@@ -11,13 +11,13 @@ use crate::curve::twedwards::extended::ExtendedPoint as TwistedExtendedPoint;
1111use crate :: field:: { FieldElement , Scalar } ;
1212use crate :: * ;
1313use elliptic_curve:: {
14- array:: {
15- typenum:: { Unsigned , U56 , U57 , U84 } ,
16- Array ,
17- } ,
18- group:: { cofactor:: CofactorGroup , prime:: PrimeGroup , Curve , Group , GroupEncoding } ,
14+ Error ,
15+ array:: { Array , typenum:: Unsigned } ,
16+ consts:: { U28 , U84 } ,
17+ group:: { Curve , Group , GroupEncoding , cofactor:: CofactorGroup , prime:: PrimeGroup } ,
1918 hash2curve:: { ExpandMsg , ExpandMsgXof , Expander , FromOkm } ,
2019 ops:: LinearCombination ,
20+ point:: NonIdentity ,
2121} ;
2222use rand_core:: TryRngCore ;
2323use subtle:: { Choice , ConditionallyNegatable , ConditionallySelectable , ConstantTimeEq , CtOption } ;
@@ -747,7 +747,7 @@ impl EdwardsPoint {
747747 ///
748748 /// Hash using the default domain separation tag and hash function
749749 pub fn hash_with_defaults ( msg : & [ u8 ] ) -> Self {
750- Self :: hash :: < ExpandMsgXof < sha3:: Shake256 , U84 > > ( msg, DEFAULT_HASH_TO_CURVE_SUITE )
750+ Self :: hash :: < ExpandMsgXof < sha3:: Shake256 > > ( msg, DEFAULT_HASH_TO_CURVE_SUITE )
751751 }
752752
753753 /// Hash a message to a point on the curve
@@ -756,7 +756,7 @@ impl EdwardsPoint {
756756 /// see <https://datatracker.ietf.org/doc/rfc9380/>
757757 pub fn hash < X > ( msg : & [ u8 ] , dst : & [ u8 ] ) -> Self
758758 where
759- X : for < ' a > ExpandMsg < ' a > ,
759+ X : ExpandMsg < U28 > ,
760760 {
761761 type RandomLen = U84 ;
762762 let mut random_bytes = Array :: < u8 , RandomLen > :: default ( ) ;
@@ -784,7 +784,7 @@ impl EdwardsPoint {
784784 ///
785785 /// Encode using the default domain separation tag and hash function
786786 pub fn encode_with_defaults ( msg : & [ u8 ] ) -> Self {
787- Self :: encode :: < ExpandMsgXof < sha3:: Shake256 , U84 > > ( msg, DEFAULT_ENCODE_TO_CURVE_SUITE )
787+ Self :: encode :: < ExpandMsgXof < sha3:: Shake256 > > ( msg, DEFAULT_ENCODE_TO_CURVE_SUITE )
788788 }
789789
790790 /// Encode a message to a point on the curve
@@ -793,7 +793,7 @@ impl EdwardsPoint {
793793 /// see <https://datatracker.ietf.org/doc/rfc9380/>
794794 pub fn encode < X > ( msg : & [ u8 ] , dst : & [ u8 ] ) -> Self
795795 where
796- X : for < ' a > ExpandMsg < ' a > ,
796+ X : ExpandMsg < U28 > ,
797797 {
798798 type RandomLen = U84 ;
799799 let mut random_bytes = Array :: < u8 , RandomLen > :: default ( ) ;
@@ -814,6 +814,21 @@ impl EdwardsPoint {
814814 }
815815}
816816
817+ impl From < NonIdentity < EdwardsPoint > > for EdwardsPoint {
818+ fn from ( p : NonIdentity < EdwardsPoint > ) -> Self {
819+ p. to_point ( )
820+ }
821+ }
822+
823+ /// The constant-time alternative is available at [`NonIdentity::new()`].
824+ impl TryFrom < EdwardsPoint > for NonIdentity < EdwardsPoint > {
825+ type Error = Error ;
826+
827+ fn try_from ( point : EdwardsPoint ) -> Result < Self , Error > {
828+ NonIdentity :: new ( point) . into_option ( ) . ok_or ( Error )
829+ }
830+ }
831+
817832// ------------------------------------------------------------------------
818833// Addition and Subtraction
819834// ------------------------------------------------------------------------
@@ -1188,7 +1203,7 @@ mod tests {
11881203 ] ;
11891204
11901205 for ( msg, x, y) in MSGS {
1191- let p = EdwardsPoint :: hash :: < ExpandMsgXof < sha3:: Shake256 , U84 > > ( msg, DST ) ;
1206+ let p = EdwardsPoint :: hash :: < ExpandMsgXof < sha3:: Shake256 > > ( msg, DST ) ;
11921207 assert_eq ! ( p. is_on_curve( ) . unwrap_u8( ) , 1u8 ) ;
11931208 let p = p. to_affine ( ) ;
11941209 let mut xx = [ 0u8 ; 56 ] ;
@@ -1225,7 +1240,7 @@ mod tests {
12251240 ] ;
12261241
12271242 for ( msg, x, y) in MSGS {
1228- let p = EdwardsPoint :: encode :: < ExpandMsgXof < sha3:: Shake256 , U84 > > ( msg, DST ) ;
1243+ let p = EdwardsPoint :: encode :: < ExpandMsgXof < sha3:: Shake256 > > ( msg, DST ) ;
12291244 assert_eq ! ( p. is_on_curve( ) . unwrap_u8( ) , 1u8 ) ;
12301245 let p = p. to_affine ( ) ;
12311246 let mut xx = [ 0u8 ; 56 ] ;
0 commit comments