@@ -2,19 +2,16 @@ use elliptic_curve::Field;
22use elliptic_curve:: array:: Array ;
33use elliptic_curve:: bigint:: { ArrayEncoding , U256 } ;
44use elliptic_curve:: consts:: { U4 , U16 , U48 } ;
5- use elliptic_curve:: group:: cofactor:: CofactorGroup ;
65use elliptic_curve:: hash2curve:: {
76 FromOkm , GroupDigest , Isogeny , IsogenyCoefficients , MapToCurve , OsswuMap , OsswuMapParams , Sgn0 ,
87} ;
9- use elliptic_curve:: subtle:: { Choice , ConditionallySelectable , ConstantTimeEq , CtOption } ;
8+ use elliptic_curve:: subtle:: { Choice , ConditionallySelectable , ConstantTimeEq } ;
109
1110use crate :: { AffinePoint , ProjectivePoint , Scalar , Secp256k1 } ;
1211
1312use super :: FieldElement ;
1413
1514impl GroupDigest for Secp256k1 {
16- type FieldElement = FieldElement ;
17-
1815 type K = U16 ;
1916}
2017
@@ -130,11 +127,12 @@ impl OsswuMap for FieldElement {
130127 }
131128}
132129
133- impl MapToCurve for FieldElement {
134- type Output = ProjectivePoint ;
130+ impl MapToCurve for Secp256k1 {
131+ type CurvePoint = ProjectivePoint ;
132+ type FieldElement = FieldElement ;
135133
136- fn map_to_curve ( & self ) -> Self :: Output {
137- let ( rx, ry) = self . osswu ( ) ;
134+ fn map_to_curve ( element : FieldElement ) -> Self :: CurvePoint {
135+ let ( rx, ry) = element . osswu ( ) ;
138136 let ( qx, qy) = FieldElement :: isogeny ( rx, ry) ;
139137
140138 AffinePoint {
@@ -144,6 +142,10 @@ impl MapToCurve for FieldElement {
144142 }
145143 . into ( )
146144 }
145+
146+ fn map_to_subgroup ( point : Self :: CurvePoint ) -> ProjectivePoint {
147+ point
148+ }
147149}
148150
149151impl FromOkm for Scalar {
@@ -258,31 +260,14 @@ impl Isogeny for FieldElement {
258260 } ;
259261}
260262
261- impl CofactorGroup for ProjectivePoint {
262- type Subgroup = ProjectivePoint ;
263-
264- fn clear_cofactor ( & self ) -> Self :: Subgroup {
265- * self
266- }
267-
268- fn into_subgroup ( self ) -> CtOption < Self :: Subgroup > {
269- CtOption :: new ( self , 1 . into ( ) )
270- }
271-
272- fn is_torsion_free ( & self ) -> Choice {
273- 1 . into ( )
274- }
275- }
276-
277263#[ cfg( test) ]
278264mod tests {
279- use crate :: { FieldElement , Scalar , Secp256k1 , U256 } ;
265+ use crate :: { Scalar , Secp256k1 , U256 , arithmetic :: field :: FieldElement } ;
280266 use elliptic_curve:: {
281267 Curve ,
282268 array:: Array ,
283269 bigint:: { ArrayEncoding , NonZero , U384 } ,
284270 consts:: U48 ,
285- group:: cofactor:: CofactorGroup ,
286271 hash2curve:: { FromOkm , GroupDigest , MapToCurve } ,
287272 } ;
288273 use hex_literal:: hex;
@@ -377,17 +362,17 @@ mod tests {
377362 assert_eq ! ( u[ 0 ] . to_bytes( ) . as_slice( ) , test_vector. u_0) ;
378363 assert_eq ! ( u[ 1 ] . to_bytes( ) . as_slice( ) , test_vector. u_1) ;
379364
380- let q0 = u[ 0 ] . map_to_curve ( ) ;
365+ let q0 = Secp256k1 :: map_to_curve ( u[ 0 ] ) ;
381366 let aq0 = q0. to_affine ( ) ;
382367 assert_eq ! ( aq0. x. to_bytes( ) . as_slice( ) , test_vector. q0_x) ;
383368 assert_eq ! ( aq0. y. to_bytes( ) . as_slice( ) , test_vector. q0_y) ;
384369
385- let q1 = u[ 1 ] . map_to_curve ( ) ;
370+ let q1 = Secp256k1 :: map_to_curve ( u[ 1 ] ) ;
386371 let aq1 = q1. to_affine ( ) ;
387372 assert_eq ! ( aq1. x. to_bytes( ) . as_slice( ) , test_vector. q1_x) ;
388373 assert_eq ! ( aq1. y. to_bytes( ) . as_slice( ) , test_vector. q1_y) ;
389374
390- let p = q0 . clear_cofactor ( ) + q1 . clear_cofactor ( ) ;
375+ let p = Secp256k1 :: add_and_map_to_subgroup ( q0 , q1 ) ;
391376 let ap = p. to_affine ( ) ;
392377 assert_eq ! ( ap. x. to_bytes( ) . as_slice( ) , test_vector. p_x) ;
393378 assert_eq ! ( ap. y. to_bytes( ) . as_slice( ) , test_vector. p_y) ;
0 commit comments