Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(noir_js)!: Rename inner and outer proof methods #2845

Merged
merged 4 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tooling/noir_js/test/backend/barretenberg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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
Expand All @@ -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);
}
Expand Down
18 changes: 9 additions & 9 deletions tooling/noir_js/test/node/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand All @@ -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;
});

Expand Down Expand Up @@ -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.',
);
Expand Down Expand Up @@ -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);
Expand Down