@@ -28,11 +28,13 @@ use aligned_batcher_lib::types::{
2828} ;
2929use clap:: Subcommand ;
3030use ethers:: utils:: hex;
31+ use sha3:: { Digest , Keccak256 } ;
3132
3233use crate :: errors:: BatcherClientError ;
3334use crate :: types:: AlignedVerificationData ;
3435use crate :: AlignedCommands :: Submit ;
3536use crate :: AlignedCommands :: VerifyProofOnchain ;
37+ use crate :: AlignedCommands :: GetVerificationKeyCommitment ;
3638
3739use clap:: { Parser , ValueEnum } ;
3840
@@ -49,6 +51,10 @@ pub enum AlignedCommands {
4951 Submit ( SubmitArgs ) ,
5052 #[ clap( about = "Verify the proof was included in a verified batch on Ethereum" ) ]
5153 VerifyProofOnchain ( VerifyProofOnchainArgs ) ,
54+
55+ // GetVericiationKey, command name is get-vk-commitment
56+ #[ clap( about = "Create verification key for proving system" , name = "get-vk-commitment" ) ]
57+ GetVerificationKeyCommitment ( GetVerificationKeyCommitmentArgs ) ,
5258}
5359
5460#[ derive( Parser , Debug ) ]
@@ -109,6 +115,15 @@ pub struct VerifyProofOnchainArgs {
109115 chain : Chain ,
110116}
111117
118+ #[ derive( Parser , Debug ) ]
119+ #[ command( version, about, long_about = None ) ]
120+ pub struct GetVerificationKeyCommitmentArgs {
121+ #[ arg( name = "File name" , long = "input" ) ]
122+ input_file : PathBuf ,
123+ #[ arg( name = "Output file" , long = "output" ) ]
124+ output_file : Option < PathBuf > ,
125+ }
126+
112127#[ derive( Debug , Clone , ValueEnum ) ]
113128pub enum Chain {
114129 Devnet ,
@@ -170,7 +185,6 @@ async fn main() -> Result<(), errors::BatcherClientError> {
170185 )
171186 . await ?;
172187 }
173-
174188 VerifyProofOnchain ( verify_inclusion_args) => {
175189 let contract_address = match verify_inclusion_args. chain {
176190 Chain :: Devnet => "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8" ,
@@ -222,6 +236,22 @@ async fn main() -> Result<(), errors::BatcherClientError> {
222236 Err ( err) => error ! ( "Error while reading batch inclusion verification: {}" , err) ,
223237 }
224238 }
239+ GetVerificationKeyCommitment ( args) => {
240+ let content = read_file ( args. input_file ) ?;
241+
242+ let mut hasher = Keccak256 :: new ( ) ;
243+ hasher. update ( & content) ;
244+ let hash: [ u8 ; 32 ] = hasher. finalize ( ) . into ( ) ;
245+
246+ info ! ( "Commitment: {}" , hex:: encode( hash) ) ;
247+ if let Some ( output_file) = args. output_file {
248+ let mut file = File :: create ( output_file. clone ( ) )
249+ . map_err ( |e| BatcherClientError :: IoError ( output_file. clone ( ) , e) ) ?;
250+
251+ file. write_all ( hex:: encode ( hash) . as_bytes ( ) )
252+ . map_err ( |e| BatcherClientError :: IoError ( output_file. clone ( ) , e) ) ?;
253+ }
254+ }
225255 }
226256
227257 Ok ( ( ) )
0 commit comments