Skip to content

Commit

Permalink
fix: adding proving key initialization (#3322)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom French <[email protected]>
  • Loading branch information
signorecello and TomAFrench authored Nov 17, 2023
1 parent 73c2077 commit 3383740
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
27 changes: 4 additions & 23 deletions tooling/noir_js/test/node/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -97,16 +85,9 @@ 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');
}
const verifier = new Backend(assert_lt_program);
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
Expand Down
1 change: 1 addition & 0 deletions tooling/noir_js_backend_barretenberg/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class BarretenbergBackend implements Backend {
await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data()));

this.acirComposer = await api.acirNewAcirComposer(subgroupSize);
await api.acirInitProvingKey(this.acirComposer, this.acirUncompressedBytecode);
this.api = api;
}
}
Expand Down

0 comments on commit 3383740

Please sign in to comment.