Skip to content

Commit 87f34c2

Browse files
authored
Use elliptic_curve::CurveGroup (#1262)
1 parent 90a6987 commit 87f34c2

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

ed448-goldilocks/src/curve/edwards/extended.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use crate::curve::twedwards::extended::ExtendedPoint as TwistedExtendedPoint;
1111
use crate::field::{FieldElement, Scalar};
1212
use crate::*;
1313
use elliptic_curve::{
14-
Error,
14+
CurveGroup, Error,
1515
array::{Array, typenum::Unsigned},
1616
consts::{U28, U84},
17-
group::{Curve, Group, GroupEncoding, cofactor::CofactorGroup, prime::PrimeGroup},
17+
group::{Group, GroupEncoding, cofactor::CofactorGroup, prime::PrimeGroup},
1818
hash2curve::{ExpandMsg, ExpandMsgXof, Expander, FromOkm},
1919
ops::LinearCombination,
2020
point::NonIdentity,
@@ -512,7 +512,7 @@ impl<const N: usize> LinearCombination<[(EdwardsPoint, Scalar); N]> for EdwardsP
512512

513513
impl LinearCombination<[(EdwardsPoint, Scalar)]> for EdwardsPoint {}
514514

515-
impl Curve for EdwardsPoint {
515+
impl CurveGroup for EdwardsPoint {
516516
type AffineRepr = AffinePoint;
517517

518518
fn to_affine(&self) -> AffinePoint {

ed448-goldilocks/src/decaf/ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::{
44
iter::Sum,
55
ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign},
66
};
7-
use elliptic_curve::group::Curve;
7+
use elliptic_curve::CurveGroup;
88

99
use super::DecafPoint;
1010

ed448-goldilocks/src/decaf/points.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use crate::field::FieldElement;
44
use crate::*;
55

66
use elliptic_curve::{
7-
Error, Group,
7+
CurveGroup, Error, Group,
88
array::{Array, typenum::Unsigned},
99
consts::{U32, U56, U84},
10-
group::{Curve, GroupEncoding, cofactor::CofactorGroup, prime::PrimeGroup},
10+
group::{GroupEncoding, cofactor::CofactorGroup, prime::PrimeGroup},
1111
hash2curve::{ExpandMsg, Expander, FromOkm},
1212
ops::LinearCombination,
1313
point::NonIdentity,
@@ -237,7 +237,7 @@ impl<const N: usize> LinearCombination<[(DecafPoint, Scalar); N]> for DecafPoint
237237

238238
impl LinearCombination<[(DecafPoint, Scalar)]> for DecafPoint {}
239239

240-
impl Curve for DecafPoint {
240+
impl CurveGroup for DecafPoint {
241241
type AffineRepr = DecafAffinePoint;
242242

243243
fn to_affine(&self) -> Self::AffineRepr {

k256/src/arithmetic/projective.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use core::{
99
ops::{Add, AddAssign, Neg, Sub, SubAssign},
1010
};
1111
use elliptic_curve::{
12-
BatchNormalize, Error, Result,
12+
BatchNormalize, CurveGroup, Error, Result,
1313
group::{
14-
Curve, Group, GroupEncoding,
14+
Group, GroupEncoding,
1515
ff::Field,
1616
prime::{PrimeCurve, PrimeCurveAffine, PrimeGroup},
1717
},
@@ -257,10 +257,10 @@ impl From<AffinePoint> for ProjectivePoint {
257257
}
258258

259259
impl<const N: usize> BatchNormalize<[ProjectivePoint; N]> for ProjectivePoint {
260-
type Output = [<Self as Curve>::AffineRepr; N];
260+
type Output = [<Self as CurveGroup>::AffineRepr; N];
261261

262262
#[inline]
263-
fn batch_normalize(points: &[Self; N]) -> [<Self as Curve>::AffineRepr; N] {
263+
fn batch_normalize(points: &[Self; N]) -> [<Self as CurveGroup>::AffineRepr; N] {
264264
let zs = [FieldElement::ONE; N];
265265
let mut affine_points = [AffinePoint::IDENTITY; N];
266266
batch_normalize_generic(points, zs, &mut affine_points);
@@ -270,10 +270,10 @@ impl<const N: usize> BatchNormalize<[ProjectivePoint; N]> for ProjectivePoint {
270270

271271
#[cfg(feature = "alloc")]
272272
impl BatchNormalize<[ProjectivePoint]> for ProjectivePoint {
273-
type Output = Vec<<Self as Curve>::AffineRepr>;
273+
type Output = Vec<<Self as CurveGroup>::AffineRepr>;
274274

275275
#[inline]
276-
fn batch_normalize(points: &[Self]) -> Vec<<Self as Curve>::AffineRepr> {
276+
fn batch_normalize(points: &[Self]) -> Vec<<Self as CurveGroup>::AffineRepr> {
277277
let zs = vec![FieldElement::ONE; points.len()];
278278
let mut affine_points = vec![AffinePoint::IDENTITY; points.len()];
279279
batch_normalize_generic(points, zs, &mut affine_points);
@@ -454,7 +454,7 @@ impl GroupEncoding for ProjectivePoint {
454454

455455
impl PrimeGroup for ProjectivePoint {}
456456

457-
impl Curve for ProjectivePoint {
457+
impl CurveGroup for ProjectivePoint {
458458
type AffineRepr = AffinePoint;
459459

460460
fn to_affine(&self) -> AffinePoint {
@@ -698,9 +698,9 @@ mod tests {
698698
Scalar,
699699
test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS},
700700
};
701-
use elliptic_curve::Field;
701+
use elliptic_curve::BatchNormalize;
702702
use elliptic_curve::group::{ff::PrimeField, prime::PrimeCurveAffine};
703-
use elliptic_curve::{BatchNormalize, group};
703+
use elliptic_curve::{CurveGroup, Field};
704704
use rand_core::{OsRng, TryRngCore};
705705

706706
#[cfg(feature = "alloc")]
@@ -737,7 +737,7 @@ mod tests {
737737
expected
738738
);
739739

740-
<ProjectivePoint as group::Curve>::batch_normalize(&[g, h], &mut res);
740+
<ProjectivePoint as CurveGroup>::batch_normalize(&[g, h], &mut res);
741741
assert_eq!(res, expected);
742742

743743
let mut res = [AffinePoint::IDENTITY; 3];
@@ -753,7 +753,7 @@ mod tests {
753753
expected
754754
);
755755

756-
<ProjectivePoint as group::Curve>::batch_normalize(
756+
<ProjectivePoint as CurveGroup>::batch_normalize(
757757
&[g, ProjectivePoint::IDENTITY, non_normalized_identity],
758758
&mut res,
759759
);
@@ -774,7 +774,7 @@ mod tests {
774774
<ProjectivePoint as BatchNormalize<_>>::batch_normalize(scalars.as_slice());
775775
assert_eq!(res, expected);
776776

777-
<ProjectivePoint as group::Curve>::batch_normalize(&[g, h], res.as_mut());
777+
<ProjectivePoint as CurveGroup>::batch_normalize(&[g, h], res.as_mut());
778778
assert_eq!(res.to_vec(), expected);
779779

780780
let expected = vec![g.to_affine(), AffinePoint::IDENTITY];
@@ -783,7 +783,7 @@ mod tests {
783783

784784
assert_eq!(res, expected);
785785

786-
<ProjectivePoint as group::Curve>::batch_normalize(
786+
<ProjectivePoint as CurveGroup>::batch_normalize(
787787
&[g, ProjectivePoint::IDENTITY],
788788
res.as_mut(),
789789
);

primeorder/src/projective.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ use core::{
99
ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign},
1010
};
1111
use elliptic_curve::{
12-
BatchNormalize, Error, FieldBytes, FieldBytesSize, PrimeField, PublicKey, Result, Scalar,
12+
BatchNormalize, CurveGroup, Error, FieldBytes, FieldBytesSize, PrimeField, PublicKey, Result,
13+
Scalar,
1314
array::ArraySize,
1415
bigint::ArrayEncoding,
1516
group::{
16-
Curve, Group, GroupEncoding,
17+
Group, GroupEncoding,
1718
prime::{PrimeCurve, PrimeGroup},
1819
},
1920
ops::{BatchInvert, LinearCombination},
@@ -308,7 +309,7 @@ where
308309
}
309310
}
310311

311-
impl<C> Curve for ProjectivePoint<C>
312+
impl<C> CurveGroup for ProjectivePoint<C>
312313
where
313314
Self: Double,
314315
C: PrimeCurveParams,
@@ -333,10 +334,10 @@ where
333334
Self: Double,
334335
C: PrimeCurveParams,
335336
{
336-
type Output = [<Self as Curve>::AffineRepr; N];
337+
type Output = [<Self as CurveGroup>::AffineRepr; N];
337338

338339
#[inline]
339-
fn batch_normalize(points: &[Self; N]) -> [<Self as Curve>::AffineRepr; N] {
340+
fn batch_normalize(points: &[Self; N]) -> [<Self as CurveGroup>::AffineRepr; N] {
340341
let zs = [C::FieldElement::ONE; N];
341342
let mut affine_points = [C::AffinePoint::IDENTITY; N];
342343
batch_normalize_generic(points, zs, &mut affine_points);
@@ -350,10 +351,10 @@ where
350351
Self: Double,
351352
C: PrimeCurveParams,
352353
{
353-
type Output = Vec<<Self as Curve>::AffineRepr>;
354+
type Output = Vec<<Self as CurveGroup>::AffineRepr>;
354355

355356
#[inline]
356-
fn batch_normalize(points: &[Self]) -> Vec<<Self as Curve>::AffineRepr> {
357+
fn batch_normalize(points: &[Self]) -> Vec<<Self as CurveGroup>::AffineRepr> {
357358
let mut zs = vec![C::FieldElement::ONE; points.len()];
358359
let mut affine_points = vec![AffinePoint::IDENTITY; points.len()];
359360
batch_normalize_generic(points, zs.as_mut_slice(), &mut affine_points);

0 commit comments

Comments
 (0)