11use bls12_381:: { G1Affine , G1Projective , G2Affine , Scalar } ;
22
33use dvt_abi:: { self } ;
4- use group:: GroupEncoding ;
54use sha2:: { Digest , Sha256 } ;
6- use sp1_zkvm;
75
86use crate :: bls:: {
9- bls_id_from_u32, bls_verify, bls_verify_precomputed_hash, evaluate_polynomial, evaluate_polynomial_g1_projection, hash_message_to_g2, lagrange_interpolation, PublicKey , SecretKey
7+ bls_id_from_u32, bls_verify_precomputed_hash, evaluate_polynomial,
8+ evaluate_polynomial_g1_projection, hash_message_to_g2, lagrange_interpolation, PublicKey ,
9+ SecretKey ,
1010} ;
1111
1212#[ derive( Debug ) ]
@@ -73,7 +73,6 @@ pub fn to_g1_projection(pubkey: &dvt_abi::BLSPubkey) -> G1Projective {
7373 G1Projective :: from ( to_g1_affine ( pubkey) )
7474}
7575
76-
7776pub fn verify_seed_exchange_commitment (
7877 verification_hashes : & dvt_abi:: AbiVerificationHashes ,
7978 seed_exchange : & dvt_abi:: AbiSeedExchangeCommitment ,
@@ -84,16 +83,14 @@ pub fn verify_seed_exchange_commitment(
8483
8584 let g1_pubkey = to_g1_affine ( & commitment. pubkey ) ;
8685
87-
88- let g2_sig = & G2Affine :: from_compressed ( & commitment. signature )
89- . into_option ( ) ;
86+ let g2_sig = & G2Affine :: from_compressed ( & commitment. signature ) . into_option ( ) ;
9087 if g2_sig. is_none ( ) {
9188 return Err ( Box :: new ( VerificationErrors :: UnslashableError (
9289 String :: from ( format ! (
93- "Invalid field seeds_exchange_commitment.commitment.signature {}\n " ,
90+ "Invalid field seeds_exchange_commitment.commitment.signature {}\n " ,
9491 hex:: encode( commitment. signature)
95- ) )
96- ) ) )
92+ ) ) ,
93+ ) ) ) ;
9794 }
9895 if !bls_verify_precomputed_hash (
9996 & g1_pubkey,
@@ -112,7 +109,6 @@ pub fn verify_seed_exchange_commitment(
112109 let sk = SecretKey :: from_bytes ( & shared_secret. secret ) ;
113110 if sk. is_err ( ) {
114111 return Err ( Box :: new ( VerificationErrors :: SlashableError ( String :: from (
115-
116112 format ! (
117113 "Invalid field seeds_exchange_commitment.shared_secret.secret: {} \n " ,
118114 sk. unwrap_err( )
@@ -226,7 +222,7 @@ fn agg_final_keys(
226222 . collect ( ) ;
227223
228224 let mut final_cfs = Vec :: new ( ) ;
229- for i in 0 ..verification_vectors[ 0 ] . len ( ) {
225+ for i in 0 ..verification_vectors[ 0 ] . len ( ) {
230226 let mut sum = G1Projective :: identity ( ) ;
231227 for j in 0 ..verification_vectors. len ( ) {
232228 sum = sum + verification_vectors[ j] [ i] ;
@@ -237,7 +233,7 @@ fn agg_final_keys(
237233 for i in 0 ..ids. len ( ) {
238234 let tmp = evaluate_polynomial_g1_projection ( & final_cfs, ids[ i] ) ;
239235 final_keys. push ( tmp) ;
240- }
236+ }
241237 final_keys. iter ( ) . map ( |x| G1Affine :: from ( x) ) . collect ( )
242238}
243239
@@ -275,7 +271,9 @@ pub fn verify_generation_hashes(
275271 // opcode count for n=5 924_860_863
276272 let ok = bls_verify_precomputed_hash (
277273 & to_g1_affine ( & generation. partial_pubkey ) ,
278- & G2Affine :: from_compressed ( & generation. message_signature ) . into_option ( ) . unwrap ( ) ,
274+ & G2Affine :: from_compressed ( & generation. message_signature )
275+ . into_option ( )
276+ . unwrap ( ) ,
279277 & hashed_msg,
280278 ) ;
281279
@@ -366,7 +364,7 @@ pub fn verify_generations(
366364 } )
367365 . collect ( ) ;
368366
369- let computed_key = lagrange_interpolation ( & partial_keys, & ids) ?;
367+ let computed_key = lagrange_interpolation ( & partial_keys, & ids) ?;
370368
371369 if computed_key != agg_key {
372370 return Err ( Box :: new ( std:: io:: Error :: new (
0 commit comments