Skip to content

Use elliptic_curve::CurveGroup #1262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ed448-goldilocks/src/curve/edwards/extended.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use crate::curve::twedwards::extended::ExtendedPoint as TwistedExtendedPoint;
use crate::field::{FieldElement, Scalar};
use crate::*;
use elliptic_curve::{
Error,
CurveGroup, Error,
array::{Array, typenum::Unsigned},
consts::{U28, U84},
group::{Curve, Group, GroupEncoding, cofactor::CofactorGroup, prime::PrimeGroup},
group::{Group, GroupEncoding, cofactor::CofactorGroup, prime::PrimeGroup},
hash2curve::{ExpandMsg, ExpandMsgXof, Expander, FromOkm},
ops::LinearCombination,
point::NonIdentity,
Expand Down Expand Up @@ -512,7 +512,7 @@ impl<const N: usize> LinearCombination<[(EdwardsPoint, Scalar); N]> for EdwardsP

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

impl Curve for EdwardsPoint {
impl CurveGroup for EdwardsPoint {
type AffineRepr = AffinePoint;

fn to_affine(&self) -> AffinePoint {
Expand Down
2 changes: 1 addition & 1 deletion ed448-goldilocks/src/decaf/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::{
iter::Sum,
ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign},
};
use elliptic_curve::group::Curve;
use elliptic_curve::CurveGroup;

use super::DecafPoint;

Expand Down
6 changes: 3 additions & 3 deletions ed448-goldilocks/src/decaf/points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use crate::field::FieldElement;
use crate::*;

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

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

impl Curve for DecafPoint {
impl CurveGroup for DecafPoint {
type AffineRepr = DecafAffinePoint;

fn to_affine(&self) -> Self::AffineRepr {
Expand Down
26 changes: 13 additions & 13 deletions k256/src/arithmetic/projective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use core::{
ops::{Add, AddAssign, Neg, Sub, SubAssign},
};
use elliptic_curve::{
BatchNormalize, Error, Result,
BatchNormalize, CurveGroup, Error, Result,
group::{
Curve, Group, GroupEncoding,
Group, GroupEncoding,
ff::Field,
prime::{PrimeCurve, PrimeCurveAffine, PrimeGroup},
},
Expand Down Expand Up @@ -257,10 +257,10 @@ impl From<AffinePoint> for ProjectivePoint {
}

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

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

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

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

impl PrimeGroup for ProjectivePoint {}

impl Curve for ProjectivePoint {
impl CurveGroup for ProjectivePoint {
type AffineRepr = AffinePoint;

fn to_affine(&self) -> AffinePoint {
Expand Down Expand Up @@ -698,9 +698,9 @@ mod tests {
Scalar,
test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS},
};
use elliptic_curve::Field;
use elliptic_curve::BatchNormalize;
use elliptic_curve::group::{ff::PrimeField, prime::PrimeCurveAffine};
use elliptic_curve::{BatchNormalize, group};
use elliptic_curve::{CurveGroup, Field};
use rand_core::{OsRng, TryRngCore};

#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -737,7 +737,7 @@ mod tests {
expected
);

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

let mut res = [AffinePoint::IDENTITY; 3];
Expand All @@ -753,7 +753,7 @@ mod tests {
expected
);

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

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

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

assert_eq!(res, expected);

<ProjectivePoint as group::Curve>::batch_normalize(
<ProjectivePoint as CurveGroup>::batch_normalize(
&[g, ProjectivePoint::IDENTITY],
res.as_mut(),
);
Expand Down
15 changes: 8 additions & 7 deletions primeorder/src/projective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ use core::{
ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign},
};
use elliptic_curve::{
BatchNormalize, Error, FieldBytes, FieldBytesSize, PrimeField, PublicKey, Result, Scalar,
BatchNormalize, CurveGroup, Error, FieldBytes, FieldBytesSize, PrimeField, PublicKey, Result,
Scalar,
array::ArraySize,
bigint::ArrayEncoding,
group::{
Curve, Group, GroupEncoding,
Group, GroupEncoding,
prime::{PrimeCurve, PrimeGroup},
},
ops::{BatchInvert, LinearCombination},
Expand Down Expand Up @@ -308,7 +309,7 @@ where
}
}

impl<C> Curve for ProjectivePoint<C>
impl<C> CurveGroup for ProjectivePoint<C>
where
Self: Double,
C: PrimeCurveParams,
Expand All @@ -333,10 +334,10 @@ where
Self: Double,
C: PrimeCurveParams,
{
type Output = [<Self as Curve>::AffineRepr; N];
type Output = [<Self as CurveGroup>::AffineRepr; N];

#[inline]
fn batch_normalize(points: &[Self; N]) -> [<Self as Curve>::AffineRepr; N] {
fn batch_normalize(points: &[Self; N]) -> [<Self as CurveGroup>::AffineRepr; N] {
let zs = [C::FieldElement::ONE; N];
let mut affine_points = [C::AffinePoint::IDENTITY; N];
batch_normalize_generic(points, zs, &mut affine_points);
Expand All @@ -350,10 +351,10 @@ where
Self: Double,
C: PrimeCurveParams,
{
type Output = Vec<<Self as Curve>::AffineRepr>;
type Output = Vec<<Self as CurveGroup>::AffineRepr>;

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