@@ -33,49 +33,39 @@ type FullNoir = {
33
33
}
34
34
35
35
async function start ( ) {
36
- // Generate inner proof artifacts
37
- console . log ( "Creating Noir from circuit..." ) ;
38
36
const simple : FullNoir = await fullNoirFromCircuit ( 'not_odd' ) ;
37
+ const outer : FullNoir = await fullNoirFromCircuit ( 'recurse' ) ;
39
38
40
- console . log ( "Executing binary circuit for witness..." ) ;
41
- const innerInput = { n : 2 } ;
42
- const innerWitness = ( await simple . noir . execute ( innerInput ) ) . witness ;
43
- console . log ( "Generating intermediate proof..." ) ;
44
- const innerProof : ProofData = await simple . backend . generateProof ( innerWitness ) ;
39
+ // Generate inner proof artifacts
40
+ console . log ( "Generating intermediate proof artifacts 1..." ) ;
41
+ const innerWitness1 = ( await simple . noir . execute ( { n : 2 } ) ) . witness ;
42
+ const innerProof1 : ProofData = await simple . backend . generateProof ( innerWitness1 ) ;
43
+ const artifacts1 = await simple . backend . generateRecursiveProofArtifacts ( innerProof1 , 1 ) ;
45
44
46
- if ( false ) { // mess up proof
47
- console . log ( "Messing intermediate proof..." ) ;
48
- innerProof . proof [ 0 ] += 1 ;
49
- }
45
+ console . log ( "Generating intermediate proof artifacts 2..." ) ;
46
+ const innerWitness2 = ( await simple . noir . execute ( { n : 4 } ) ) . witness ;
47
+ const innerProof2 : ProofData = await simple . backend . generateProof ( innerWitness2 ) ;
48
+ const artifacts2 = await simple . backend . generateRecursiveProofArtifacts ( innerProof2 , 1 ) ;
50
49
51
- console . log ( "Generating recursive proof artifacts..." ) ;
52
- const { proofAsFields, vkAsFields, vkHash } = await simple . backend . generateRecursiveProofArtifacts ( innerProof , 1 ) ;
53
- // console.log({ proofAsFields, vkAsFields, vkHash });
54
50
simple . backend . destroy ( ) ;
55
51
56
52
// Generate and verify outer proof
57
- console . log ( "Creating Noir from circuit..." ) ;
58
- const outer : FullNoir = await fullNoirFromCircuit ( 'recurse' ) ;
59
- console . log ( "Executing binary circuit for witness..." ) ;
53
+ console . log ( "Generating outer proof..." ) ;
60
54
const outerInput = {
61
- verification_key : vkAsFields ,
62
- proof : proofAsFields ,
63
- public_inputs : [ "0" ] ,
64
- key_hash : vkHash
55
+ verification_key : artifacts1 . vkAsFields ,
56
+ public_inputs : [ "1" ] , // expect output of inner call to be "true"
57
+ key_hash : artifacts1 . vkHash ,
58
+ proof1 : artifacts1 . proofAsFields ,
59
+ proof2 : artifacts2 . proofAsFields
65
60
} ;
66
61
const outerWitness = ( await outer . noir . execute (
67
62
outerInput
68
63
) ) . witness ;
69
-
70
- console . log ( "Generating outer proof..." ) ;
71
64
const outerProof : ProofData = await outer . backend . generateProof ( outerWitness ) ;
72
65
73
66
console . log ( "Verifying outer proof..." ) ;
74
- console . log ( await outer . backend . verifyProof ( outerProof ) ) ;
75
-
76
- // console.log("Executing lib circuit function to verify inner proof");
77
- // let res = await main(vkAsFields, proofAsFields, ["7"], vkHash);
78
- // console.log(res);
67
+ const res : boolean = await outer . backend . verifyProof ( outerProof ) ;
68
+ console . log ( "Verification" , res ? "PASSED" : "failed" ) ;
79
69
80
70
outer . backend . destroy ( ) ;
81
71
}
0 commit comments