arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
Sync with the recent changes in ark-algebra on pairing and testing (#116)

* Fix another typo in the Jubjub curve comment

* fix

* progress

* get_point_from_x_unchecked

* fix

* soft link

* Fix Bandersnatch

* Fix Edwards form of Bandersnatch

* Actually fix ed_on_bls12_381_bandersnatch/src/curves/mod.rs

* fix

* fix

* curve-benches

* fix the last mul_by_a; fmt

Co-authored-by: onewayfunc <onewayfunc@gmail.com>
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
Weikeng Chen w.k@berkeley.edu
Fri, 02 Sep 2022 16:31:58 -0700
commit

3c4c67f114e77f496267bcc474caeb137880e46d

parent

42289245a6d59606f7f34bb6506b064d8ca028f5

113 files changed, 312 insertions(+), 1074 deletions(-)

jump to
M Cargo.toml → Cargo.toml

@@ -62,6 +62,7 @@ [patch.crates-io]

ark-ec = { git = "https://github.com/arkworks-rs/algebra" } ark-ff = { git = "https://github.com/arkworks-rs/algebra" } ark-serialize = { git = "https://github.com/arkworks-rs/algebra" } +ark-algebra-bench-templates = { git = "https://github.com/arkworks-rs/algebra" } ark-algebra-test-templates = { git = "https://github.com/arkworks-rs/algebra" } ark-r1cs-std = { git = "https://github.com/arkworks-rs/r1cs-std" } -ark-std = { git = "https://github.com/arkworks-rs/std" } +ark-std = { git = "https://github.com/arkworks-rs/std" }
M bls12_377/Cargo.toml → bls12_377/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version="^0.3.0", default-features = false }
M bls12_377/src/curves/g1.rs → bls12_377/src/curves/g1.rs

@@ -36,7 +36,7 @@ /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)

const GENERATOR: G1SWAffine = G1SWAffine::new_unchecked(G1_GENERATOR_X, G1_GENERATOR_Y); #[inline(always)] - fn mul_by_a(_: &Self::BaseField) -> Self::BaseField { + fn mul_by_a(_: Self::BaseField) -> Self::BaseField { Self::BaseField::zero() } }

@@ -106,7 +106,7 @@ type MontCurveConfig = Parameters;

/// Multiplication by `a` is multiply by `-1`. #[inline(always)] - fn mul_by_a(elem: &Self::BaseField) -> Self::BaseField { + fn mul_by_a(elem: Self::BaseField) -> Self::BaseField { elem.neg() } }
M bls12_377/src/curves/g2.rs → bls12_377/src/curves/g2.rs

@@ -53,7 +53,7 @@ /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)

const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y); #[inline(always)] - fn mul_by_a(_: &Self::BaseField) -> Self::BaseField { + fn mul_by_a(_: Self::BaseField) -> Self::BaseField { Self::BaseField::zero() } }
M bls12_377/src/curves/tests.rs → bls12_377/src/curves/tests.rs

@@ -3,7 +3,7 @@ curves::{curve_tests, edwards_tests, sw_tests},

generate_bilinearity_test, generate_g1_generator_raw_test, generate_g1_test, generate_g2_test, msm::test_var_base_msm, }; -use ark_ec::{models::short_weierstrass::SWCurveConfig, AffineCurve, PairingEngine}; +use ark_ec::{models::short_weierstrass::SWCurveConfig, AffineRepr, PairingEngine}; use ark_ff::{ fields::{Field, PrimeField}, One, Zero,
M bls12_381/Cargo.toml → bls12_381/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version="^0.3.0", default-features = false }
M bls12_381/src/curves/g1.rs → bls12_381/src/curves/g1.rs

@@ -3,7 +3,7 @@ bls12,

bls12::Bls12Parameters, models::CurveConfig, short_weierstrass::{Affine, SWCurveConfig}, - AffineCurve, ProjectiveCurve, + AffineRepr, Group, }; use ark_ff::{Field, MontFp, Zero}; use ark_std::ops::Neg;

@@ -40,7 +40,7 @@ /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)

const GENERATOR: G1Affine = G1Affine::new_unchecked(G1_GENERATOR_X, G1_GENERATOR_Y); #[inline(always)] - fn mul_by_a(_: &Self::BaseField) -> Self::BaseField { + fn mul_by_a(_: Self::BaseField) -> Self::BaseField { Self::BaseField::zero() }
M bls12_381/src/curves/g2.rs → bls12_381/src/curves/g2.rs

@@ -3,7 +3,7 @@ bls12,

bls12::Bls12Parameters, models::CurveConfig, short_weierstrass::{Affine, SWCurveConfig}, - AffineCurve, + AffineRepr, }; use ark_ff::{Field, MontFp, Zero};

@@ -51,7 +51,7 @@ /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)

const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y); #[inline(always)] - fn mul_by_a(_: &Self::BaseField) -> Self::BaseField { + fn mul_by_a(_: Self::BaseField) -> Self::BaseField { Self::BaseField::zero() }
M bls12_381/src/curves/tests.rs → bls12_381/src/curves/tests.rs

@@ -1,27 +1,18 @@

-use ark_algebra_test_templates::{ - curves::*, generate_bilinearity_test, generate_g1_generator_raw_test, generate_g1_test, - generate_g2_test, msm::*, -}; -use ark_ec::{ - models::short_weierstrass::SWCurveConfig, AffineCurve, PairingEngine, ProjectiveCurve, -}; -use ark_ff::{ - fields::{Field, PrimeField}, - One, UniformRand, Zero, -}; +use ark_algebra_test_templates::*; +use ark_ec::{AffineRepr, CurveGroup}; +use ark_ff::{fields::Field, One, UniformRand, Zero}; use ark_std::{rand::Rng, test_rng}; -use core::ops::{AddAssign, MulAssign}; -use crate::{g1, g2, Bls12_381, Fq, Fq12, Fq2, Fr, G1Affine, G1Projective, G2Affine, G2Projective}; +use crate::{Bls12_381, Fq, Fq2, Fr, G1Affine, G1Projective, G2Affine, G2Projective}; -generate_g1_test!(bls12_381; curve_tests; sw_tests;); -generate_g2_test!(bls12_381; curve_tests; sw_tests;); -generate_bilinearity_test!(Bls12_381, Fq12); -generate_g1_generator_raw_test!(bls12_381, 4); +test_group!(g1; G1Projective; sw); +test_group!(g2; G2Projective; sw); +test_group!(pairing_output; ark_ec::pairing::PairingOutput<Bls12_381>; msm); +test_pairing!(pairing; crate::Bls12_381); #[test] fn test_g1_endomorphism_beta() { - assert!(g1::BETA.pow(&[3u64]).is_one()); + assert!(crate::g1::BETA.pow(&[3u64]).is_one()); } #[test]

