Skip to content

Commit

Permalink
adapt hash chain example
Browse files Browse the repository at this point in the history
  • Loading branch information
mitschabaude committed Dec 17, 2024
1 parent bff1f19 commit 6890754
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/examples/zkprogram/hash-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import {
assert,
Bool,
Experimental,
Field,
Poseidon,
Provable,
Expand Down Expand Up @@ -42,17 +43,18 @@ const hashChain = ZkProgram({
// we have y = hash^k(x)
// now do z = hash^(n-k)(y) = hash^n(x) by calling this method recursively
// except if we have k = n, then ignore the output and use y
let z: Field = await hashChain.proveRecursivelyIf.chain(
reachedN.not(),
{ x: y, n: n.sub(k) }
);
let z: Field = await hashChainRecursive.chain.if(reachedN.not(), {
x: y,
n: n.sub(k),
});
z = Provable.if(reachedN, y, z);
Provable.log('hashChain (start proving)', n);
return { publicOutput: z };
},
},
},
});
let hashChainRecursive = Experimental.Recursive(hashChain);

await hashChain.compile();

Expand Down

0 comments on commit 6890754

Please sign in to comment.