-
Notifications
You must be signed in to change notification settings - Fork 134
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Follow-up to #1931
Adds another API
<methodName>.if()
toExperimental.Recursive
for recursion within programs that is conditional on aBool
. 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