@@ -38,12 +29,8 @@ loop {

let x = Fq::rand(&mut rng); let greatest = rng.gen(); - if let Some(p) = G1Affine::get_point_from_x(x, greatest) { - if !p - .into_projective() - .mul_bigint(Fr::characteristic()) - .is_zero() - { + if let Some(p) = G1Affine::get_point_from_x_unchecked(x, greatest) { + if !p.mul_bigint(Fr::characteristic()).is_zero() { assert!(!p.is_in_correct_subgroup_assuming_on_curve()); return; }

@@ -65,12 +52,8 @@ loop {

let x = Fq2::rand(&mut rng); let greatest = rng.gen(); - if let Some(p) = G2Affine::get_point_from_x(x, greatest) { - if !p - .into_projective() - .mul_bigint(Fr::characteristic()) - .is_zero() - { + if let Some(p) = G2Affine::get_point_from_x_unchecked(x, greatest) { + if !p.mul_bigint(Fr::characteristic()).is_zero() { assert!(!p.is_in_correct_subgroup_assuming_on_curve()); return; }
M bls12_381/src/fields/tests.rs → bls12_381/src/fields/tests.rs

@@ -1,23 +1,22 @@

-use ark_algebra_test_templates::{ - fields::*, generate_field_serialization_test, generate_field_test, -}; +use ark_algebra_test_templates::*; use ark_ff::{ biginteger::{BigInt, BigInteger, BigInteger384}, fields::{FftField, Field, Fp12Config, Fp2Config, Fp6Config, PrimeField}, One, UniformRand, Zero, }; -use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize}; use ark_std::{ cmp::Ordering, ops::{AddAssign, MulAssign, SubAssign}, - rand::Rng, - test_rng, vec, + vec, }; -use crate::{Fq, Fq12, Fq12Config, Fq2, Fq2Config, Fq6, Fq6Config, FqConfig, Fr, FrConfig}; +use crate::{Fq, Fq12, Fq12Config, Fq2, Fq2Config, Fq6, Fq6Config, Fr}; -generate_field_test!(bls12_381; fq2; fq6; fq12; mont(6, 4); ); -generate_field_serialization_test!(bls12_381; fq2; fq6; fq12;); +test_field!(fr; Fr; mont_prime_field); +test_field!(fq; Fq; mont_prime_field); +test_field!(fq2; Fq2); +test_field!(fq6; Fq6); +test_field!(fq12; Fq12); #[test] fn test_negative_one() {
M bn254/Cargo.toml → bn254/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version="^0.3.0", default-features = false }
M bn254/src/curves/g1.rs → bn254/src/curves/g1.rs

@@ -33,7 +33,7 @@ /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)

const GENERATOR: G1Affine = G1Affine::new_unchecked(G1_GENERATOR_X, G1_GENERATOR_Y); #[inline(always)] - fn mul_by_a(_: &Self::BaseField) -> Self::BaseField { + fn mul_by_a(_: Self::BaseField) -> Self::BaseField { Self::BaseField::zero() } }
M bn254/src/curves/g2.rs → bn254/src/curves/g2.rs

@@ -45,7 +45,7 @@ /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)

const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y); #[inline(always)] - fn mul_by_a(_: &Self::BaseField) -> Self::BaseField { + fn mul_by_a(_: Self::BaseField) -> Self::BaseField { Self::BaseField::zero() } }
M bn254/src/curves/tests.rs → bn254/src/curves/tests.rs

@@ -1,16 +1,9 @@

-use ark_algebra_test_templates::{ - curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test, msm::*, -}; -use ark_ec::{AffineCurve, PairingEngine}; -use ark_ff::{ - fields::{Field, PrimeField}, - One, -}; -use ark_std::{rand::Rng, test_rng}; -use core::ops::MulAssign; +use ark_algebra_test_templates::*; +use ark_ff::fields::Field; -use crate::{g1, g2, Bn254, Fq12, Fr, G1Affine, G1Projective, G2Affine, G2Projective}; +use crate::{Bn254, G1Projective, G2Projective}; -generate_g1_test!(bn254; curve_tests; sw_tests;); -generate_g2_test!(bn254; curve_tests; sw_tests;); -generate_bilinearity_test!(Bn254, Fq12); +test_group!(g1; G1Projective; sw); +test_group!(g2; G2Projective; sw); +test_group!(pairing_output; ark_ec::pairing::PairingOutput<Bn254>; msm); +test_pairing!(pairing; crate::Bn254);
M bn254/src/fields/tests.rs → bn254/src/fields/tests.rs

@@ -1,22 +1,21 @@

-use ark_algebra_test_templates::{ - fields::*, generate_field_serialization_test, generate_field_test, -}; +use ark_algebra_test_templates::*; use ark_ff::{ biginteger::{BigInt, BigInteger, BigInteger256}, fields::{FftField, Field, Fp6Config, PrimeField}, One, UniformRand, Zero, }; -use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize}; -use ark_std::{rand::Rng, test_rng}; -use core::{ +use ark_std::{ cmp::Ordering, - ops::{AddAssign, MulAssign, SubAssign}, + ops::{AddAssign, MulAssign}, }; -use crate::{Fq, Fq12, Fq2, Fq6, Fq6Config, FqConfig, Fr, FrConfig}; +use crate::{Fq, Fq12, Fq2, Fq6, Fq6Config, Fr}; -generate_field_test!(bn254; fq2; fq6; fq12; mont(4, 4); ); -generate_field_serialization_test!(bn254; fq2; fq6; fq12;); +test_field!(fr; Fr; mont_prime_field); +test_field!(fq; Fq; mont_prime_field); +test_field!(fq2; Fq2); +test_field!(fq6; Fq6); +test_field!(fq12; Fq12); #[test] fn test_fq_repr_from() {
M bw6_761/Cargo.toml → bw6_761/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version="^0.3.0", default-features = false }
A bw6_761/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A bw6_761/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M bw6_761/src/curves/g1.rs → bw6_761/src/curves/g1.rs

@@ -43,7 +43,7 @@

/// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y) const GENERATOR: G1Affine = G1Affine::new_unchecked(G1_GENERATOR_X, G1_GENERATOR_Y); #[inline(always)] - fn mul_by_a(_elem: &Self::BaseField) -> Self::BaseField { + fn mul_by_a(_elem: Self::BaseField) -> Self::BaseField { use ark_ff::Zero; Self::BaseField::zero() }
M bw6_761/src/curves/g2.rs → bw6_761/src/curves/g2.rs

@@ -44,7 +44,7 @@ /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)

const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y); #[inline(always)] - fn mul_by_a(_elem: &Self::BaseField) -> Self::BaseField { + fn mul_by_a(_elem: Self::BaseField) -> Self::BaseField { use ark_ff::Zero; Self::BaseField::zero() }
M bw6_761/src/curves/tests.rs → bw6_761/src/curves/tests.rs

@@ -1,13 +1,8 @@

-use ark_algebra_test_templates::{ - curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test, msm::*, -}; -use ark_ec::{AffineCurve, PairingEngine}; -use ark_ff::{Field, One, PrimeField}; -use ark_std::{rand::Rng, test_rng}; -use core::ops::MulAssign; - use crate::*; +use ark_algebra_test_templates::*; +use ark_ff::Field; -generate_g1_test!(bw6_761; curve_tests; sw_tests;); -generate_g2_test!(bw6_761; curve_tests; sw_tests;); -generate_bilinearity_test!(BW6_761, Fq6); +test_group!(g1; G1Projective; sw); +test_group!(g2; G2Projective; sw); +test_group!(pairing_output; ark_ec::pairing::PairingOutput<BW6_761>; msm); +test_pairing!(pairing; crate::BW6_761);
M bw6_761/src/fields/tests.rs → bw6_761/src/fields/tests.rs

@@ -1,12 +1,7 @@

-use ark_algebra_test_templates::{ - fields::*, generate_field_serialization_test, generate_field_test, -}; -use ark_ff::{Field, One, PrimeField, UniformRand, Zero}; -use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize}; -use ark_std::{rand::Rng, test_rng}; -use core::ops::{AddAssign, MulAssign, SubAssign}; - use crate::*; +use ark_algebra_test_templates::*; -generate_field_test!(bw6_761; fq3; fq6_2_on_3; false; mont(12, 6); ); -generate_field_serialization_test!(bw6_761;); +test_field!(fr; Fr; mont_prime_field); +test_field!(fq; Fq; mont_prime_field); +test_field!(fq3; Fq3); +test_field!(fq6; Fq6);
M cp6_782/Cargo.toml → cp6_782/Cargo.toml

@@ -10,13 +10,14 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version = "^0.3.0", default-features = false } ark-ec = { version = "^0.3.0", default-features = false } ark-std = { version = "^0.3.0", default-features = false } ark-bls12-377 = { version = "^0.3.0", path = "../bls12_377", default-features = false, features = [ "base_field" ] } +itertools = { version = "0.10", default-features = false } [dev-dependencies] ark-serialize = { version = "^0.3.0", default-features = false }
A cp6_782/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A cp6_782/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M cp6_782/src/curves/g1.rs → cp6_782/src/curves/g1.rs

@@ -1,6 +1,7 @@

use ark_ec::{ models::{short_weierstrass::SWCurveConfig, CurveConfig}, short_weierstrass::{Affine, Projective}, + AffineRepr, CurveGroup, }; use ark_ff::MontFp;

