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

Conditional recursion from within ZkProgram #1932

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

mitschabaude
Copy link
Collaborator

@mitschabaude mitschabaude commented Nov 28, 2024

Follow-up to #1931

Adds another API <methodName>.if() to Experimental.Recursive for recursion within programs that is conditional on a Bool. If the condition is false, we return a dummy proof that is not verified.

For the first time ever, this enables us to implement a recursive function using recursive proofs in o1js! (Because the condition enables us to stop recursing eventually)

See a simple example of self-recursion at hash-chain.ts

@mitschabaude mitschabaude requested review from a team as code owners November 28, 2024 15:35
@mitschabaude mitschabaude requested review from hattyhattington17 and querolita and removed request for a team November 28, 2024 15:35
@mitschabaude mitschabaude changed the base branch from feature/declare-proofs to feature/zkprogram-qol December 17, 2024 16:10
@mitschabaude
Copy link
Collaborator Author

mitschabaude commented Dec 19, 2024

with #1931 and #1933 approved merged, this is ripe for review!

Base automatically changed from feature/zkprogram-qol to main December 19, 2024 15:54
Copy link
Contributor

@45930 45930 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -56,6 +56,7 @@ import { emptyWitness } from '../provable/types/util.js';
import { InferValue } from '../../bindings/lib/provable-generic.js';
import { DeclaredProof, ZkProgramContext } from './zkprogram-context.js';
import { mapObject, mapToObject, zip } from '../util/arrays.js';
import { Bool } from '../provable/bool.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to import Bool here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be a left-over import, will fix!

Copy link
Contributor

@ymekuria ymekuria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants