@@ -258,13 +258,24 @@ where
258258
259259impl < C > Group for ProjectivePoint < C >
260260where
261- Self : Double ,
261+ Self : GroupEncoding ,
262262 C : PrimeCurveParams ,
263263{
264264 type Scalar = Scalar < C > ;
265265
266266 fn try_from_rng < R : TryRngCore + ?Sized > ( rng : & mut R ) -> core:: result:: Result < Self , R :: Error > {
267- Ok ( Self :: GENERATOR * <Scalar < C > as Field >:: try_from_rng ( rng) ?)
267+ let mut bytes = <Self as GroupEncoding >:: Repr :: default ( ) ;
268+
269+ loop {
270+ rng. try_fill_bytes ( bytes. as_mut ( ) ) ?;
271+
272+ // Ensure SEC1 tag is 0x02 or 0x03 (compressed w\ even vs odd y-coordinate respectively)
273+ bytes. as_mut ( ) [ 0 ] = ( bytes. as_mut ( ) [ 0 ] & 1 ) | 2 ;
274+
275+ if let Some ( point) = Self :: from_bytes ( & bytes) . into ( ) {
276+ return Ok ( point) ;
277+ }
278+ }
268279 }
269280
270281 fn identity ( ) -> Self {
@@ -311,7 +322,7 @@ where
311322
312323impl < C > CurveGroup for ProjectivePoint < C >
313324where
314- Self : Double ,
325+ Self : GroupEncoding ,
315326 C : PrimeCurveParams ,
316327{
317328 type AffineRepr = AffinePoint < C > ;
@@ -331,7 +342,7 @@ where
331342
332343impl < const N : usize , C > BatchNormalize < [ ProjectivePoint < C > ; N ] > for ProjectivePoint < C >
333344where
334- Self : Double ,
345+ Self : GroupEncoding ,
335346 C : PrimeCurveParams ,
336347{
337348 type Output = [ <Self as CurveGroup >:: AffineRepr ; N ] ;
@@ -348,7 +359,7 @@ where
348359#[ cfg( feature = "alloc" ) ]
349360impl < C > BatchNormalize < [ ProjectivePoint < C > ] > for ProjectivePoint < C >
350361where
351- Self : Double ,
362+ Self : GroupEncoding ,
352363 C : PrimeCurveParams ,
353364{
354365 type Output = Vec < <Self as CurveGroup >:: AffineRepr > ;
@@ -400,15 +411,15 @@ where
400411
401412impl < C > LinearCombination < [ ( Self , Scalar < C > ) ] > for ProjectivePoint < C >
402413where
403- Self : Double ,
414+ Self : GroupEncoding ,
404415 C : PrimeCurveParams ,
405416{
406417 // TODO(tarcieri): optimized implementation
407418}
408419
409420impl < C , const N : usize > LinearCombination < [ ( Self , Scalar < C > ) ; N ] > for ProjectivePoint < C >
410421where
411- Self : Double ,
422+ Self : GroupEncoding ,
412423 C : PrimeCurveParams ,
413424{
414425 // TODO(tarcieri): optimized implementation
0 commit comments