@@ -8,6 +9,45 @@ use crate::{Fq, Fr};

pub type G1Affine = Affine<Parameters>; pub type G1Projective = Projective<Parameters>; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct G1Prepared(pub G1Affine); + +impl From<G1Affine> for G1Prepared { + fn from(other: G1Affine) -> Self { + G1Prepared(other) + } +} + +impl From<G1Projective> for G1Prepared { + fn from(q: G1Projective) -> Self { + q.into_affine().into() + } +} + +impl<'a> From<&'a G1Affine> for G1Prepared { + fn from(other: &'a G1Affine) -> Self { + G1Prepared(*other) + } +} + +impl<'a> From<&'a G1Projective> for G1Prepared { + fn from(q: &'a G1Projective) -> Self { + q.into_affine().into() + } +} + +impl G1Prepared { + pub fn is_zero(&self) -> bool { + self.0.is_identity() + } +} + +impl Default for G1Prepared { + fn default() -> Self { + G1Prepared(G1Affine::generator()) + } +} #[derive(Clone, Default, PartialEq, Eq)] pub struct Parameters;
M cp6_782/src/curves/g2.rs → cp6_782/src/curves/g2.rs

@@ -1,6 +1,7 @@

use ark_ec::{ models::CurveConfig, short_weierstrass::{Affine, Projective, SWCurveConfig}, + AffineRepr, CurveGroup, }; use ark_ff::{Field, MontFp};

@@ -8,6 +9,45 @@ use crate::{Fq, Fq3, Fr};

pub type G2Affine = Affine<Parameters>; pub type G2Projective = Projective<Parameters>; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct G2Prepared(pub G2Affine); + +impl From<G2Affine> for G2Prepared { + fn from(other: G2Affine) -> Self { + G2Prepared(other) + } +} + +impl From<G2Projective> for G2Prepared { + fn from(q: G2Projective) -> Self { + q.into_affine().into() + } +} + +impl<'a> From<&'a G2Affine> for G2Prepared { + fn from(other: &'a G2Affine) -> Self { + G2Prepared(*other) + } +} + +impl<'a> From<&'a G2Projective> for G2Prepared { + fn from(q: &'a G2Projective) -> Self { + q.into_affine().into() + } +} + +impl G2Prepared { + pub fn is_zero(&self) -> bool { + self.0.is_identity() + } +} + +impl Default for G2Prepared { + fn default() -> Self { + G2Prepared(G2Affine::generator()) + } +} #[derive(Clone, Default, PartialEq, Eq)] pub struct Parameters;
M cp6_782/src/curves/mod.rs → cp6_782/src/curves/mod.rs

@@ -1,17 +1,19 @@

-use ark_ec::{models::short_weierstrass::SWCurveConfig, PairingEngine}; +use ark_ec::pairing::{MillerLoopOutput, PairingOutput}; +use ark_ec::{models::short_weierstrass::SWCurveConfig, pairing::Pairing}; use ark_ff::{ biginteger::BigInteger832, fields::{BitIteratorBE, Field}, BigInt, CyclotomicMultSubgroup, One, }; +use itertools::Itertools; use crate::{Fq, Fq3, Fq6, Fr}; pub mod g1; -pub use self::g1::{G1Affine, G1Projective}; +pub use self::g1::{G1Affine, G1Prepared, G1Projective}; pub mod g2; -pub use self::g2::{G2Affine, G2Projective}; +pub use self::g2::{G2Affine, G2Prepared, G2Projective}; #[cfg(test)] mod tests;

@@ -21,40 +23,39 @@

#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct CP6_782; -impl PairingEngine for CP6_782 { - type Fr = Fr; - type G1Projective = G1Projective; +impl Pairing for CP6_782 { + type ScalarField = Fr; + type G1 = G1Projective; type G1Affine = G1Affine; - type G1Prepared = G1Affine; - type G2Projective = G2Projective; + type G1Prepared = G1Prepared; + type G2 = G2Projective; type G2Affine = G2Affine; - type G2Prepared = G2Affine; - type Fq = Fq; - type Fqe = Fq3; - type Fqk = Fq6; + type G2Prepared = G2Prepared; + type TargetField = Fq6; + + fn multi_miller_loop( + a: impl IntoIterator<Item = impl Into<Self::G1Prepared>>, + b: impl IntoIterator<Item = impl Into<Self::G2Prepared>>, + ) -> MillerLoopOutput<Self> { + let mut result = Self::TargetField::one(); + a.into_iter().zip_eq(b).for_each(|(p, q)| { + let (p, q) = (p.into(), q.into()); + result *= &CP6_782::ate_miller_loop(&p, &q); + }); - fn miller_loop<'a, I>(i: I) -> Self::Fqk - where - I: IntoIterator<Item = &'a (Self::G1Prepared, Self::G2Prepared)>, - { - let mut result = Self::Fqk::one(); - for &(ref p, ref q) in i { - result *= &CP6_782::ate_miller_loop(p, q); - } - result + MillerLoopOutput(result) } - fn final_exponentiation(r: &Self::Fqk) -> Option<Self::Fqk> { - Some(CP6_782::final_exponentiation(r)) + fn final_exponentiation(r: MillerLoopOutput<Self>) -> Option<PairingOutput<Self>> { + Some(PairingOutput(CP6_782::final_exponentiation(&r.0))) } } impl CP6_782 { - pub fn ate_pairing(p: &G1Affine, q: &G2Affine) -> GT { - CP6_782::final_exponentiation(&CP6_782::ate_miller_loop(p, q)) - } + fn ate_miller_loop(p: &G1Prepared, q: &G2Prepared) -> Fq6 { + let p = p.0; + let q = q.0; - fn ate_miller_loop(p: &G1Affine, q: &G2Affine) -> Fq6 { let px = p.x; let py = p.y; let qx = q.x;
M cp6_782/src/curves/tests.rs → cp6_782/src/curves/tests.rs

@@ -1,13 +1,9 @@

-use ark_algebra_test_templates::{ - curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test, msm::*, -}; -use ark_ec::{AffineCurve, PairingEngine}; -use ark_ff::{Field, One, PrimeField}; -use ark_std::{rand::Rng, test_rng}; -use core::ops::MulAssign; +use ark_algebra_test_templates::*; +use ark_ff::Field; use crate::*; -generate_g1_test!(cp6_782; curve_tests; sw_tests;); -generate_g2_test!(cp6_782; curve_tests; sw_tests;); -generate_bilinearity_test!(CP6_782, Fq6); +test_group!(g1; G1Projective; sw); +test_group!(g2; G2Projective; sw); +test_group!(pairing_output; ark_ec::pairing::PairingOutput<CP6_782>; msm); +test_pairing!(pairing; crate::CP6_782);
M cp6_782/src/fields/tests.rs → cp6_782/src/fields/tests.rs

@@ -1,12 +1,7 @@

-use ark_algebra_test_templates::{ - fields::*, generate_field_serialization_test, generate_field_test, -}; -use ark_ff::{Field, One, PrimeField, UniformRand, Zero}; -use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize}; -use ark_std::{rand::Rng, test_rng}; -use core::ops::{AddAssign, MulAssign, SubAssign}; - use crate::*; +use ark_algebra_test_templates::*; -generate_field_test!(cp6_782; fq3; fq6_2_on_3; mont(13, 6); ); -generate_field_serialization_test!(cp6_782;); +test_field!(fr; Fr; mont_prime_field); +test_field!(fq; Fq; mont_prime_field); +test_field!(fq3; Fq3); +test_field!(fq6; Fq6);
M curve-benches/Cargo.toml → curve-benches/Cargo.toml

@@ -16,11 +16,10 @@ repository = "https://github.com/arkworks-rs/curves"

