11use bls12_381:: {
22 hash_to_curve:: { ExpandMsgXmd , HashToCurve } ,
3- multi_miller_loop, G1Affine , G1Projective , G2Affine , G2Prepared , G2Projective , Gt , Scalar ,
3+ multi_miller_loop, G1Affine , G1Projective , G2Affine , G2Prepared , G2Projective , Gt ,
44} ;
55use eyre:: { eyre, Result } ;
66use serde:: { Deserialize , Serialize } ;
@@ -44,11 +44,6 @@ impl Signature {
4444 return false ;
4545 } ;
4646
47- // Subgroup check for signature
48- if !subgroup_check_g2 ( & sig_point) {
49- return false ;
50- }
51-
5247 verify_with_aggregate_pk ( & sig_point, msg, aggregate_public_key)
5348 }
5449
@@ -84,14 +79,6 @@ fn verify_with_aggregate_pk(
8479 ate2_evaluation ( sig_point, & generator_g1_negative, & msg_hash, & key_point)
8580}
8681
87- /// Verifies a G2 point is in subgroup `r`.
88- fn subgroup_check_g2 ( point : & G2Affine ) -> bool {
89- const CURVE_ORDER : & str = "73EDA753299D7D483339D80809A1D80553BDA402FFFE5BFEFFFFFFFF00000001" ;
90- let r = hex_to_scalar ( CURVE_ORDER ) . unwrap ( ) ;
91- let check = point * r;
92- check. is_identity ( ) . into ( )
93- }
94-
9582/// Evaluation of e(S, -G1) * e(H, PK) == 1
9683fn ate2_evaluation ( p1 : & G2Affine , q1 : & G1Affine , r1 : & G2Affine , s1 : & G1Affine ) -> bool {
9784 // Prepare G2 points for efficient pairing
@@ -113,25 +100,3 @@ fn hash_to_curve(msg: &[u8]) -> G2Projective {
113100 const DST : & [ u8 ] = b"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_" ;
114101 <G2Projective as HashToCurve < ExpandMsgXmd < sha2:: Sha256 > > >:: hash_to_curve ( msg, DST )
115102}
116-
117- /// Converts hex string to scalar
118- fn hex_to_scalar ( hex : & str ) -> Option < Scalar > {
119- if hex. len ( ) != 64 {
120- return None ;
121- }
122-
123- let mut raw = [ 0u64 ; 4 ] ;
124- for ( i, chunk) in hex. as_bytes ( ) . chunks ( 16 ) . enumerate ( ) . take ( 4 ) {
125- if let Ok ( hex_chunk) = core:: str:: from_utf8 ( chunk) {
126- if let Ok ( value) = u64:: from_str_radix ( hex_chunk, 16 ) {
127- raw[ 3 - i] = value. to_le ( ) ;
128- } else {
129- return None ;
130- }
131- } else {
132- return None ;
133- }
134- }
135-
136- Some ( Scalar :: from_raw ( raw) )
137- }
0 commit comments