diff --git a/CHANGELOG.md b/CHANGELOG.md index 529953b5b..3b4d22f0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Breaking changes +- [\#593](https://github.com/arkworks-rs/algebra/pull/593) (`ark-ec`) Change `AffineRepr::xy()` to return owned values. + ### Features ### Improvements diff --git a/README.md b/README.md index e62ca3593..a507f3517 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This repository contains several Rust crates: * [`ark-poly`](poly): Interfaces for univariate, multivariate, and multilinear polynomials, and FFTs over finite fields * [`ark-serialize`](serialize): Efficient interfaces for serialization and point compression for finite fields and elliptic curves -In addition, the [`curves`](https://github.com/arkworks-rs/curves) repository contains concrete implementations of popular elliptic curves; see [here](https://github.com/arkworks-rs/curves/README.md) for details. +In addition, the [`curves`](https://github.com/arkworks-rs/curves) repository contains concrete implementations of popular elliptic curves; see [here](https://github.com/arkworks-rs/curves/blob/master/README.md) for details. ## Build guide diff --git a/bench-templates/src/macros/ec.rs b/bench-templates/src/macros/ec.rs index d561fcfc9..5cb7380c6 100644 --- a/bench-templates/src/macros/ec.rs +++ b/bench-templates/src/macros/ec.rs @@ -214,8 +214,10 @@ macro_rules! ec_bench { let name = format!("{}::{}", $curve_name, stringify!($Group)); let mut rng = ark_std::test_rng(); - let g = <$Group>::rand(&mut rng).into_affine(); - let v: Vec<_> = (0..SAMPLES).map(|_| g).collect(); + let v: Vec<_> = (0..SAMPLES) + .map(|_| <$Group>::rand(&mut rng)) + .collect(); + let v = <$Group>::normalize_batch(&v); let scalars: Vec<_> = (0..SAMPLES) .map(|_| Scalar::rand(&mut rng).into_bigint()) .collect(); diff --git a/ec/README.md b/ec/README.md index eec8bcfd1..f80871a95 100644 --- a/ec/README.md +++ b/ec/README.md @@ -7,7 +7,7 @@
`ark-ec` defines traits and algorithms for working with different kinds of additive groups, with a focus on groups arising from elliptic curves. It further provides concrete instantiations of these traits for various elliptic curve models, including popular families of pairing-friendly curves such as the BLS12 family of curves. -Implementations of particular curves using these curve models can be found in [`arkworks-rs/curves`](https://github.com/arkworks-rs/curves/README.md). +Implementations of particular curves using these curve models can be found in [`arkworks-rs/curves`](https://github.com/arkworks-rs/curves/blob/master/README.md). ## Usage diff --git a/ec/src/hashing/curve_maps/wb/mod.rs b/ec/src/hashing/curve_maps/wb/mod.rs index 4e2644009..10ddbb0f7 100644 --- a/ec/src/hashing/curve_maps/wb/mod.rs +++ b/ec/src/hashing/curve_maps/wb/mod.rs @@ -53,10 +53,10 @@ where let y_num = DensePolynomial::from_coefficients_slice(self.y_map_numerator); let y_den = DensePolynomial::from_coefficients_slice(self.y_map_denominator); - let mut v: [BaseField= Projective<
::G2Config>;
Eq(bound = "P: Bls12Config")
)]
pub struct G2Prepared {
ell_coeffs: vec![],
infinity: true,
};
- q.xy().map_or(zero, |(&q_x, &q_y)| {
+ q.xy().map_or(zero, |(q_x, q_y)| {
let mut ell_coeffs = vec![];
let mut r = G2HomProjective:: {
x: q_x,
@@ -133,7 +133,7 @@ impl {
}
fn add_in_place(&mut self, q: &G2Affine ) -> EllCoeff {
- let (&qx, &qy) = q.xy().unwrap();
+ let (qx, qy) = q.xy().unwrap();
// Formula for line function when working with
// homogeneous projective coordinates.
let theta = self.y - &(qy * &self.z);
diff --git a/ec/src/models/bls12/mod.rs b/ec/src/models/bls12/mod.rs
index ca8a66351..f5275f697 100644
--- a/ec/src/models/bls12/mod.rs
+++ b/ec/src/models/bls12/mod.rs
@@ -178,13 +178,13 @@ impl {
match P::TWIST_TYPE {
TwistType::M => {
- c2.mul_assign_by_fp(py);
- c1.mul_assign_by_fp(px);
+ c2.mul_assign_by_fp(&py);
+ c1.mul_assign_by_fp(&px);
f.mul_by_014(&c0, &c1, &c2);
},
TwistType::D => {
- c0.mul_assign_by_fp(py);
- c1.mul_assign_by_fp(px);
+ c0.mul_assign_by_fp(&py);
+ c1.mul_assign_by_fp(&px);
f.mul_by_034(&c0, &c1, &c2);
},
}
diff --git a/ec/src/models/bn/g2.rs b/ec/src/models/bn/g2.rs
index 231b74402..434624520 100644
--- a/ec/src/models/bn/g2.rs
+++ b/ec/src/models/bn/g2.rs
@@ -21,8 +21,8 @@ pub type G2Projective = Projective< ::G2Config>;
Eq(bound = "P: BnConfig")
)]
pub struct G2Prepared = Projective< ::G2Config>;
Eq(bound = "P: BW6Config")
)]
pub struct G2Prepared {
impl {
fn double_in_place(&mut self) -> (P::Fp, P::Fp, P::Fp) {
// Formula for line function when working with
- // homogeneous projective coordinates, as described in https://eprint.iacr.org/2013/722.pdf.
+ // homogeneous projective coordinates, as described in
+ // {
type ScalarField = P::ScalarField;
type Group = Projective ;
- fn xy(&self) -> Option<(&Self::BaseField, &Self::BaseField)> {
- (!self.infinity).then(|| (&self.x, &self.y))
+ fn xy(&self) -> Option<(Self::BaseField, Self::BaseField)> {
+ (!self.infinity).then(|| (self.x, self.y))
}
#[inline]
diff --git a/ec/src/models/short_weierstrass/group.rs b/ec/src/models/short_weierstrass/group.rs
index ad043f892..d94e20cba 100644
--- a/ec/src/models/short_weierstrass/group.rs
+++ b/ec/src/models/short_weierstrass/group.rs
@@ -330,10 +330,10 @@ impl {
}
impl {
- /// Using http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-madd-2007-bl
+ /// Using {
impl {
#[inline]
fn from(p: Affine ) -> Projective {
- p.xy().map_or(Projective::zero(), |(&x, &y)| Self {
+ p.xy().map_or(Projective::zero(), |(x, y)| Self {
x,
y,
z: P::BaseField::one(),
diff --git a/ec/src/models/twisted_edwards/affine.rs b/ec/src/models/twisted_edwards/affine.rs
index a6c908e31..4bf186721 100644
--- a/ec/src/models/twisted_edwards/affine.rs
+++ b/ec/src/models/twisted_edwards/affine.rs
@@ -166,8 +166,8 @@ impl {
type ScalarField = P::ScalarField;
type Group = Projective ;
- fn xy(&self) -> Option<(&Self::BaseField, &Self::BaseField)> {
- (!self.is_zero()).then(|| (&self.x, &self.y))
+ fn xy(&self) -> Option<(Self::BaseField, Self::BaseField)> {
+ (!self.is_zero()).then(|| (self.x, self.y))
}
fn generator() -> Self {
diff --git a/ff-macros/src/lib.rs b/ff-macros/src/lib.rs
index d642d1a79..9d90d5840 100644
--- a/ff-macros/src/lib.rs
+++ b/ff-macros/src/lib.rs
@@ -131,6 +131,47 @@ fn fetch_attr(name: &str, attrs: &[syn::Attribute]) -> Option