1919use zeroize:: Zeroize ;
2020
2121use ark_ec:: { AffineRepr , CurveGroup } ;
22- use ark_ff:: PrimeField ;
22+ use ark_ff:: { One , PrimeField , Zero } ;
2323use ark_serialize:: { CanonicalDeserialize , CanonicalSerialize } ;
2424use ark_std:: vec:: Vec ;
2525
@@ -58,7 +58,7 @@ pub use codec::Codec;
5858
5959#[ derive( Debug ) ]
6060pub enum Error {
61- /// Verification error(s)
61+ /// Verification error
6262 VerificationFailure ,
6363 /// Bad input data
6464 InvalidData ,
@@ -135,9 +135,9 @@ pub trait Suite: Copy {
135135
136136 /// Hash data to a curve point.
137137 ///
138- /// By default uses "try and increment" method described by RFC 9381.
138+ /// By default uses "try and increment" method described by RFC- 9381.
139139 ///
140- /// The input `data` is assumed to be `[salt||]alpha` according to the RFC 9381.
140+ /// The input `data` is assumed to be `[salt||]alpha` according to the RFC- 9381.
141141 /// In other words, salt is not applied by this function.
142142 #[ inline( always) ]
143143 fn data_to_point ( data : & [ u8 ] ) -> Option < AffinePoint < Self > > {
@@ -146,10 +146,10 @@ pub trait Suite: Copy {
146146
147147 /// Map the point to a hash value using `Self::Hasher`.
148148 ///
149- /// By default uses the algorithm described by RFC 9381.
149+ /// By default uses the algorithm described by RFC- 9381 without cofactor clearing .
150150 #[ inline( always) ]
151151 fn point_to_hash ( pt : & AffinePoint < Self > ) -> HashOutput < Self > {
152- utils:: point_to_hash_rfc_9381 :: < Self > ( pt)
152+ utils:: point_to_hash_rfc_9381 :: < Self > ( pt, false )
153153 }
154154
155155 /// Generator used through all the suite.
@@ -221,7 +221,10 @@ impl<S: Suite> Secret<S> {
221221 /// The `seed` is hashed using the `Suite::hash` to construct the secret scalar.
222222 pub fn from_seed ( seed : & [ u8 ] ) -> Self {
223223 let bytes = utils:: hash :: < S :: Hasher > ( seed) ;
224- let scalar = ScalarField :: < S > :: from_le_bytes_mod_order ( & bytes[ ..] ) ;
224+ let mut scalar = ScalarField :: < S > :: from_le_bytes_mod_order ( & bytes[ ..] ) ;
225+ if scalar. is_zero ( ) {
226+ scalar. set_one ( ) ;
227+ }
225228 Self :: from_scalar ( scalar)
226229 }
227230
0 commit comments