1- use agg_mode_sdk:: types:: Network ;
1+ use agg_mode_sdk:: {
2+ blockchain:: {
3+ provider:: ProofAggregationServiceProvider , AggregationModeVerificationData , ProofStatus ,
4+ } ,
5+ types:: Network ,
6+ } ;
7+ use alloy:: hex;
28use clap:: { self , Args } ;
39use std:: path:: PathBuf ;
410
@@ -18,10 +24,56 @@ pub struct VerifyOnChainArgs {
1824 proving_system : ProvingSystemArg ,
1925 #[ arg( name = "Program verification key hash" , long = "vk" , required = true ) ]
2026 program_vk : PathBuf ,
21- #[ arg( long = "vk" ) ]
22- verifying_key_path : PathBuf ,
2327 #[ arg( name = "Public input file name" , long = "public-input" ) ]
2428 pub_input_file_name : Option < PathBuf > ,
2529}
2630
27- pub async fn run ( args : VerifyOnChainArgs ) { }
31+ pub async fn run ( args : VerifyOnChainArgs ) {
32+ let program_id_key: [ u8 ; 32 ] = std:: fs:: read ( & args. program_vk )
33+ . expect ( "to read program vk file" )
34+ . try_into ( )
35+ . expect ( "Invalid hexadecimal encoded vk hash" ) ;
36+
37+ let Some ( pub_inputs_file_name) = args. pub_input_file_name else {
38+ tracing:: error!( "Public input file not provided" ) ;
39+ return ;
40+ } ;
41+ let public_inputs =
42+ std:: fs:: read ( & pub_inputs_file_name) . expect ( "to read program public inputs file" ) ;
43+
44+ let provider =
45+ ProofAggregationServiceProvider :: new ( args. network , args. rpc_url , args. beacon_url ) ;
46+
47+ let verification_data = AggregationModeVerificationData :: SP1 {
48+ vk : program_id_key,
49+ public_inputs,
50+ } ;
51+
52+ let proof_status = match provider
53+ . check_proof_verification ( args. from_block , verification_data)
54+ . await
55+ {
56+ Ok ( res) => res,
57+ Err ( e) => {
58+ tracing:: error!( "Error while trying to verify proof {:?}" , e) ;
59+ return ;
60+ }
61+ } ;
62+
63+ match proof_status {
64+ ProofStatus :: Verified { merkle_root, .. } => {
65+ tracing:: info!(
66+ "Your proof has been verified in the aggregated proof with merkle root 0x{}" ,
67+ hex:: encode( merkle_root)
68+ ) ;
69+ }
70+ ProofStatus :: Invalid => {
71+ tracing:: error!(
72+ "Your proof was found in the blob but the Merkle Root verification failed."
73+ )
74+ }
75+ ProofStatus :: NotFound => {
76+ tracing:: error!( "Your proof wasn't found in the logs. Try specifying an earlier `from_block` to search further back in history." )
77+ }
78+ }
79+ }
0 commit comments