documentation = "https://docs.rs/algebra/" keywords = ["cryptography", "finite-fields", "elliptic-curves", "pairing"] categories = ["cryptography"] -include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] +include = ["Cargo.toml", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" publish = false -build = "build.rs" ################################# Dependencies ################################

@@ -32,6 +31,7 @@ ark-std = { version = "^0.3.0", default-features = false }

ark-ec = { version = "^0.3.0", default-features = false } ark-ff = { version = "^0.3.0", default-features = false } ark-serialize = { version = "^0.3.0", default-features = false } +ark-algebra-bench-templates = { version = "^0.3.0", default-features = false } ark-mnt4-298 = { path = "../mnt4_298" } ark-mnt6-298 = { path = "../mnt6_298" }

@@ -48,7 +48,7 @@ ark-vesta = { path = "../vesta" }

[features] asm = [ "ark-ff/asm"] -parallel = [ "ark-ff/parallel", "ark-ec/parallel", ] +parallel = [ "ark-ff/parallel", "ark-ec/parallel" ] n_fold = [] [build-dependencies]
M curve-benches/benches/bls12_377.rs → curve-benches/benches/bls12_377.rs

@@ -1,11 +1,12 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; use ark_bls12_377::{ fq::Fq, fq2::Fq2, fr::Fr, Bls12_377, Fq12, G1Affine, G1Projective as G1, G2Affine, G2Projective as G2, }; -use ark_ec::{PairingEngine, ProjectiveCurve}; +use ark_ec::bls12::{G1Prepared, G2Prepared}; +use ark_ec::{CurveGroup, Group}; use ark_ff::{ biginteger::{BigInteger256 as FrRepr, BigInteger384 as FqRepr}, BigInteger, Field, PrimeField, UniformRand,
M curve-benches/benches/bls12_381.rs → curve-benches/benches/bls12_381.rs

@@ -1,11 +1,12 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; use ark_bls12_381::{ fq::Fq, fq2::Fq2, fr::Fr, Bls12_381, Fq12, G1Affine, G1Projective as G1, G2Affine, G2Projective as G2, }; -use ark_ec::{PairingEngine, ProjectiveCurve}; +use ark_ec::bls12::{G1Prepared, G2Prepared}; +use ark_ec::{CurveGroup, Group}; use ark_ff::{ biginteger::{BigInteger256 as FrRepr, BigInteger384 as FqRepr}, BigInteger, Field, PrimeField, UniformRand,
M curve-benches/benches/bn254.rs → curve-benches/benches/bn254.rs

@@ -1,11 +1,14 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; use ark_bn254::{ fq::Fq, fq2::Fq2, fr::Fr, Bn254, Fq12, G1Affine, G1Projective as G1, G2Affine, G2Projective as G2, }; -use ark_ec::{PairingEngine, ProjectiveCurve}; +use ark_ec::{ + bn::{G1Prepared, G2Prepared}, + CurveGroup, Group, +}; use ark_ff::{biginteger::BigInteger256 as Repr, BigInteger, Field, PrimeField, UniformRand}; mod g1 {
M curve-benches/benches/bw6_761.rs → curve-benches/benches/bw6_761.rs

@@ -1,11 +1,14 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; use ark_bw6_761::{ fq::Fq, fq3::Fq3, fr::Fr, Fq6, G1Affine, G1Projective as G1, G2Affine, G2Projective as G2, BW6_761, }; -use ark_ec::{PairingEngine, ProjectiveCurve}; +use ark_ec::{ + bw6::{G1Prepared, G2Prepared}, + CurveGroup, Group, +}; use ark_ff::{ biginteger::{BigInteger384 as FrRepr, BigInteger768 as FqRepr}, BigInteger, Field, PrimeField, UniformRand,
M curve-benches/benches/cp6_782.rs → curve-benches/benches/cp6_782.rs

@@ -1,11 +1,11 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; use ark_cp6_782::{ - fq::Fq, fq3::Fq3, fr::Fr, Fq6, G1Affine, G1Projective as G1, G2Affine, G2Projective as G2, - CP6_782, + fq::Fq, fq3::Fq3, fr::Fr, Fq6, G1Affine, G1Prepared, G1Projective as G1, G2Affine, G2Prepared, + G2Projective as G2, CP6_782, }; -use ark_ec::{PairingEngine, ProjectiveCurve}; +use ark_ec::{CurveGroup, Group}; use ark_ff::{ biginteger::{BigInteger384 as FrRepr, BigInteger832 as FqRepr}, BigInteger, Field, PrimeField, UniformRand,
M curve-benches/benches/ed_on_bls12_381.rs → curve-benches/benches/ed_on_bls12_381.rs

@@ -1,7 +1,7 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; -use ark_ec::ProjectiveCurve; +use ark_ec::{CurveGroup, Group}; use ark_ed_on_bls12_381::{fq::Fq, fr::Fr, EdwardsAffine as GAffine, EdwardsProjective as G}; use ark_ff::{biginteger::BigInteger256 as Repr, BigInteger, Field, PrimeField, UniformRand};
M curve-benches/benches/mnt4_298.rs → curve-benches/benches/mnt4_298.rs

@@ -1,7 +1,10 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; -use ark_ec::{PairingEngine, ProjectiveCurve}; +use ark_ec::{ + mnt4::{G1Prepared, G2Prepared}, + CurveGroup, Group, +}; use ark_ff::{biginteger::BigInteger320 as FqRepr, BigInteger, Field, PrimeField, UniformRand}; use ark_mnt4_298::{ fq::Fq, fq2::Fq2, fr::Fr, Fq4, G1Affine, G1Projective as G1, G2Affine, G2Projective as G2,
M curve-benches/benches/mnt4_753.rs → curve-benches/benches/mnt4_753.rs

@@ -1,7 +1,10 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; -use ark_ec::{PairingEngine, ProjectiveCurve}; +use ark_ec::{ + mnt4::{G1Prepared, G2Prepared}, + CurveGroup, Group, +}; use ark_ff::{biginteger::BigInteger768 as FqRepr, BigInteger, Field, PrimeField, UniformRand}; use ark_mnt4_753::{ fq::Fq, fq2::Fq2, fr::Fr, Fq4, G1Affine, G1Projective as G1, G2Affine, G2Projective as G2,
M curve-benches/benches/mnt6_298.rs → curve-benches/benches/mnt6_298.rs

@@ -1,7 +1,10 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; -use ark_ec::{PairingEngine, ProjectiveCurve}; +use ark_ec::{ + mnt6::{G1Prepared, G2Prepared}, + CurveGroup, Group, +}; use ark_ff::{biginteger::BigInteger320 as FqRepr, BigInteger, Field, PrimeField, UniformRand}; use ark_mnt6_298::{ fq::Fq, fq3::Fq3, fr::Fr, Fq6, G1Affine, G1Projective as G1, G2Affine, G2Projective as G2,
M curve-benches/benches/mnt6_753.rs → curve-benches/benches/mnt6_753.rs

@@ -1,7 +1,10 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; -use ark_ec::{PairingEngine, ProjectiveCurve}; +use ark_ec::{ + mnt6::{G1Prepared, G2Prepared}, + CurveGroup, Group, +}; use ark_ff::{biginteger::BigInteger768 as FqRepr, BigInteger, Field, PrimeField, UniformRand}; use ark_mnt6_753::{ fq::Fq, fq3::Fq3, fr::Fr, Fq6, G1Affine, G1Projective as G1, G2Affine, G2Projective as G2,
M curve-benches/benches/pallas.rs → curve-benches/benches/pallas.rs

@@ -1,7 +1,7 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; -use ark_ec::ProjectiveCurve; +use ark_ec::{CurveGroup, Group}; use ark_ff::{biginteger::BigInteger256 as Repr, BigInteger, Field, PrimeField, UniformRand}; use ark_pallas::{fq::Fq, fr::Fr, Affine as GAffine, Projective as G};
M curve-benches/benches/vesta.rs → curve-benches/benches/vesta.rs

@@ -1,7 +1,7 @@

-use ark_curve_benches::*; +use ark_algebra_bench_templates::*; use ark_std::ops::{AddAssign, MulAssign, SubAssign}; -use ark_ec::ProjectiveCurve; +use ark_ec::{CurveGroup, Group}; use ark_ff::{biginteger::BigInteger256 as Repr, BigInteger, Field, PrimeField, UniformRand}; use ark_vesta::{fq::Fq, fr::Fr, Affine as GAffine, Projective as G};
D curve-benches/build.rs

@@ -1,9 +0,0 @@

-extern crate rustc_version; - -use rustc_version::{version_meta, Channel}; - -fn main() { - if version_meta().expect("nightly check failed").channel == Channel::Nightly { - println!("cargo:rustc-cfg=nightly"); - } -}
D curve-benches/src/lib.rs

@@ -1,8 +0,0 @@

-#![allow(unused_macros, unused_imports)] -#[macro_use] -pub mod macros; -pub use macros::*; - -#[macro_use] -pub extern crate bencher; -pub use bencher::*;
D curve-benches/src/macros/ec.rs

@@ -1,258 +0,0 @@

-#[macro_export] -macro_rules! ec_bench { - ($projective:ty, $affine:ty) => { - fn rand(b: &mut $crate::bencher::Bencher) { - let mut rng = ark_std::test_rng(); - b.iter(|| <$projective>::rand(&mut rng)); - } - - fn mul_assign(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<($projective, Fr)> = (0..SAMPLES) - .map(|_| (<$projective>::rand(&mut rng), Fr::rand(&mut rng))) - .collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count].0; - tmp *= v[count].1; - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn add_assign(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<($projective, $projective)> = (0..SAMPLES) - .map(|_| (<$projective>::rand(&mut rng), <$projective>::rand(&mut rng))) - .collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count].0; - n_fold!(tmp, v, add_assign, count); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn sub_assign(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<($projective, $projective)> = (0..SAMPLES) - .map(|_| (<$projective>::rand(&mut rng), <$projective>::rand(&mut rng))) - .collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count].0; - n_fold!(tmp, v, sub_assign, count); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn double(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$projective> = (0..SAMPLES) - .map(|_| <$projective>::rand(&mut rng)) - .collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count]; - n_fold!(tmp, double_in_place); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn add_assign_mixed(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<($projective, $affine)> = (0..SAMPLES) - .map(|_| { - ( - <$projective>::rand(&mut rng), - <$projective>::rand(&mut rng).into(), - ) - }) - .collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count].0; - n_fold!(tmp, v, add_assign_mixed, count); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn deser(b: &mut $crate::bencher::Bencher) { - use ark_ec::ProjectiveCurve; - use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let mut num_bytes = 0; - let tmp = <$projective>::rand(&mut rng).into_affine(); - let v: Vec<_> = (0..SAMPLES) - .flat_map(|_| { - let mut bytes = Vec::with_capacity(1000); - tmp.serialize(&mut bytes).unwrap(); - num_bytes = bytes.len(); - bytes - }) - .collect(); - - let mut count = 0; - b.iter(|| { - count = (count + 1) % SAMPLES; - let index = count * num_bytes; - <$affine>::deserialize(&v[index..(index + num_bytes)]).unwrap() - }); - } - - fn ser(b: &mut $crate::bencher::Bencher) { - use ark_ec::ProjectiveCurve; - use ark_serialize::CanonicalSerialize; - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let mut v: Vec<_> = (0..SAMPLES) - .map(|_| <$projective>::rand(&mut rng)) - .collect(); - let v = <$projective>::batch_normalization_into_affine(v.as_mut_slice()); - let mut bytes = Vec::with_capacity(1000); - - let mut count = 0; - b.iter(|| { - let tmp = v[count]; - count = (count + 1) % SAMPLES; - bytes.clear(); - tmp.serialize(&mut bytes) - }); - } - - fn deser_unchecked(b: &mut $crate::bencher::Bencher) { - use ark_ec::ProjectiveCurve; - use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let mut num_bytes = 0; - let tmp = <$projective>::rand(&mut rng).into_affine(); - let v: Vec<_> = (0..SAMPLES) - .flat_map(|_| { - let mut bytes = Vec::with_capacity(1000); - tmp.serialize_unchecked(&mut bytes).unwrap(); - num_bytes = bytes.len(); - bytes - }) - .collect(); - - let mut count = 0; - b.iter(|| { - count = (count + 1) % SAMPLES; - let index = count * num_bytes; - <$affine>::deserialize_unchecked(&v[index..(index + num_bytes)]).unwrap() - }); - } - - fn ser_unchecked(b: &mut $crate::bencher::Bencher) { - use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let mut v: Vec<_> = (0..SAMPLES) - .map(|_| <$projective>::rand(&mut rng)) - .collect(); - let v = <$projective>::batch_normalization_into_affine(v.as_mut_slice()); - let mut bytes = Vec::with_capacity(1000); - - let mut count = 0; - b.iter(|| { - let tmp = v[count]; - count = (count + 1) % SAMPLES; - bytes.clear(); - tmp.serialize_unchecked(&mut bytes) - }); - } - - fn deser_uncompressed(b: &mut $crate::bencher::Bencher) { - use ark_ec::ProjectiveCurve; - use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let mut num_bytes = 0; - let tmp = <$projective>::rand(&mut rng).into_affine(); - let v: Vec<_> = (0..SAMPLES) - .flat_map(|_| { - let mut bytes = Vec::with_capacity(1000); - tmp.serialize_uncompressed(&mut bytes).unwrap(); - num_bytes = bytes.len(); - bytes - }) - .collect(); - - let mut count = 0; - b.iter(|| { - count = (count + 1) % SAMPLES; - let index = count * num_bytes; - <$affine>::deserialize_uncompressed(&v[index..(index + num_bytes)]).unwrap() - }); - } - - fn msm_131072(b: &mut $crate::bencher::Bencher) { - use ark_ec::msm::VariableBaseMSM; - use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; - const SAMPLES: usize = 131072; - - let mut rng = ark_std::test_rng(); - - let g = <$projective>::rand(&mut rng).into_affine(); - let v: Vec<_> = (0..SAMPLES).map(|_| g).collect(); - let scalars: Vec<_> = (0..SAMPLES) - .map(|_| Fr::rand(&mut rng).into_bigint()) - .collect(); - b.bench_n(1, |b| { - b.iter(|| <$projective as VariableBaseMSM>::msm_bigint(&v, &scalars)); - }) - } - - $crate::benchmark_group!( - group_ops, - rand, - mul_assign, - add_assign, - sub_assign, - add_assign_mixed, - double, - ser, - deser, - ser_unchecked, - deser_unchecked, - deser_uncompressed, - msm_131072, - ); - }; -}
D curve-benches/src/macros/field.rs

@@ -1,455 +0,0 @@

-#[macro_export] -macro_rules! f_bench { - // Use this for base fields - ($f:ident, $f_type:ty, $f_repr:ident, $f_repr_type:ty, $modname:ident) => { - pub mod $modname { - use super::*; - field_common!($f, $f_type); - sqrt!($f, $f_type); - prime_field!($f, $f_type, $f_repr, $f_repr_type); - $crate::benchmark_group!( - $modname, - // common stuff - add_assign, - sub_assign, - double, - negate, - mul_assign, - square, - inverse, - ser, - deser, - ser_unchecked, - deser_unchecked, - // sqrt field stuff - sqrt, - // prime field stuff - repr_add_nocarry, - repr_sub_noborrow, - repr_num_bits, - repr_mul2, - repr_div2, - into_repr, - from_repr, - ); - } - use $modname::$modname; - }; - // use this for intermediate fields - (extension, $f:ident, $f_type:ty, $modname:ident) => { - mod $modname { - use super::*; - field_common!($f, $f_type); - sqrt!($f, $f_type); - $crate::benchmark_group!( - $modname, - // common stuff - add_assign, - sub_assign, - double, - negate, - mul_assign, - square, - inverse, - ser, - deser, - ser_unchecked, - deser_unchecked, - // sqrt field stuff - sqrt, - ); - } - use $modname::$modname; - }; - // Use this for the full extension field Fqk - (target, $f:ident, $f_type:ty, $modname:ident) => { - mod $modname { - use super::*; - field_common!($f, $f_type); - $crate::benchmark_group!( - $modname, - // common stuff - add_assign, - sub_assign, - double, - negate, - mul_assign, - square, - inverse, - ser, - deser, - ser_unchecked, - deser_unchecked, - ); - } - use $modname::$modname; - }; -} - -#[macro_export] -macro_rules! field_common { - ($f:ident, $f_type:ty) => { - fn add_assign(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<_> = (0..SAMPLES) - .map(|_| ($f::rand(&mut rng), $f::rand(&mut rng))) - .collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count].0; - n_fold!(tmp, v, add_assign, count); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn sub_assign(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<_> = (0..SAMPLES) - .map(|_| ($f::rand(&mut rng), $f::rand(&mut rng))) - .collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count].0; - n_fold!(tmp, v, sub_assign, count); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn double(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_type> = (0..SAMPLES).map(|_| $f::rand(&mut rng)).collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count]; - n_fold!(tmp, double_in_place); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn negate(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_type> = (0..SAMPLES).map(|_| $f::rand(&mut rng)).collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count]; - tmp = -tmp; - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn mul_assign(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<_> = (0..SAMPLES) - .map(|_| ($f::rand(&mut rng), $f::rand(&mut rng))) - .collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count].0; - n_fold!(tmp, v, mul_assign, count); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn square(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_type> = (0..SAMPLES).map(|_| $f::rand(&mut rng)).collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count]; - n_fold!(tmp, square_in_place); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn inverse(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_type> = (0..SAMPLES).map(|_| $f::rand(&mut rng)).collect(); - - let mut count = 0; - b.iter(|| { - let tmp = v[count].inverse(); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn deser(b: &mut $crate::bencher::Bencher) { - use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let mut num_bytes = 0; - let v: Vec<_> = (0..SAMPLES) - .flat_map(|_| { - let mut bytes = Vec::with_capacity(1000); - let tmp = $f::rand(&mut rng); - tmp.serialize(&mut bytes).unwrap(); - num_bytes = bytes.len(); - bytes - }) - .collect(); - - let mut count = 0; - b.iter(|| { - count = (count + 1) % SAMPLES; - let index = count * num_bytes; - <$f_type>::deserialize(&v[index..(index + num_bytes)]).unwrap() - }); - } - - fn ser(b: &mut $crate::bencher::Bencher) { - use ark_serialize::CanonicalSerialize; - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_type> = (0..SAMPLES).map(|_| $f::rand(&mut rng)).collect(); - let mut bytes = Vec::with_capacity(1000); - - let mut count = 0; - b.iter(|| { - let tmp = v[count]; - count = (count + 1) % SAMPLES; - bytes.clear(); - tmp.serialize(&mut bytes) - }); - } - - fn deser_unchecked(b: &mut $crate::bencher::Bencher) { - use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let mut num_bytes = 0; - let v: Vec<_> = (0..SAMPLES) - .flat_map(|_| { - let mut bytes = Vec::with_capacity(1000); - let tmp = $f::rand(&mut rng); - tmp.serialize_unchecked(&mut bytes).unwrap(); - num_bytes = bytes.len(); - bytes - }) - .collect(); - - let mut count = 0; - b.iter(|| { - count = (count + 1) % SAMPLES; - let index = count * num_bytes; - <$f_type>::deserialize_unchecked(&v[index..(index + num_bytes)]).unwrap() - }); - } - - fn ser_unchecked(b: &mut $crate::bencher::Bencher) { - use ark_serialize::CanonicalSerialize; - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_type> = (0..SAMPLES).map(|_| $f::rand(&mut rng)).collect(); - let mut bytes = Vec::with_capacity(1000); - - let mut count = 0; - b.iter(|| { - let tmp = v[count]; - count = (count + 1) % SAMPLES; - bytes.clear(); - tmp.serialize_unchecked(&mut bytes) - }); - } - }; -} - -#[macro_export] -macro_rules! sqrt { - ($f:ident, $f_type:ty) => { - pub fn sqrt(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_type> = (0..SAMPLES) - .map(|_| { - let mut tmp = $f::rand(&mut rng); - tmp.square_in_place(); - tmp - }) - .collect(); - - let mut count = 0; - b.iter(|| { - count = (count + 1) % SAMPLES; - v[count].sqrt() - }); - } - }; -} - -#[macro_export] -macro_rules! prime_field { - ($f:ident, $f_type:ty, $f_repr:ident, $f_repr_type:ty) => { - fn repr_add_nocarry(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<_> = (0..SAMPLES) - .map(|_| { - let mut tmp1 = $f_repr::rand(&mut rng); - let mut tmp2 = $f_repr::rand(&mut rng); - // Shave a few bits off to avoid overflow. - for _ in 0..3 { - tmp1.div2(); - tmp2.div2(); - } - (tmp1, tmp2) - }) - .collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count].0; - n_fold!(tmp, v, add_with_carry, count); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn repr_sub_noborrow(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<_> = (0..SAMPLES) - .map(|_| { - let tmp1 = $f_repr::rand(&mut rng); - let mut tmp2 = tmp1; - // Ensure tmp2 is smaller than tmp1. - for _ in 0..10 { - tmp2.div2(); - } - (tmp1, tmp2) - }) - .collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count].0; - n_fold!(tmp, v, sub_with_borrow, count); - count = (count + 1) % SAMPLES; - tmp; - }); - } - - fn repr_num_bits(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_repr_type> = (0..SAMPLES).map(|_| $f_repr::rand(&mut rng)).collect(); - - let mut count = 0; - b.iter(|| { - let tmp = v[count].num_bits(); - count = (count + 1) % SAMPLES; - tmp; - }); - } - - fn repr_mul2(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_repr_type> = (0..SAMPLES).map(|_| $f_repr::rand(&mut rng)).collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count]; - n_fold!(tmp, mul2); - count = (count + 1) % SAMPLES; - tmp; - }); - } - - fn repr_div2(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_repr_type> = (0..SAMPLES).map(|_| $f_repr::rand(&mut rng)).collect(); - - let mut count = 0; - b.iter(|| { - let mut tmp = v[count]; - n_fold!(tmp, div2); - count = (count + 1) % SAMPLES; - tmp; - }); - } - - fn into_repr(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_type> = (0..SAMPLES).map(|_| $f::rand(&mut rng)).collect(); - - let mut count = 0; - b.iter(|| { - count = (count + 1) % SAMPLES; - v[count].into_bigint(); - }); - } - - fn from_repr(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<$f_repr_type> = (0..SAMPLES) - .map(|_| $f::rand(&mut rng).into_bigint()) - .collect(); - - let mut count = 0; - b.iter(|| { - count = (count + 1) % SAMPLES; - let _ = $f::from(v[count]); - }); - } - }; -}
D curve-benches/src/macros/mod.rs

@@ -1,11 +0,0 @@

-#[macro_use] -mod utils; - -#[macro_use] -mod ec; - -#[macro_use] -mod field; - -#[macro_use] -mod pairing;
D curve-benches/src/macros/pairing.rs

@@ -1,72 +0,0 @@

-#[macro_export] -macro_rules! pairing_bench { - ($curve:ident, $pairing_field:ident) => { - fn miller_loop(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let g1s = (0..SAMPLES).map(|_| G1::rand(&mut rng)).collect::<Vec<_>>(); - let g2s = (0..SAMPLES).map(|_| G2::rand(&mut rng)).collect::<Vec<_>>(); - let g1s = G1::batch_normalization_into_affine(&g1s); - let g2s = G2::batch_normalization_into_affine(&g2s); - let prepared = g1s - .into_iter() - .zip(g2s) - .map(|(g1, g2)| (g1.into(), g2.into())) - .collect::<Vec<( - <$curve as PairingEngine>::G1Prepared, - <$curve as PairingEngine>::G2Prepared, - )>>(); - let mut count = 0; - b.iter(|| { - let tmp = - $curve::miller_loop(&[(prepared[count].0.clone(), prepared[count].1.clone())]); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn final_exponentiation(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<_> = (0..SAMPLES) - .map(|_| { - ( - G1Affine::from(G1::rand(&mut rng)).into(), - G2Affine::from(G2::rand(&mut rng)).into(), - ) - }) - .map(|(p, q)| $curve::miller_loop(&[(p, q)])) - .collect(); - - let mut count = 0; - b.iter(|| { - let tmp = $curve::final_exponentiation(&v[count]); - count = (count + 1) % SAMPLES; - tmp - }); - } - - fn full_pairing(b: &mut $crate::bencher::Bencher) { - const SAMPLES: usize = 1000; - - let mut rng = ark_std::test_rng(); - - let v: Vec<(G1, G2)> = (0..SAMPLES) - .map(|_| (G1::rand(&mut rng), G2::rand(&mut rng))) - .collect(); - - let mut count = 0; - b.iter(|| { - let tmp = $curve::pairing(v[count].0, v[count].1); - count = (count + 1) % SAMPLES; - tmp - }); - } - - $crate::benchmark_group!(pairing, miller_loop, final_exponentiation, full_pairing,); - }; -}
D curve-benches/src/macros/utils.rs

@@ -1,36 +0,0 @@

-#[macro_export] -macro_rules! n_fold { - ($tmp:ident, $v:ident, $func:ident, $count:ident) => { - $tmp.$func(&$v[$count].1); - }; - - ($tmp:ident, $func:ident) => { - $tmp.$func(); - }; -} - -/// Defines a function called `$group_name` that returns the test description -/// values for the listed functions `$function`. -#[macro_export] -macro_rules! benchmark_group { - ($group_name:ident, $($function:path),+) => { - pub fn $group_name() -> ::std::vec::Vec<$crate::TestDescAndFn> { - use $crate::{TestDescAndFn, TestFn, TestDesc}; - use std::borrow::Cow; - let mut benches = ::std::vec::Vec::new(); - $( - benches.push(TestDescAndFn { - desc: TestDesc { - name: Cow::from(module_path!().to_string() + "::" + stringify!($function)), - ignore: false, - }, - testfn: TestFn::StaticBenchFn($function), - }); - )+ - benches - } - }; - ($group_name:ident, $($function:path,)+) => { - benchmark_group!($group_name, $($function),+); - }; -}
M curve-constraint-tests/Cargo.toml → curve-constraint-tests/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves", "r1cs" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-std = { version = "^0.3.0", default-features = false }
A curve-constraint-tests/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A curve-constraint-tests/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M ed_on_bls12_377/Cargo.toml → ed_on_bls12_377/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version = "^0.3.0", default-features = false }
A ed_on_bls12_377/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A ed_on_bls12_377/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M ed_on_bls12_377/src/curves/mod.rs → ed_on_bls12_377/src/curves/mod.rs

@@ -43,8 +43,8 @@

/// Multiplication by `a` is just negation. /// Is `a` 1 or -1? #[inline(always)] - fn mul_by_a(elem: &Self::BaseField) -> Self::BaseField { - -*elem + fn mul_by_a(elem: Self::BaseField) -> Self::BaseField { + -elem } }
M ed_on_bls12_377/src/curves/tests.rs → ed_on_bls12_377/src/curves/tests.rs

@@ -1,5 +1,5 @@

use ark_algebra_test_templates::curves::*; -use ark_ec::AffineCurve; +use ark_ec::AffineRepr; use crate::*;
M ed_on_bls12_381/Cargo.toml → ed_on_bls12_381/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version = "^0.3.0", default-features = false }
A ed_on_bls12_381/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A ed_on_bls12_381/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M ed_on_bls12_381/src/curves/mod.rs → ed_on_bls12_381/src/curves/mod.rs

@@ -70,7 +70,7 @@ impl TECurveConfig for JubjubParameters {

/// COEFF_A = -1 const COEFF_A: Fq = MontFp!("-1"); - /// COEFF_D = (10240/10241) mod q + /// COEFF_D = -(10240/10241) mod q const COEFF_D: Fq = MontFp!("19257038036680949359750312669786877991949435402254120286184196891950884077233");

@@ -81,8 +81,8 @@ type MontCurveConfig = JubjubParameters;

/// Multiplication by `a` is simply negation here. #[inline(always)] - fn mul_by_a(elem: &Self::BaseField) -> Self::BaseField { - -(*elem) + fn mul_by_a(elem: Self::BaseField) -> Self::BaseField { + -elem } }
M ed_on_bls12_381/src/curves/tests.rs → ed_on_bls12_381/src/curves/tests.rs

@@ -1,5 +1,5 @@

use ark_algebra_test_templates::curves::*; -use ark_ec::{AffineCurve, ProjectiveCurve}; +use ark_ec::{AffineRepr, ProjectiveCurve}; use ark_ff::Zero; use ark_std::{ops::Mul, str::FromStr};
M ed_on_bls12_381_bandersnatch/Cargo.toml → ed_on_bls12_381_bandersnatch/Cargo.toml

@@ -8,7 +8,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version = "^0.3.0", default-features = false }
A ed_on_bls12_381_bandersnatch/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A ed_on_bls12_381_bandersnatch/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M ed_on_bls12_381_bandersnatch/src/curves/mod.rs → ed_on_bls12_381_bandersnatch/src/curves/mod.rs

@@ -83,9 +83,8 @@ type MontCurveConfig = BandersnatchParameters;

/// Multiplication by `a` is multiply by `-5`. #[inline(always)] - fn mul_by_a(elem: &Self::BaseField) -> Self::BaseField { - let t = (*elem).double().double(); - -(t + *elem) + fn mul_by_a(elem: Self::BaseField) -> Self::BaseField { + elem.double().double() * elem } }
M ed_on_bls12_381_bandersnatch/src/curves/tests.rs → ed_on_bls12_381_bandersnatch/src/curves/tests.rs

@@ -1,5 +1,5 @@

use ark_algebra_test_templates::curves::*; -use ark_ec::{AffineCurve, ProjectiveCurve}; +use ark_ec::{AffineRepr, ProjectiveCurve}; use ark_ff::Zero; use ark_std::{ops::Mul, str::FromStr};
M ed_on_bn254/Cargo.toml → ed_on_bn254/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version = "^0.3.0", default-features = false }
A ed_on_bn254/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A ed_on_bn254/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M ed_on_bn254/src/curves/mod.rs → ed_on_bn254/src/curves/mod.rs

@@ -40,8 +40,8 @@ /// COEFF_A = 1

const COEFF_A: Fq = Fq::ONE; #[inline(always)] - fn mul_by_a(elem: &Self::BaseField) -> Self::BaseField { - *elem + fn mul_by_a(elem: Self::BaseField) -> Self::BaseField { + elem } /// COEFF_D = 168696/168700 mod q
M ed_on_bn254/src/curves/tests.rs → ed_on_bn254/src/curves/tests.rs

@@ -1,5 +1,5 @@

use ark_algebra_test_templates::curves::*; -use ark_ec::{AffineCurve, ProjectiveCurve}; +use ark_ec::{AffineRepr, ProjectiveCurve}; use ark_ff::Zero; use ark_std::{ops::Mul, str::FromStr};
M ed_on_bw6_761/Cargo.toml → ed_on_bw6_761/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ed-on-cp6-782 = { version = "^0.3.0", path = "../ed_on_cp6_782", default-features = false }
A ed_on_bw6_761/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A ed_on_bw6_761/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M ed_on_cp6_782/Cargo.toml → ed_on_cp6_782/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version = "^0.3.0", default-features = false }
A ed_on_cp6_782/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A ed_on_cp6_782/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M ed_on_cp6_782/src/curves/mod.rs → ed_on_cp6_782/src/curves/mod.rs

@@ -41,8 +41,8 @@ type MontCurveConfig = EdwardsParameters;

/// Multiplication by `a` is just negation. #[inline(always)] - fn mul_by_a(elem: &Self::BaseField) -> Self::BaseField { - -*elem + fn mul_by_a(elem: Self::BaseField) -> Self::BaseField { + -elem } }
M ed_on_cp6_782/src/curves/tests.rs → ed_on_cp6_782/src/curves/tests.rs

@@ -1,5 +1,5 @@

use ark_algebra_test_templates::curves::*; -use ark_ec::AffineCurve; +use ark_ec::AffineRepr; use crate::*;
M ed_on_mnt4_298/Cargo.toml → ed_on_mnt4_298/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version = "^0.3.0", default-features = false }
A ed_on_mnt4_298/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A ed_on_mnt4_298/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M ed_on_mnt4_298/src/curves/mod.rs → ed_on_mnt4_298/src/curves/mod.rs

@@ -54,8 +54,8 @@ type MontCurveConfig = EdwardsParameters;

/// Multiplication by `a` is just negation. #[inline(always)] - fn mul_by_a(elem: &Self::BaseField) -> Self::BaseField { - -*elem + fn mul_by_a(elem: Self::BaseField) -> Self::BaseField { + -elem } }
M ed_on_mnt4_298/src/curves/tests.rs → ed_on_mnt4_298/src/curves/tests.rs

@@ -1,5 +1,5 @@

use ark_algebra_test_templates::curves::*; -use ark_ec::AffineCurve; +use ark_ec::AffineRepr; use crate::*;
M ed_on_mnt4_753/Cargo.toml → ed_on_mnt4_753/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version = "^0.3.0", default-features = false }
A ed_on_mnt4_753/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A ed_on_mnt4_753/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M ed_on_mnt4_753/src/curves/mod.rs → ed_on_mnt4_753/src/curves/mod.rs

@@ -41,8 +41,8 @@ type MontCurveConfig = EdwardsParameters;

/// Multiplication by `a` is just negation. #[inline(always)] - fn mul_by_a(elem: &Self::BaseField) -> Self::BaseField { - -*elem + fn mul_by_a(elem: Self::BaseField) -> Self::BaseField { + -elem } }
M ed_on_mnt4_753/src/curves/tests.rs → ed_on_mnt4_753/src/curves/tests.rs

@@ -1,5 +1,5 @@

use ark_algebra_test_templates::curves::*; -use ark_ec::AffineCurve; +use ark_ec::AffineRepr; use crate::*;
M mnt4_298/Cargo.toml → mnt4_298/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version = "^0.3.0", default-features = false }
M mnt4_298/src/curves/g2.rs → mnt4_298/src/curves/g2.rs

@@ -60,7 +60,7 @@ /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)

const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y); #[inline(always)] - fn mul_by_a(elt: &Fq2) -> Fq2 { + fn mul_by_a(elt: Fq2) -> Fq2 { Fq2::new(MUL_BY_A_C0 * &elt.c0, MUL_BY_A_C1 * &elt.c1) } }
M mnt4_298/src/curves/tests.rs → mnt4_298/src/curves/tests.rs

@@ -2,7 +2,7 @@ use ark_algebra_test_templates::{

curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test, generate_product_of_pairings_test, msm::*, }; -use ark_ec::{AffineCurve, PairingEngine, ProjectiveCurve}; +use ark_ec::{AffineRepr, PairingEngine, ProjectiveCurve}; use ark_ff::{Field, One, PrimeField, UniformRand}; use ark_std::{rand::Rng, test_rng}; use core::ops::MulAssign;
M mnt4_753/Cargo.toml → mnt4_753/Cargo.toml

@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields" ]

categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [dependencies] ark-ff = { version = "^0.3.0", default-features = false }
M mnt4_753/src/curves/g2.rs → mnt4_753/src/curves/g2.rs

@@ -67,7 +67,7 @@ /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)

