1- import { Field , ZkProgram , assert , Provable , Proof } from 'o1js' ;
1+ import { Field , ZkProgram , assert , Provable , Proof , Experimental } from 'o1js' ;
22import { tic , toc } from '../examples/utils/tic-toc.js' ;
33
44let 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
5354let 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
6970tic ( 'compiling' ) ;
70- await MaxProofsVerifiedTwo . compile ( ) ;
71+ await mergeProgram . compile ( ) ;
7172await Wrapper . compile ( ) ;
7273toc ( ) ;
7374
7475tic ( 'executing 4 proofs' ) ;
75- let { proof } = await MaxProofsVerifiedTwo . mergeTwo ( ) ;
76+ let { proof } = await mergeProgram . mergeTwo ( ) ;
7677toc ( ) ;
7778
78- assert ( await MaxProofsVerifiedTwo . verify ( proof ) , 'Proof is not valid' ) ;
79+ assert ( await mergeProgram . verify ( proof ) , 'Proof is not valid' ) ;
7980
8081proof . publicOutput . assertEquals ( 15 ) ;
8182
0 commit comments