Skip to content

Commit 6890754

Browse files
committed
adapt hash chain example
1 parent bff1f19 commit 6890754

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/examples/zkprogram/hash-chain.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import {
88
assert,
99
Bool,
10+
Experimental,
1011
Field,
1112
Poseidon,
1213
Provable,
@@ -42,17 +43,18 @@ const hashChain = ZkProgram({
4243
// we have y = hash^k(x)
4344
// now do z = hash^(n-k)(y) = hash^n(x) by calling this method recursively
4445
// except if we have k = n, then ignore the output and use y
45-
let z: Field = await hashChain.proveRecursivelyIf.chain(
46-
reachedN.not(),
47-
{ x: y, n: n.sub(k) }
48-
);
46+
let z: Field = await hashChainRecursive.chain.if(reachedN.not(), {
47+
x: y,
48+
n: n.sub(k),
49+
});
4950
z = Provable.if(reachedN, y, z);
5051
Provable.log('hashChain (start proving)', n);
5152
return { publicOutput: z };
5253
},
5354
},
5455
},
5556
});
57+
let hashChainRecursive = Experimental.Recursive(hashChain);
5658

5759
await hashChain.compile();
5860

0 commit comments

Comments
 (0)