const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y); #[inline(always)] - fn mul_by_a(elt: &Fq2) -> Fq2 { + fn mul_by_a(elt: Fq2) -> Fq2 { Fq2::new(MUL_BY_A_C0 * &elt.c0, MUL_BY_A_C1 * &elt.c1) } }
M mnt4_753/src/curves/tests.rs → mnt4_753/src/curves/tests.rs

@@ -2,7 +2,7 @@ use ark_algebra_test_templates::{

curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test, generate_product_of_pairings_test, msm::*, }; -use ark_ec::{AffineCurve, PairingEngine, ProjectiveCurve}; +use ark_ec::{AffineRepr, PairingEngine, ProjectiveCurve}; use ark_ff::{Field, One, PrimeField, UniformRand}; use ark_std::{rand::Rng, test_rng}; use core::ops::MulAssign;
A mnt6_298/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A mnt6_298/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M mnt6_298/src/curves/g2.rs → mnt6_298/src/curves/g2.rs

@@ -63,7 +63,7 @@ /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)

const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y); #[inline(always)] - fn mul_by_a(elt: &Fq3) -> Fq3 { + fn mul_by_a(elt: Fq3) -> Fq3 { Fq3::new( MUL_BY_A_C0 * &elt.c1, MUL_BY_A_C1 * &elt.c2,
M mnt6_298/src/curves/tests.rs → mnt6_298/src/curves/tests.rs

