From 71dbbb863a6f262da4804c17965ace627bf3a278 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Tue, 26 Sep 2023 15:38:30 +0100 Subject: [PATCH] chore(noir_js)!: Rename inner and outer proof methods (#2845) --- tooling/noir_js/test/backend/barretenberg.ts | 10 +++++----- tooling/noir_js/test/node/e2e.test.ts | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tooling/noir_js/test/backend/barretenberg.ts b/tooling/noir_js/test/backend/barretenberg.ts index 6a770cde2f2..cc812084f87 100644 --- a/tooling/noir_js/test/backend/barretenberg.ts +++ b/tooling/noir_js/test/backend/barretenberg.ts @@ -42,7 +42,7 @@ export class Backend { // // The settings for this proof are the same as the settings for a "normal" proof // ie one that is not in the recursive setting. - async generateOuterProof(decompressedWitness: Uint8Array) { + async generateFinalProof(decompressedWitness: Uint8Array) { const makeEasyToVerifyInCircuit = false; return this.generateProof(decompressedWitness, makeEasyToVerifyInCircuit); } @@ -58,7 +58,7 @@ export class Backend { // We set `makeEasyToVerifyInCircuit` to true, which will tell the backend to // generate the proof using components that will make the proof // easier to verify in a circuit. - async generateInnerProof(witness: Uint8Array) { + async generateIntermediateProof(witness: Uint8Array) { const makeEasyToVerifyInCircuit = true; return this.generateProof(witness, makeEasyToVerifyInCircuit); } @@ -83,7 +83,7 @@ export class Backend { // method. // // The number of public inputs denotes how many public inputs are in the inner proof. - async generateInnerProofArtifacts(proof: Uint8Array, numOfPublicInputs = 0) { + async generateIntermediateProofArtifacts(proof: Uint8Array, numOfPublicInputs = 0) { const proofAsFields = await this.api.acirSerializeProofIntoFields(this.acirComposer, proof, numOfPublicInputs); // TODO: perhaps we should put this in the init function. Need to benchmark @@ -100,13 +100,13 @@ export class Backend { }; } - async verifyOuterProof(proof: Uint8Array) { + async verifyFinalProof(proof: Uint8Array) { const makeEasyToVerifyInCircuit = false; const verified = await this.verifyProof(proof, makeEasyToVerifyInCircuit); return verified; } - async verifyInnerProof(proof: Uint8Array) { + async verifyIntermediateProof(proof: Uint8Array) { const makeEasyToVerifyInCircuit = true; return this.verifyProof(proof, makeEasyToVerifyInCircuit); } diff --git a/tooling/noir_js/test/node/e2e.test.ts b/tooling/noir_js/test/node/e2e.test.ts index 18413074871..bbb936ea6e5 100644 --- a/tooling/noir_js/test/node/e2e.test.ts +++ b/tooling/noir_js/test/node/e2e.test.ts @@ -16,10 +16,10 @@ it('end-to-end proof creation and verification (outer)', async () => { // Proof creation const prover = new Backend(assert_lt_json.bytecode); await prover.init(); - const proof = await prover.generateOuterProof(serializedWitness); + const proof = await prover.generateFinalProof(serializedWitness); // Proof verification - const isValid = await prover.verifyOuterProof(proof); + const isValid = await prover.verifyFinalProof(proof); expect(isValid).to.be.true; }); @@ -36,10 +36,10 @@ it('end-to-end proof creation and verification (inner)', async () => { // Proof creation const prover = new Backend(assert_lt_json.bytecode); await prover.init(); - const proof = await prover.generateInnerProof(serializedWitness); + const proof = await prover.generateIntermediateProof(serializedWitness); // Proof verification - const isValid = await prover.verifyInnerProof(proof); + const isValid = await prover.verifyIntermediateProof(proof); expect(isValid).to.be.true; }); @@ -67,12 +67,12 @@ it('[BUG] -- bb.js null function or function signature mismatch (different insta const prover = new Backend(assert_lt_json.bytecode); await prover.init(); - const proof = await prover.generateOuterProof(serializedWitness); + const proof = await prover.generateFinalProof(serializedWitness); try { const verifier = new Backend(assert_lt_json.bytecode); await verifier.init(); - await verifier.verifyOuterProof(proof); + 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.', ); @@ -105,13 +105,13 @@ it('[BUG] -- bb.js null function or function signature mismatch (outer-inner) ', await prover.init(); // Create a proof using both proving systems, the majority of the time // one would only use outer proofs. - const proofOuter = await prover.generateOuterProof(serializedWitness); - const _proofInner = await prover.generateInnerProof(serializedWitness); + const proofOuter = await prover.generateFinalProof(serializedWitness); + const _proofInner = await prover.generateIntermediateProof(serializedWitness); // Proof verification // try { - const isValidOuter = await prover.verifyOuterProof(proofOuter); + const isValidOuter = await prover.verifyFinalProof(proofOuter); expect(isValidOuter).to.be.true; // We can also try verifying an inner proof and it will fail. // const isValidInner = await prover.verifyInnerProof(_proofInner);