@@ -159,7 +159,6 @@ function loadPublicInput(public_input_path){
159
159
for ( let i in public_input ) {
160
160
let field = public_input [ i ] ;
161
161
for ( let k in field ) {
162
- console . log ( "parsing: " , k ) ;
163
162
let element ;
164
163
if ( k == 'field' ) {
165
164
element = loadFieldElement ( field [ k ] ) ;
@@ -204,24 +203,29 @@ const verify_circuit_proof = async (modular_path: string, circuit: string) => {
204
203
) ;
205
204
206
205
let proof_path = folder_path + "/proof.bin" ;
207
- console . log ( "Verify :" , proof_path ) ;
206
+ console . log ( "Verify :" , proof_path ) ;
208
207
let proof = loadProof ( proof_path ) ;
209
208
let public_input = loadPublicInput ( folder_path + "/public_input.json" ) ;
210
- console . log ( "public input: " , public_input ) ;
211
209
let receipt = await ( await verifier_contract . verify ( proof , public_input , { gasLimit : 30_500_000 } ) ) . wait ( ) ;
212
- console . log ( "Gas used: ⛽ " , receipt . gasUsed . toNumber ( ) ) ;
210
+ console . log ( "⛽ Gas used: " , receipt . gasUsed . toNumber ( ) ) ;
213
211
console . log ( "Events received:" ) ;
214
- const event_icons : { [ key :string ] : string } = {
215
- 'WrongPublicInput' : '🤔' ,
216
- 'WrongCommitment' : '🤔' ,
217
- 'ConstraintSystemNotSatisfied' : '🤔' ,
218
- 'ProofVerified' : '✅' ,
219
- 'ProofVerificationFailed' : '🛑' ,
212
+ const event_to_string = ( event ) => {
213
+ switch ( event . event ) {
214
+ case 'VerificationResult' : {
215
+ if ( BigInt ( event . data ) != 0n ) {
216
+ return '✅ProofVerified' ;
217
+ } else {
218
+ return '🛑ProofVerificationFailed' ;
219
+ }
220
+ }
221
+ break ;
222
+ default :
223
+ return '🤔' + event . event ;
224
+ }
220
225
} ;
221
226
222
227
for ( const e of receipt . events ) {
223
- //console.log(e);
224
- console . log ( "%s: %s" , e . event , event_icons [ e . event ] ) ;
228
+ console . log ( event_to_string ( e ) ) ;
225
229
}
226
230
console . log ( "====================================" ) ;
227
231
}
0 commit comments