@@ -2,7 +2,7 @@ use ark_algebra_test_templates::{

curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test, generate_product_of_pairings_test, msm::*, }; -use ark_ec::{AffineCurve, PairingEngine, ProjectiveCurve}; +use ark_ec::{AffineRepr, PairingEngine, ProjectiveCurve}; use ark_ff::{Field, One, PrimeField, UniformRand}; use ark_std::{rand::Rng, test_rng}; use core::ops::MulAssign;
A mnt6_753/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A mnt6_753/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M mnt6_753/src/curves/g2.rs → mnt6_753/src/curves/g2.rs

@@ -88,7 +88,7 @@ /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)

const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y); #[inline(always)] - fn mul_by_a(elt: &Fq3) -> Fq3 { + fn mul_by_a(elt: Fq3) -> Fq3 { Fq3::new( MUL_BY_A_C0 * &elt.c1, MUL_BY_A_C1 * &elt.c2,
M mnt6_753/src/curves/tests.rs → mnt6_753/src/curves/tests.rs

@@ -2,7 +2,7 @@ use ark_algebra_test_templates::{

curves::*, generate_bilinearity_test, generate_g1_test, generate_g2_test, generate_product_of_pairings_test, msm::*, }; -use ark_ec::{AffineCurve, PairingEngine, ProjectiveCurve}; +use ark_ec::{AffineRepr, PairingEngine, ProjectiveCurve}; use ark_ff::{Field, One, PrimeField, UniformRand}; use ark_std::{rand::Rng, test_rng}; use core::ops::MulAssign;
A pallas/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A pallas/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M pallas/src/curves/mod.rs → pallas/src/curves/mod.rs

