Skip to content

Commit

Permalink
chore(docs): Updates following is_recursive flag removal (#4199)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Followup to #4187 for resolving
#4139

## Summary\*

We no longer need to distinguish between `generateIntermediateProof` and
`generateFinalProof`. This will go into effect once
AztecProtocol/aztec-packages#4221 is merged and
released.

## Additional Context

## Documentation\*

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.

---------

Co-authored-by: José Pedro Sousa <outgoing@zpedro.dev>
Co-authored-by: Cat McGee <helloworld@mcgee.cat>
  • Loading branch information
3 people committed Feb 1, 2024
1 parent 593916b commit 96a74bb
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions docs/docs/how_to/how-to-recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ In short:

:::

In a standard recursive app, you're also dealing with at least two circuits. For the purpose of this guide, we will assume these two:
In a standard recursive app, you're also dealing with at least two circuits. For the purpose of this guide, we will assume the following:

- `main`: a circuit of type `assert(x != y)`
- `main`: a circuit of type `assert(x != y)`, where `main` is marked with a `#[recursive]` attribute. This attribute states that the backend should generate proofs that are friendly for verification within another circuit.
- `recursive`: a circuit that verifies `main`

For a full example on how recursive proofs work, please refer to the [noir-examples](https://github.com/noir-lang/noir-examples) repository. We will *not* be using it as a reference for this guide.
Expand Down Expand Up @@ -77,7 +77,7 @@ const { witness } = noir.execute(input)
With this witness, you are now able to generate the intermediate proof for the main circuit:

```js
const { proof, publicInputs } = await backend.generateIntermediateProof(witness)
const { proof, publicInputs } = await backend.generateProof(witness)
```

:::warning
Expand All @@ -95,13 +95,13 @@ With this in mind, it becomes clear that our intermediate proof is the one *mean
Optionally, you are able to verify the intermediate proof:

```js
const verified = await backend.verifyIntermediateProof({ proof, publicInputs })
const verified = await backend.verifyProof({ proof, publicInputs })
```

This can be useful to make sure our intermediate proof was correctly generated. But the real goal is to do it within another circuit. For that, we need to generate the intermediate artifacts:
This can be useful to make sure our intermediate proof was correctly generated. But the real goal is to do it within another circuit. For that, we need to generate recursive proof artifacts that will be passed to the circuit that is verifying the proof we just generated. Instead of passing the proof and verification key as a byte array, we pass them as fields which makes it cheaper to verify in a circuit:

```js
const { proofAsFields, vkAsFields, vkHash } = await backend.generateIntermediateProofArtifacts( { publicInputs, proof }, publicInputsCount)
const { proofAsFields, vkAsFields, vkHash } = await backend.generateRecursiveProofArtifacts( { publicInputs, proof }, publicInputsCount)
```

This call takes the public inputs and the proof, but also the public inputs count. While this is easily retrievable by simply counting the `publicInputs` length, the backend interface doesn't currently abstract it away.
Expand Down Expand Up @@ -135,8 +135,8 @@ const recursiveInputs = {
}

const { witness, returnValue } = noir.execute(recursiveInputs) // we're executing the recursive circuit now!
const { proof, publicInputs } = backend.generateFinalProof(witness)
const verified = backend.verifyFinalProof({ proof, publicInputs })
const { proof, publicInputs } = backend.generateProof(witness)
const verified = backend.verifyProof({ proof, publicInputs })
```

You can obviously chain this proof into another proof. In fact, if you're using recursive proofs, you're probably interested of using them this way!
Expand Down Expand Up @@ -165,15 +165,15 @@ This allows you to neatly call exactly the method you want without conflicting n
```js
// Alice runs this 👇
const { witness: mainWitness } = await noir_programs.main.execute(input)
const proof = await backends.main.generateIntermediateProof(mainWitness)
const proof = await backends.main.generateProof(mainWitness)

// Bob runs this 👇
const verified = await backends.main.verifyIntermediateProof(proof)
const { proofAsFields, vkAsFields, vkHash } = await backends.main.generateIntermediateProofArtifacts(
const verified = await backends.main.verifyProof(proof)
const { proofAsFields, vkAsFields, vkHash } = await backends.main.generateRecursiveProofArtifacts(
proof,
numPublicInputs,
);
const recursiveProof = await noir_programs.recursive.generateFinalProof(recursiveInputs)
const recursiveProof = await noir_programs.recursive.generateProof(recursiveInputs)
```

:::

0 comments on commit 96a74bb

Please sign in to comment.