Skip to content

Commit 0d04ccc

Browse files
committed
adapt example
1 parent 671685e commit 0d04ccc

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/tests/inductive-proofs-internal.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Field, ZkProgram, assert, Provable, Proof } from 'o1js';
1+
import { Field, ZkProgram, assert, Provable, Proof, Experimental } from 'o1js';
22
import { tic, toc } from '../examples/utils/tic-toc.js';
33

44
let log: string[] = [];
@@ -10,7 +10,7 @@ function pushLog(s: string) {
1010
});
1111
}
1212

13-
let MaxProofsVerifiedTwo = ZkProgram({
13+
let mergeProgram = ZkProgram({
1414
name: 'recursive-2',
1515
publicOutput: Field,
1616

@@ -31,7 +31,7 @@ let MaxProofsVerifiedTwo = ZkProgram({
3131
async method() {
3232
pushLog('mergeOne');
3333
let z = Provable.witness(Field, () => 0);
34-
let x: Field = await MaxProofsVerifiedTwo.proveRecursively.baseCase(z);
34+
let x: Field = await mergeProgramRecursive.baseCase(z);
3535
return { publicOutput: x.add(1) };
3636
},
3737
},
@@ -42,20 +42,21 @@ let MaxProofsVerifiedTwo = ZkProgram({
4242
async method() {
4343
pushLog('mergeTwo');
4444
let z = Provable.witness(Field, () => 0);
45-
let x: Field = await MaxProofsVerifiedTwo.proveRecursively.baseCase(z);
46-
let y: Field = await MaxProofsVerifiedTwo.proveRecursively.mergeOne();
45+
let x: Field = await mergeProgramRecursive.baseCase(z);
46+
let y: Field = await mergeProgramRecursive.mergeOne();
4747
return { publicOutput: x.add(y) };
4848
},
4949
},
5050
},
5151
});
52+
let mergeProgramRecursive = Experimental.Recursive(mergeProgram);
5253

5354
let Wrapper = ZkProgram({
5455
name: 'wraps-recursive-2',
5556

5657
methods: {
5758
wrap: {
58-
privateInputs: [ZkProgram.Proof(MaxProofsVerifiedTwo)],
59+
privateInputs: [ZkProgram.Proof(mergeProgram)],
5960

6061
async method(proof: Proof<undefined, Field>) {
6162
proof.verify();
@@ -67,15 +68,15 @@ let Wrapper = ZkProgram({
6768
});
6869

6970
tic('compiling');
70-
await MaxProofsVerifiedTwo.compile();
71+
await mergeProgram.compile();
7172
await Wrapper.compile();
7273
toc();
7374

7475
tic('executing 4 proofs');
75-
let { proof } = await MaxProofsVerifiedTwo.mergeTwo();
76+
let { proof } = await mergeProgram.mergeTwo();
7677
toc();
7778

78-
assert(await MaxProofsVerifiedTwo.verify(proof), 'Proof is not valid');
79+
assert(await mergeProgram.verify(proof), 'Proof is not valid');
7980

8081
proof.publicOutput.assertEquals(15);
8182

0 commit comments

Comments
 (0)