mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-05 20:10:32 +00:00
Remove crate::arithmetic::Group trait
It was only present to enable an FFT implementation in `halo2_proofs` that is generic over fields and groups, but we can replace it with an equivalent trait in `halo2_proofs` that can have a blanket impl.
This commit is contained in:
parent
4c86de5e10
commit
fbce21598d
7 changed files with 8 additions and 84 deletions
|
|
@ -10,10 +10,10 @@ and this project adheres to Rust's notion of
|
||||||
- Migrated to `ff 0.13`, `group 0.13`.
|
- Migrated to `ff 0.13`, `group 0.13`.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- `pasta_curves::arithmetic::SqrtRatio` (use `ff::Field::{sqrt_ratio, sqrt_alt}`
|
- `pasta_curves::arithmetic`:
|
||||||
instead).
|
- `Group`
|
||||||
- `pasta_curves::arithmetic::SqrtTables` (from public API, as it isn't suitable
|
- `SqrtRatio` (use `ff::Field::{sqrt_ratio, sqrt_alt}` instead).
|
||||||
for generic usage).
|
- `SqrtTables` (from public API, as it isn't suitable for generic usage).
|
||||||
|
|
||||||
## [0.4.1] - 2022-10-13
|
## [0.4.1] - 2022-10-13
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -9,24 +9,3 @@ mod fields;
|
||||||
|
|
||||||
pub use curves::*;
|
pub use curves::*;
|
||||||
pub use fields::*;
|
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);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use group::prime::{PrimeCurve, PrimeCurveAffine};
|
||||||
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
|
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
use super::{FieldExt, Group};
|
use super::FieldExt;
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
|
|
@ -28,7 +28,6 @@ pub trait CurveExt:
|
||||||
+ ConditionallySelectable
|
+ ConditionallySelectable
|
||||||
+ ConstantTimeEq
|
+ ConstantTimeEq
|
||||||
+ From<<Self as PrimeCurve>::Affine>
|
+ From<<Self as PrimeCurve>::Affine>
|
||||||
+ Group<Scalar = <Self as group::Group>::Scalar>
|
|
||||||
{
|
{
|
||||||
/// The scalar field of this elliptic curve.
|
/// The scalar field of this elliptic curve.
|
||||||
type ScalarExt: FieldExt;
|
type ScalarExt: FieldExt;
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ use core::mem::size_of;
|
||||||
|
|
||||||
use static_assertions::const_assert;
|
use static_assertions::const_assert;
|
||||||
|
|
||||||
use super::Group;
|
|
||||||
|
|
||||||
#[cfg(feature = "sqrt-table")]
|
#[cfg(feature = "sqrt-table")]
|
||||||
use alloc::{boxed::Box, vec::Vec};
|
use alloc::{boxed::Box, vec::Vec};
|
||||||
#[cfg(feature = "sqrt-table")]
|
#[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
|
/// This trait is a common interface for dealing with elements of a finite
|
||||||
/// field.
|
/// field.
|
||||||
pub trait FieldExt: ff::PrimeField + Ord + Group<Scalar = Self> {
|
pub trait FieldExt: ff::PrimeField + Ord {
|
||||||
/// Modulus of the field written as a string for display purposes
|
/// Modulus of the field written as a string for display purposes
|
||||||
const MODULUS: &'static str;
|
const MODULUS: &'static str;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ use rand::RngCore;
|
||||||
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
|
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
|
||||||
|
|
||||||
use super::{Fp, Fq};
|
use super::{Fp, Fq};
|
||||||
use crate::arithmetic::Group;
|
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
use crate::arithmetic::{Coordinates, CurveAffine, CurveExt, FieldExt};
|
use crate::arithmetic::{Coordinates, CurveAffine, CurveExt, FieldExt};
|
||||||
|
|
@ -783,23 +782,6 @@ macro_rules! new_curve_impl {
|
||||||
impl_binops_multiplicative!($name, $scalar);
|
impl_binops_multiplicative!($name, $scalar);
|
||||||
impl_binops_multiplicative_mixed!($name_affine, $scalar, $name);
|
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")]
|
#[cfg(feature = "gpu")]
|
||||||
impl ec_gpu::GpuName for $name_affine {
|
impl ec_gpu::GpuName for $name_affine {
|
||||||
fn name() -> alloc::string::String {
|
fn name() -> alloc::string::String {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use lazy_static::lazy_static;
|
||||||
#[cfg(feature = "bits")]
|
#[cfg(feature = "bits")]
|
||||||
use ff::{FieldBits, PrimeFieldBits};
|
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")]
|
#[cfg(feature = "sqrt-table")]
|
||||||
use crate::arithmetic::SqrtTables;
|
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 {
|
impl ff::Field for Fp {
|
||||||
const ZERO: Self = Self::zero();
|
const ZERO: Self = Self::zero();
|
||||||
const ONE: Self = Self::one();
|
const ONE: Self = Self::one();
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use lazy_static::lazy_static;
|
||||||
#[cfg(feature = "bits")]
|
#[cfg(feature = "bits")]
|
||||||
use ff::{FieldBits, PrimeFieldBits};
|
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")]
|
#[cfg(feature = "sqrt-table")]
|
||||||
use crate::arithmetic::SqrtTables;
|
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 {
|
impl ff::Field for Fq {
|
||||||
const ZERO: Self = Self::zero();
|
const ZERO: Self = Self::zero();
|
||||||
const ONE: Self = Self::one();
|
const ONE: Self = Self::one();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue