From 8f009fa06d92a26c3471613dfe96f85c2f891d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Fri, 27 Oct 2023 20:22:34 +0100 Subject: [PATCH 1/4] fix: adding proving key initialization --- tooling/noir_js_backend_barretenberg/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tooling/noir_js_backend_barretenberg/src/index.ts b/tooling/noir_js_backend_barretenberg/src/index.ts index 11c56a7384d..2a19992d8ba 100644 --- a/tooling/noir_js_backend_barretenberg/src/index.ts +++ b/tooling/noir_js_backend_barretenberg/src/index.ts @@ -37,6 +37,7 @@ export class BarretenbergBackend implements Backend { await api.commonInitSlabAllocator(subgroupSize); await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data())); + await api.acirInitProvingKey(this.acirComposer, this.acirUncompressedBytecode); this.acirComposer = await api.acirNewAcirComposer(subgroupSize); this.api = api; } From 78222dd3638b479d3182b23492d42934222ab073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Sat, 28 Oct 2023 22:00:37 +0100 Subject: [PATCH 2/4] =?UTF-8?q?even=20in=20a=201-liner=20PR=20=F0=9F=A4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tooling/noir_js_backend_barretenberg/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/noir_js_backend_barretenberg/src/index.ts b/tooling/noir_js_backend_barretenberg/src/index.ts index 2a19992d8ba..9dcf516ccca 100644 --- a/tooling/noir_js_backend_barretenberg/src/index.ts +++ b/tooling/noir_js_backend_barretenberg/src/index.ts @@ -37,8 +37,8 @@ export class BarretenbergBackend implements Backend { await api.commonInitSlabAllocator(subgroupSize); await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data())); - await api.acirInitProvingKey(this.acirComposer, this.acirUncompressedBytecode); this.acirComposer = await api.acirNewAcirComposer(subgroupSize); + await api.acirInitProvingKey(this.acirComposer, this.acirUncompressedBytecode); this.api = api; } } From 8346b5737906d9a82be62a035cba82b4f47ef6b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Sun, 29 Oct 2023 11:39:24 +0000 Subject: [PATCH 3/4] fix: found out this fix solved one of the known bugs --- tooling/noir_js/test/node/e2e.test.ts | 28 +++++---------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index f7c3ea37a1a..b9d3312da98 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -69,19 +69,7 @@ it('end-to-end proof creation and verification (inner)', async () => { expect(isValid).to.be.true; }); -// The "real" workflow will involve a prover and a verifier on different systems. -// -// We cannot do this in our tests because they will panic with: -// `unreachable` -// -// This happens when we we create a proof with one barretenberg instance and -// try to verify it with another. -// -// If this bug is fixed, we can remove this test and split barretenberg into -// a prover and verifier class to more accurately reflect what happens in production. -// -// If its not fixable, we can leave it in as documentation of this behavior. -it('[BUG] -- bb.js unreachable (different instance) ', async () => { +it('end-to-end proving and verification with different instances', async () => { // Noir.Js part const inputs = { x: '2', @@ -97,16 +85,10 @@ it('[BUG] -- bb.js unreachable (different instance) ', async () => { const proof = await prover.generateFinalProof(witness); - try { - const verifier = new Backend(assert_lt_program); - await verifier.verifyFinalProof(proof); - expect.fail( - 'bb.js currently returns a bug when we try to verify a proof with a different Barretenberg instance that created it.', - ); - } catch (error) { - const knownError = error as Error; - expect(knownError.message).to.contain('unreachable'); - } + // try { + const verifier = new Backend(assert_lt_program); + const verify = await verifier.verifyFinalProof(proof); + expect(verify).to.be.true; }); // This bug occurs when we use the same backend to create an inner proof and then an outer proof From 011f52f9feff8e7e0a9a11cfe5b6ffa270c84a0d Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:24:37 +0000 Subject: [PATCH 4/4] Apply suggestions from code review --- tooling/noir_js/test/node/e2e.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index b9d3312da98..33d64377b06 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -85,10 +85,9 @@ it('end-to-end proving and verification with different instances', async () => { const proof = await prover.generateFinalProof(witness); - // try { const verifier = new Backend(assert_lt_program); - const verify = await verifier.verifyFinalProof(proof); - expect(verify).to.be.true; + const proof_is_valid = await verifier.verifyFinalProof(proof); + expect(proof_is_valid).to.be.true; }); // This bug occurs when we use the same backend to create an inner proof and then an outer proof