@@ -37,7 +37,7 @@ /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)

const GENERATOR: Affine = Affine::new_unchecked(G_GENERATOR_X, G_GENERATOR_Y); #[inline(always)] - fn mul_by_a(_: &Self::BaseField) -> Self::BaseField { + fn mul_by_a(_: Self::BaseField) -> Self::BaseField { Self::BaseField::zero() } }
M pallas/src/curves/tests.rs → pallas/src/curves/tests.rs

@@ -1,5 +1,5 @@

use ark_algebra_test_templates::curves::{curve_tests, sw_tests}; -use ark_ec::AffineCurve; +use ark_ec::AffineRepr; use crate::{Affine, PallasParameters, Projective};
A vesta/LICENSE-APACHE

@@ -0,0 +1,1 @@

+../LICENSE-APACHE
A vesta/LICENSE-MIT

@@ -0,0 +1,1 @@

+../LICENSE-MIT
M vesta/src/curves/mod.rs → vesta/src/curves/mod.rs

@@ -36,7 +36,7 @@ /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)

const GENERATOR: Affine = Affine::new_unchecked(G_GENERATOR_X, G_GENERATOR_Y); #[inline(always)] - fn mul_by_a(_: &Self::BaseField) -> Self::BaseField { + fn mul_by_a(_: Self::BaseField) -> Self::BaseField { Self::BaseField::zero() } }
M vesta/src/curves/tests.rs → vesta/src/curves/tests.rs

@@ -1,5 +1,5 @@

use ark_algebra_test_templates::curves::{curve_tests, sw_tests}; -use ark_ec::AffineCurve; +use ark_ec::AffineRepr; use crate::{Affine, Projective, VestaParameters};