diff --git a/CHANGELOG.md b/CHANGELOG.md index a561cc1..fe33e88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,10 +10,10 @@ and this project adheres to Rust's notion of - Migrated to `ff 0.13`, `group 0.13`. ### Removed -- `pasta_curves::arithmetic::SqrtRatio` (use `ff::Field::{sqrt_ratio, sqrt_alt}` - instead). -- `pasta_curves::arithmetic::SqrtTables` (from public API, as it isn't suitable - for generic usage). +- `pasta_curves::arithmetic`: + - `Group` + - `SqrtRatio` (use `ff::Field::{sqrt_ratio, sqrt_alt}` instead). + - `SqrtTables` (from public API, as it isn't suitable for generic usage). ## [0.4.1] - 2022-10-13 ### Added diff --git a/src/arithmetic.rs b/src/arithmetic.rs index 0de6600..39613a6 100644 --- a/src/arithmetic.rs +++ b/src/arithmetic.rs @@ -9,24 +9,3 @@ mod fields; pub use curves::*; pub use fields::*; - -/// This represents an element of a group with basic operations that can be -/// performed. This allows an FFT implementation (for example) to operate -/// generically over either a field or elliptic curve group. -pub trait Group: Copy + Clone + Send + Sync + 'static { - /// The group is assumed to be of prime order $p$. `Scalar` is the - /// associated scalar field of size $p$. - type Scalar: FieldExt; - - /// Returns the additive identity of the group. - fn group_zero() -> Self; - - /// Adds `rhs` to this group element. - fn group_add(&mut self, rhs: &Self); - - /// Subtracts `rhs` from this group element. - fn group_sub(&mut self, rhs: &Self); - - /// Scales this group element by a scalar. - fn group_scale(&mut self, by: &Self::Scalar); -} diff --git a/src/arithmetic/curves.rs b/src/arithmetic/curves.rs index 44eced6..f9b2ef4 100644 --- a/src/arithmetic/curves.rs +++ b/src/arithmetic/curves.rs @@ -7,7 +7,7 @@ use group::prime::{PrimeCurve, PrimeCurveAffine}; use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}; #[cfg(feature = "alloc")] -use super::{FieldExt, Group}; +use super::FieldExt; #[cfg(feature = "alloc")] use alloc::boxed::Box; @@ -28,7 +28,6 @@ pub trait CurveExt: + ConditionallySelectable + ConstantTimeEq + From<::Affine> - + Group::Scalar> { /// The scalar field of this elliptic curve. type ScalarExt: FieldExt; diff --git a/src/arithmetic/fields.rs b/src/arithmetic/fields.rs index 52ec2b8..e80d6b5 100644 --- a/src/arithmetic/fields.rs +++ b/src/arithmetic/fields.rs @@ -5,8 +5,6 @@ use core::mem::size_of; use static_assertions::const_assert; -use super::Group; - #[cfg(feature = "sqrt-table")] use alloc::{boxed::Box, vec::Vec}; #[cfg(feature = "sqrt-table")] @@ -32,7 +30,7 @@ pub(crate) trait SqrtTableHelpers: ff::PrimeField { /// This trait is a common interface for dealing with elements of a finite /// field. -pub trait FieldExt: ff::PrimeField + Ord + Group { +pub trait FieldExt: ff::PrimeField + Ord { /// Modulus of the field written as a string for display purposes const MODULUS: &'static str; diff --git a/src/curves.rs b/src/curves.rs index 52712f3..45ab4c1 100644 --- a/src/curves.rs +++ b/src/curves.rs @@ -19,7 +19,6 @@ use rand::RngCore; use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}; use super::{Fp, Fq}; -use crate::arithmetic::Group; #[cfg(feature = "alloc")] use crate::arithmetic::{Coordinates, CurveAffine, CurveExt, FieldExt}; @@ -783,23 +782,6 @@ macro_rules! new_curve_impl { impl_binops_multiplicative!($name, $scalar); impl_binops_multiplicative_mixed!($name_affine, $scalar, $name); - impl Group for $name { - type Scalar = $scalar; - - fn group_zero() -> Self { - Self::identity() - } - fn group_add(&mut self, rhs: &Self) { - *self += *rhs; - } - fn group_sub(&mut self, rhs: &Self) { - *self -= *rhs; - } - fn group_scale(&mut self, by: &Self::Scalar) { - *self *= *by; - } - } - #[cfg(feature = "gpu")] impl ec_gpu::GpuName for $name_affine { fn name() -> alloc::string::String { diff --git a/src/fields/fp.rs b/src/fields/fp.rs index b505c99..dbc0317 100644 --- a/src/fields/fp.rs +++ b/src/fields/fp.rs @@ -11,7 +11,7 @@ use lazy_static::lazy_static; #[cfg(feature = "bits")] use ff::{FieldBits, PrimeFieldBits}; -use crate::arithmetic::{adc, mac, sbb, FieldExt, Group, SqrtTableHelpers}; +use crate::arithmetic::{adc, mac, sbb, FieldExt, SqrtTableHelpers}; #[cfg(feature = "sqrt-table")] use crate::arithmetic::SqrtTables; @@ -475,23 +475,6 @@ impl<'a> From<&'a Fp> for [u8; 32] { } } -impl Group for Fp { - type Scalar = Fp; - - fn group_zero() -> Self { - Self::zero() - } - fn group_add(&mut self, rhs: &Self) { - *self += *rhs; - } - fn group_sub(&mut self, rhs: &Self) { - *self -= *rhs; - } - fn group_scale(&mut self, by: &Self::Scalar) { - *self *= *by; - } -} - impl ff::Field for Fp { const ZERO: Self = Self::zero(); const ONE: Self = Self::one(); diff --git a/src/fields/fq.rs b/src/fields/fq.rs index 8f70cb5..7a3495f 100644 --- a/src/fields/fq.rs +++ b/src/fields/fq.rs @@ -11,7 +11,7 @@ use lazy_static::lazy_static; #[cfg(feature = "bits")] use ff::{FieldBits, PrimeFieldBits}; -use crate::arithmetic::{adc, mac, sbb, FieldExt, Group, SqrtTableHelpers}; +use crate::arithmetic::{adc, mac, sbb, FieldExt, SqrtTableHelpers}; #[cfg(feature = "sqrt-table")] use crate::arithmetic::SqrtTables; @@ -475,23 +475,6 @@ impl<'a> From<&'a Fq> for [u8; 32] { } } -impl Group for Fq { - type Scalar = Fq; - - fn group_zero() -> Self { - Self::zero() - } - fn group_add(&mut self, rhs: &Self) { - *self += *rhs; - } - fn group_sub(&mut self, rhs: &Self) { - *self -= *rhs; - } - fn group_scale(&mut self, by: &Self::Scalar) { - *self *= *by; - } -} - impl ff::Field for Fq { const ZERO: Self = Self::zero(); const ONE: Self = Self::one();