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: Add #[recursive] Explainer to Documentation #4399

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions docs/docs/noir/standard_library/recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ Noir supports recursively verifying proofs, meaning you verify the proof of a No

Read [the explainer on recursion](../../explainers/explainer-recursion.md) to know more about this function and the [guide on how to use it.](../../how_to/how-to-recursion.md)

## The `#[recursive]` Attribute

In Noir, the `#[recursive]` attribute is used to indicate that a circuit is designed for recursive proof generation. When applied, it informs the compiler and the tooling that the circuit should be compiled in a way that makes its proofs suitable for recursive verification. This attribute eliminates the need for manual flagging of recursion at the tooling level, streamlining the proof generation process for recursive circuits.

### Example usage with `#[recursive]`

```rust
#[recursive]
fn main(x: Field, y: pub Field) {
assert(x == y, "x and y are not equal");
}

// This marks the circuit as recursion-friendly and indicates that proofs generated from this circuit
// are intended for recursive verification.
```

By incorporating this attribute directly in the circuit's definition, tooling like Nargo and NoirJS can automatically handle the proving of recursive Noir programs without requiring additional flags or configurations.
Savio-Sou marked this conversation as resolved.
Show resolved Hide resolved

## Verifying Recursive Proofs

```rust
#[foreign(verify_proof)]
fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : Field, _key_hash : Field) {}
Expand Down
Loading