3 Commits

Author SHA1 Message Date
Marcin
1e951b3fc4 missed two dependencies 2022-11-19 13:36:02 +01:00
Marcin
9bbf909175 bump relations & r1cs-std dependency after their alpha version is out 2022-11-19 13:28:57 +01:00
Marcin
15c0777ae2 Version 0.4.0-alpha 2022-11-12 20:14:24 +01:00
115 changed files with 455 additions and 752 deletions

View File

@@ -13,7 +13,6 @@
### Features
- [\#121](https://github.com/arkworks-rs/curves/pull/121) Add the ed25519 curve.
- [\#122](https://github.com/arkworks-rs/curves/pull/122) Add the secp256k1 and secq256k1 curves.
- [\#124](https://github.com/arkworks-rs/curves/pull/124) Add the curve25519 curve.
### Improvements

View File

@@ -30,9 +30,6 @@ members = [
"pallas",
"vesta",
"secp256k1",
"secq256k1",
"curve25519",
"ed25519",
]

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-bls12-377"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "The BLS12-377 pairing-friendly elliptic curve"
homepage = "https://arkworks.rs"

View File

@@ -1,39 +1,45 @@
use ark_ec::{bls12::Bls12Config, CurveConfig};
use ark_ec::{bls12::Bls12Parameters, CurveConfig};
use ark_r1cs_std::{
fields::fp::FpVar,
groups::{bls12, curves::twisted_edwards::AffineVar as TEAffineVar},
};
use crate::Config;
use crate::Parameters;
/// An element of G1 in the BLS12-377 bilinear group.
pub type G1Var = bls12::G1Var<Config>;
pub type G1Var = bls12::G1Var<Parameters>;
/// An element of G2 in the BLS12-377 bilinear group.
pub type G2Var = bls12::G2Var<Config>;
pub type G2Var = bls12::G2Var<Parameters>;
/// An element of G1 (in TE Affine form) in the BLS12-377 bilinear group.
pub type G1TEAffineVar = TEAffineVar<
<Config as Bls12Config>::G1Config,
FpVar<<<Config as Bls12Config>::G1Config as CurveConfig>::BaseField>,
<Parameters as Bls12Parameters>::G1Parameters,
FpVar<<<Parameters as Bls12Parameters>::G1Parameters as CurveConfig>::BaseField>,
>;
/// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation.
pub type G1PreparedVar = bls12::G1PreparedVar<Config>;
pub type G1PreparedVar = bls12::G1PreparedVar<Parameters>;
/// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation.
pub type G2PreparedVar = bls12::G2PreparedVar<Config>;
pub type G2PreparedVar = bls12::G2PreparedVar<Parameters>;
#[test]
fn test() {
use ark_ec::models::bls12::Bls12Config;
ark_curve_constraint_tests::curves::sw_test::<<Config as Bls12Config>::G1Config, G1Var>()
use ark_ec::models::bls12::Bls12Parameters;
ark_curve_constraint_tests::curves::sw_test::<
<Parameters as Bls12Parameters>::G1Parameters,
G1Var,
>()
.unwrap();
ark_curve_constraint_tests::curves::te_test::<
<Config as Bls12Config>::G1Config,
<Parameters as Bls12Parameters>::G1Parameters,
G1TEAffineVar,
>()
.unwrap();
ark_curve_constraint_tests::curves::sw_test::<<Config as Bls12Config>::G2Config, G2Var>()
ark_curve_constraint_tests::curves::sw_test::<
<Parameters as Bls12Parameters>::G2Parameters,
G2Var,
>()
.unwrap();
}

View File

@@ -1,8 +1,8 @@
use crate::Config;
use crate::Parameters;
/// Specifies the constraints for computing a pairing in the BLS12-377 bilinear
/// group.
pub type PairingVar = ark_r1cs_std::pairing::bls12::PairingVar<Config>;
pub type PairingVar = ark_r1cs_std::pairing::bls12::PairingVar<Parameters>;
#[test]
fn test() {

View File

@@ -11,9 +11,9 @@ use core::ops::Neg;
use crate::{Fq, Fr};
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -25,7 +25,7 @@ impl CurveConfig for Config {
const COFACTOR_INV: Fr = MontFp!("5285428838741532253824584287042945485047145357130994810877");
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO;
@@ -41,9 +41,9 @@ impl SWCurveConfig for Config {
}
}
pub type G1SWAffine = SWAffine<Config>;
pub type G1TEAffine = TEAffine<Config>;
pub type G1TEProjective = TEProjective<Config>;
pub type G1SWAffine = SWAffine<Parameters>;
pub type G1TEAffine = TEAffine<Parameters>;
pub type G1TEProjective = TEProjective<Parameters>;
/// Bls12_377::G1 also has a twisted Edwards form.
/// It can be obtained via the following script, implementing
@@ -92,7 +92,7 @@ pub type G1TEProjective = TEProjective<Config>;
/// # b = -TE1d/TE1a
/// TE2d = Fp(122268283598675559488486339158635529096981886914877139579534153582033676785385790730042363341236035746924960903179)
/// ```
impl TECurveConfig for Config {
impl TECurveConfig for Parameters {
/// COEFF_A = -1
const COEFF_A: Fq = MontFp!("-1");
@@ -102,7 +102,7 @@ impl TECurveConfig for Config {
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
const GENERATOR: G1TEAffine = G1TEAffine::new_unchecked(TE_GENERATOR_X, TE_GENERATOR_Y);
type MontCurveConfig = Config;
type MontCurveConfig = Parameters;
/// Multiplication by `a` is multiply by `-1`.
#[inline(always)]
@@ -140,14 +140,14 @@ impl TECurveConfig for Config {
// # MB = s
// MB=Fp(10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931)
// ```
impl MontCurveConfig for Config {
impl MontCurveConfig for Parameters {
/// COEFF_A = 228097355113300204138531148905234651262148041026195375645000724271212049151994375092458297304264351187709081232384
const COEFF_A: Fq = MontFp!("228097355113300204138531148905234651262148041026195375645000724271212049151994375092458297304264351187709081232384");
/// COEFF_B = 10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931
const COEFF_B: Fq = MontFp!("10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931");
type TECurveConfig = Config;
type TECurveConfig = Parameters;
}
/// G1_GENERATOR_X =

View File

@@ -6,11 +6,11 @@ use ark_ff::{Field, MontFp, Zero};
use crate::{g1, Fq, Fq2, Fr};
pub type G2Affine = Affine<Config>;
pub type G2Affine = Affine<Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq2;
type ScalarField = Fr;
@@ -34,9 +34,9 @@ impl CurveConfig for Config {
MontFp!("6764900296503390671038341982857278410319949526107311149686707033187604810669");
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = [0, 0]
const COEFF_A: Fq2 = Fq2::new(g1::Config::COEFF_A, g1::Config::COEFF_A);
const COEFF_A: Fq2 = Fq2::new(g1::Parameters::COEFF_A, g1::Parameters::COEFF_A);
// As per https://eprint.iacr.org/2012/072.pdf,
// this curve has b' = b/i, where b is the COEFF_B of G1, and x^6 -i is

View File

@@ -1,6 +1,6 @@
use ark_ec::{
bls12,
bls12::{Bls12, Bls12Config, TwistType},
bls12::{Bls12, Bls12Parameters, TwistType},
};
use crate::*;
@@ -11,9 +11,9 @@ pub mod g2;
#[cfg(test)]
mod tests;
pub struct Config;
pub struct Parameters;
impl Bls12Config for Config {
impl Bls12Parameters for Parameters {
const X: &'static [u64] = &[0x8508c00000000001];
/// `x` is positive.
const X_IS_NEGATIVE: bool = false;
@@ -22,15 +22,15 @@ impl Bls12Config for Config {
type Fp2Config = Fq2Config;
type Fp6Config = Fq6Config;
type Fp12Config = Fq12Config;
type G1Config = g1::Config;
type G2Config = g2::Config;
type G1Parameters = g1::Parameters;
type G2Parameters = g2::Parameters;
}
pub type Bls12_377 = Bls12<Config>;
pub type Bls12_377 = Bls12<Parameters>;
pub type G1Affine = bls12::G1Affine<Config>;
pub type G1Projective = bls12::G1Projective<Config>;
pub type G2Affine = bls12::G2Affine<Config>;
pub type G2Projective = bls12::G2Projective<Config>;
pub type G1Affine = bls12::G1Affine<Parameters>;
pub type G1Projective = bls12::G1Projective<Parameters>;
pub type G2Affine = bls12::G2Affine<Parameters>;
pub type G2Projective = bls12::G2Projective<Parameters>;
pub use g1::{G1TEAffine, G1TEProjective};

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-bls12-381"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "The BLS12-381 pairing-friendly elliptic curve"
homepage = "https://arkworks.rs"

View File

@@ -1,7 +1,7 @@
use crate::*;
use ark_ec::{
bls12,
bls12::Bls12Config,
bls12::Bls12Parameters,
models::CurveConfig,
short_weierstrass::{Affine, SWCurveConfig},
AffineRepr, Group,
@@ -14,13 +14,13 @@ use crate::util::{
read_g1_compressed, read_g1_uncompressed, serialize_fq, EncodingFlags, G1_SERIALIZED_SIZE,
};
pub type G1Affine = bls12::G1Affine<crate::Config>;
pub type G1Projective = bls12::G1Projective<crate::Config>;
pub type G1Affine = bls12::G1Affine<crate::Parameters>;
pub type G1Projective = bls12::G1Projective<crate::Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -33,7 +33,7 @@ impl CurveConfig for Config {
MontFp!("52435875175126190458656871551744051925719901746859129887267498875565241663483");
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO;
@@ -57,12 +57,12 @@ impl SWCurveConfig for Config {
// An early-out optimization described in Section 6.
// If uP == P but P != point of infinity, then the point is not in the right
// subgroup.
let x_times_p = p.mul_bigint(crate::Config::X);
let x_times_p = p.mul_bigint(crate::Parameters::X);
if x_times_p.eq(p) && !p.infinity {
return false;
}
let minus_x_squared_times_p = x_times_p.mul_bigint(crate::Config::X).neg();
let minus_x_squared_times_p = x_times_p.mul_bigint(crate::Parameters::X).neg();
let endomorphism_p = endomorphism(p);
minus_x_squared_times_p.eq(&endomorphism_p)
}
@@ -74,7 +74,7 @@ impl SWCurveConfig for Config {
//
// It is enough to multiply by (1 - x), instead of (x - 1)^2 / 3
let h_eff = one_minus_x().into_bigint();
Config::mul_affine(&p, h_eff.as_ref()).into()
Parameters::mul_affine(&p, h_eff.as_ref()).into()
}
fn deserialize_with_mode<R: ark_serialize::Read>(
@@ -139,7 +139,7 @@ impl SWCurveConfig for Config {
}
fn one_minus_x() -> Fr {
const X: Fr = Fr::from_sign_and_limbs(!crate::Config::X_IS_NEGATIVE, crate::Config::X);
const X: Fr = Fr::from_sign_and_limbs(!crate::Parameters::X_IS_NEGATIVE, crate::Parameters::X);
Fr::one() - X
}
@@ -154,7 +154,7 @@ pub const G1_GENERATOR_Y: Fq = MontFp!("1339506544944476473020471379941921221584
/// BETA is a non-trivial cubic root of unity in Fq.
pub const BETA: Fq = MontFp!("793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350");
pub fn endomorphism(p: &Affine<Config>) -> Affine<Config> {
pub fn endomorphism(p: &Affine<Parameters>) -> Affine<Parameters> {
// Endomorphism of the points on the curve.
// endomorphism_p(x,y) = (BETA * x, y)
// where BETA is a non-trivial cubic root of unity in Fq.
@@ -169,7 +169,7 @@ mod test {
use super::*;
use ark_std::{rand::Rng, UniformRand};
fn sample_unchecked() -> Affine<g1::Config> {
fn sample_unchecked() -> Affine<g1::Parameters> {
let mut rng = ark_std::test_rng();
loop {
let x = Fq::rand(&mut rng);
@@ -185,7 +185,7 @@ mod test {
fn test_cofactor_clearing() {
const SAMPLES: usize = 100;
for _ in 0..SAMPLES {
let p: Affine<g1::Config> = sample_unchecked();
let p: Affine<g1::Parameters> = sample_unchecked();
let p = p.clear_cofactor();
assert!(p.is_on_curve());
assert!(p.is_in_correct_subgroup_assuming_on_curve());

View File

@@ -2,7 +2,7 @@ use ark_std::ops::Neg;
use ark_ec::{
bls12,
bls12::Bls12Config,
bls12::Bls12Parameters,
models::CurveConfig,
short_weierstrass::{Affine, Projective, SWCurveConfig},
AffineRepr, CurveGroup, Group,
@@ -16,13 +16,13 @@ use crate::{
*,
};
pub type G2Affine = bls12::G2Affine<crate::Config>;
pub type G2Projective = bls12::G2Projective<crate::Config>;
pub type G2Affine = bls12::G2Affine<crate::Parameters>;
pub type G2Projective = bls12::G2Projective<crate::Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq2;
type ScalarField = Fr;
@@ -47,12 +47,12 @@ impl CurveConfig for Config {
MontFp!("26652489039290660355457965112010883481355318854675681319708643586776743290055");
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = [0, 0]
const COEFF_A: Fq2 = Fq2::new(g1::Config::COEFF_A, g1::Config::COEFF_A);
const COEFF_A: Fq2 = Fq2::new(g1::Parameters::COEFF_A, g1::Parameters::COEFF_A);
/// COEFF_B = [4, 4]
const COEFF_B: Fq2 = Fq2::new(g1::Config::COEFF_B, g1::Config::COEFF_B);
const COEFF_B: Fq2 = Fq2::new(g1::Parameters::COEFF_B, g1::Parameters::COEFF_B);
/// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)
const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y);
@@ -67,8 +67,8 @@ impl SWCurveConfig for Config {
//
// Checks that [p]P = [X]P
let mut x_times_point = point.mul_bigint(crate::Config::X);
if crate::Config::X_IS_NEGATIVE {
let mut x_times_point = point.mul_bigint(crate::Parameters::X);
if crate::Parameters::X_IS_NEGATIVE {
x_times_point = -x_times_point;
}
@@ -86,11 +86,11 @@ impl SWCurveConfig for Config {
// When multiplying, use -c1 instead, and then negate the result. That's much
// more efficient, since the scalar -c1 has less limbs and a much lower Hamming
// weight.
let x: &'static [u64] = crate::Config::X;
let x: &'static [u64] = crate::Parameters::X;
let p_projective = p.into_group();
// [x]P
let x_p = Config::mul_affine(p, &x).neg();
let x_p = Parameters::mul_affine(p, &x).neg();
// ψ(P)
let psi_p = p_power_endomorphism(&p);
// (ψ^2)(2P)
@@ -101,7 +101,7 @@ impl SWCurveConfig for Config {
tmp += &psi_p;
// tmp2 = [x^2]P + [x]ψ(P)
let mut tmp2: Projective<Config> = tmp;
let mut tmp2: Projective<Parameters> = tmp;
tmp2 = tmp2.mul_bigint(x).neg();
// add up all the terms
@@ -224,7 +224,7 @@ pub const DOUBLE_P_POWER_ENDOMORPHISM: Fq2 = Fq2::new(
Fq::ZERO
);
pub fn p_power_endomorphism(p: &Affine<Config>) -> Affine<Config> {
pub fn p_power_endomorphism(p: &Affine<Parameters>) -> Affine<Parameters> {
// The p-power endomorphism for G2 is defined as follows:
// 1. Note that G2 is defined on curve E': y^2 = x^3 + 4(u+1).
// To map a point (x, y) in E' to (s, t) in E,
@@ -240,8 +240,8 @@ pub fn p_power_endomorphism(p: &Affine<Config>) -> Affine<Config> {
// as implemented in the code as follows.
let mut res = *p;
res.x.frobenius_map_in_place(1);
res.y.frobenius_map_in_place(1);
res.x.frobenius_map(1);
res.y.frobenius_map(1);
let tmp_x = res.x.clone();
res.x.c0 = -P_POWER_ENDOMORPHISM_COEFF_0.c1 * &tmp_x.c1;
@@ -252,7 +252,7 @@ pub fn p_power_endomorphism(p: &Affine<Config>) -> Affine<Config> {
}
/// For a p-power endomorphism psi(P), compute psi(psi(P))
pub fn double_p_power_endomorphism(p: &Projective<Config>) -> Projective<Config> {
pub fn double_p_power_endomorphism(p: &Projective<Parameters>) -> Projective<Parameters> {
let mut res = *p;
res.x *= DOUBLE_P_POWER_ENDOMORPHISM;
@@ -287,9 +287,9 @@ mod test {
let mut rng = ark_std::test_rng();
const SAMPLES: usize = 10;
for _ in 0..SAMPLES {
let p = Affine::<g2::Config>::rand(&mut rng);
let p = Affine::<g2::Parameters>::rand(&mut rng);
let optimised = p.clear_cofactor().into_group();
let naive = g2::Config::mul_affine(&p, h_eff);
let naive = g2::Parameters::mul_affine(&p, h_eff);
assert_eq!(optimised, naive);
}
}

View File

@@ -1,4 +1,4 @@
use ark_ec::bls12::{Bls12, Bls12Config, TwistType};
use ark_ec::bls12::{Bls12, Bls12Parameters, TwistType};
use crate::{Fq, Fq12Config, Fq2Config, Fq6Config};
@@ -14,11 +14,11 @@ pub use self::{
g2::{G2Affine, G2Projective},
};
pub type Bls12_381 = Bls12<Config>;
pub type Bls12_381 = Bls12<Parameters>;
pub struct Config;
pub struct Parameters;
impl Bls12Config for Config {
impl Bls12Parameters for Parameters {
const X: &'static [u64] = &[0xd201000000010000];
const X_IS_NEGATIVE: bool = true;
const TWIST_TYPE: TwistType = TwistType::M;
@@ -26,6 +26,6 @@ impl Bls12Config for Config {
type Fp2Config = Fq2Config;
type Fp6Config = Fq6Config;
type Fp12Config = Fq12Config;
type G1Config = self::g1::Config;
type G2Config = self::g2::Config;
type G1Parameters = self::g1::Parameters;
type G2Parameters = self::g2::Parameters;
}

View File

@@ -2,7 +2,9 @@ use ark_ec::{short_weierstrass::Affine, AffineRepr};
use ark_ff::{BigInteger384, PrimeField};
use ark_serialize::SerializationError;
use crate::{g1::Config as G1Config, g2::Config as G2Config, Fq, Fq2, G1Affine, G2Affine};
use crate::{
g1::Parameters as G1Parameters, g2::Parameters as G2Parameters, Fq, Fq2, G1Affine, G2Affine,
};
pub const G1_SERIALIZED_SIZE: usize = 48;
pub const G2_SERIALIZED_SIZE: usize = 96;
@@ -89,7 +91,7 @@ pub(crate) fn read_fq_with_offset(
pub(crate) fn read_g1_compressed<R: ark_serialize::Read>(
mut reader: R,
) -> Result<Affine<G1Config>, ark_serialize::SerializationError> {
) -> Result<Affine<G1Parameters>, ark_serialize::SerializationError> {
let mut bytes = [0u8; G1_SERIALIZED_SIZE];
reader
.read_exact(&mut bytes)
@@ -119,7 +121,7 @@ pub(crate) fn read_g1_compressed<R: ark_serialize::Read>(
pub(crate) fn read_g1_uncompressed<R: ark_serialize::Read>(
mut reader: R,
) -> Result<Affine<G1Config>, ark_serialize::SerializationError> {
) -> Result<Affine<G1Parameters>, ark_serialize::SerializationError> {
let mut bytes = [0u8; 2 * G1_SERIALIZED_SIZE];
reader
.read_exact(&mut bytes)
@@ -149,7 +151,7 @@ pub(crate) fn read_g1_uncompressed<R: ark_serialize::Read>(
pub(crate) fn read_g2_compressed<R: ark_serialize::Read>(
mut reader: R,
) -> Result<Affine<G2Config>, ark_serialize::SerializationError> {
) -> Result<Affine<G2Parameters>, ark_serialize::SerializationError> {
let mut bytes = [0u8; G2_SERIALIZED_SIZE];
reader
.read_exact(&mut bytes)
@@ -181,7 +183,7 @@ pub(crate) fn read_g2_compressed<R: ark_serialize::Read>(
pub(crate) fn read_g2_uncompressed<R: ark_serialize::Read>(
mut reader: R,
) -> Result<Affine<G2Config>, ark_serialize::SerializationError> {
) -> Result<Affine<G2Parameters>, ark_serialize::SerializationError> {
let mut bytes = [0u8; 2 * G2_SERIALIZED_SIZE];
reader
.read_exact(&mut bytes)

View File

@@ -3,7 +3,5 @@ use ark_ff::fields::{Fp384, MontBackend, MontConfig};
#[derive(MontConfig)]
#[modulus = "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787"]
#[generator = "2"]
#[small_subgroup_base = "3"]
#[small_subgroup_power = "2"]
pub struct FqConfig;
pub type Fq = Fp384<MontBackend<FqConfig, 6>>;

View File

@@ -3,7 +3,5 @@ use ark_ff::fields::{Fp256, MontBackend, MontConfig};
#[derive(MontConfig)]
#[modulus = "52435875175126190479447740508185965837690552500527637822603658699938581184513"]
#[generator = "7"]
#[small_subgroup_base = "3"]
#[small_subgroup_power = "1"]
pub struct FrConfig;
pub type Fr = Fp256<MontBackend<FrConfig, 4>>;

View File

@@ -1601,7 +1601,7 @@ fn test_fq2_doubling() {
}
#[test]
fn test_fq2_frobenius_map_in_place() {
fn test_fq2_frobenius_map() {
let mut a = Fq2::new(
Fq::from(BigInt::new([
0x2d0078036923ffc7,
@@ -1620,7 +1620,7 @@ fn test_fq2_frobenius_map_in_place() {
0x12d1137b8a6a837,
])),
);
a.frobenius_map_in_place(0);
a.frobenius_map(0);
assert_eq!(
a,
Fq2::new(
@@ -1642,7 +1642,7 @@ fn test_fq2_frobenius_map_in_place() {
])),
)
);
a.frobenius_map_in_place(1);
a.frobenius_map(1);
assert_eq!(
a,
Fq2::new(
@@ -1664,7 +1664,7 @@ fn test_fq2_frobenius_map_in_place() {
])),
)
);
a.frobenius_map_in_place(1);
a.frobenius_map(1);
assert_eq!(
a,
Fq2::new(
@@ -1686,7 +1686,7 @@ fn test_fq2_frobenius_map_in_place() {
])),
)
);
a.frobenius_map_in_place(2);
a.frobenius_map(2);
assert_eq!(
a,
Fq2::new(

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-bn254"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "The BN254 pairing-friendly elliptic curve"
homepage = "https://arkworks.rs"

View File

@@ -7,11 +7,11 @@ use ark_ff::{Field, MontFp, Zero};
use crate::{Fq, Fr};
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
pub type G1Affine = Affine<Config>;
pub type G1Affine = Affine<Parameters>;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -22,7 +22,7 @@ impl CurveConfig for Config {
const COFACTOR_INV: Fr = Fr::ONE;
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO;

View File

@@ -6,12 +6,12 @@ use ark_ff::{Field, MontFp, Zero};
use crate::{Fq, Fq2, Fr};
pub type G2Affine = Affine<Config>;
pub type G2Affine = Affine<Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq2;
type ScalarField = Fr;
@@ -30,7 +30,7 @@ impl CurveConfig for Config {
MontFp!("10944121435919637613327163357776759465618812564592884533313067514031822496649");
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = [0, 0]
const COEFF_A: Fq2 = Fq2::ZERO;

View File

@@ -1,6 +1,6 @@
use ark_ec::{
bn,
bn::{Bn, BnConfig, TwistType},
bn::{Bn, BnParameters, TwistType},
};
use ark_ff::MontFp;
@@ -12,9 +12,9 @@ pub mod g2;
#[cfg(test)]
mod tests;
pub struct Config;
pub struct Parameters;
impl BnConfig for Config {
impl BnParameters for Parameters {
const X: &'static [u64] = &[4965661367192848881];
/// `x` is positive.
const X_IS_NEGATIVE: bool = false;
@@ -37,13 +37,13 @@ impl BnConfig for Config {
type Fp2Config = Fq2Config;
type Fp6Config = Fq6Config;
type Fp12Config = Fq12Config;
type G1Config = g1::Config;
type G2Config = g2::Config;
type G1Parameters = g1::Parameters;
type G2Parameters = g2::Parameters;
}
pub type Bn254 = Bn<Config>;
pub type Bn254 = Bn<Parameters>;
pub type G1Affine = bn::G1Affine<Config>;
pub type G1Projective = bn::G1Projective<Config>;
pub type G2Affine = bn::G2Affine<Config>;
pub type G2Projective = bn::G2Projective<Config>;
pub type G1Affine = bn::G1Affine<Parameters>;
pub type G1Projective = bn::G1Projective<Parameters>;
pub type G2Affine = bn::G2Affine<Parameters>;
pub type G2Projective = bn::G2Projective<Parameters>;

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-bw6-761"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "The BW6-761 pairing-friendly elliptic curve"
homepage = "https://arkworks.rs"

View File

@@ -6,13 +6,13 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr};
pub type G1Affine = Affine<Config>;
pub type G1Projective = Projective<Config>;
pub type G1Affine = Affine<Parameters>;
pub type G1Projective = Projective<Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -33,7 +33,7 @@ impl CurveConfig for Config {
const COFACTOR_INV: Fr = MontFp!("91141326767669940707819291241958318717982251277713150053234367522357946997763584490607453720072232540829942217804");
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO;

View File

@@ -6,13 +6,13 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr};
pub type G2Affine = Affine<Config>;
pub type G2Projective = Projective<Config>;
pub type G2Affine = Affine<Parameters>;
pub type G2Projective = Projective<Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -33,7 +33,7 @@ impl CurveConfig for Config {
const COFACTOR_INV: Fr = MontFp!("214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124");
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO;

View File

@@ -1,6 +1,6 @@
use ark_ec::{
bw6,
bw6::{BW6Config, TwistType, BW6},
bw6::{BW6Parameters, TwistType, BW6},
};
use ark_ff::{biginteger::BigInteger768 as BigInteger, BigInt};
@@ -13,9 +13,9 @@ pub mod g2;
mod tests;
#[derive(PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl BW6Config for Config {
impl BW6Parameters for Parameters {
const X: BigInteger = BigInt::new([
0x8508c00000000001,
0x0,
@@ -50,13 +50,13 @@ impl BW6Config for Config {
type Fp = Fq;
type Fp3Config = Fq3Config;
type Fp6Config = Fq6Config;
type G1Config = g1::Config;
type G2Config = g2::Config;
type G1Parameters = g1::Parameters;
type G2Parameters = g2::Parameters;
}
pub type BW6_761 = BW6<Config>;
pub type BW6_761 = BW6<Parameters>;
pub type G1Affine = bw6::G1Affine<Config>;
pub type G1Projective = bw6::G1Projective<Config>;
pub type G2Affine = bw6::G2Affine<Config>;
pub type G2Projective = bw6::G2Projective<Config>;
pub type G1Affine = bw6::G1Affine<Parameters>;
pub type G1Projective = bw6::G1Projective<Parameters>;
pub type G2Affine = bw6::G2Affine<Parameters>;
pub type G2Projective = bw6::G2Projective<Parameters>;

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-cp6-782"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "The CP6-782 pairing-friendly elliptic curve"
homepage = "https://arkworks.rs"

View File

@@ -9,8 +9,8 @@ use ark_std::vec::Vec;
use crate::{Fq, Fr};
pub type G1Affine = Affine<Config>;
pub type G1Projective = Projective<Config>;
pub type G1Affine = Affine<Parameters>;
pub type G1Projective = Projective<Parameters>;
#[derive(Clone, Debug, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)]
pub struct G1Prepared(pub G1Affine);
@@ -52,9 +52,9 @@ impl Default for G1Prepared {
}
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -76,7 +76,7 @@ impl CurveConfig for Config {
const COFACTOR_INV: Fr = MontFp!("163276846538158998893990986356139314746223949404500031940624325017036397274793417940375498603127780919653358641788");
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = 5
const COEFF_A: Fq = MontFp!("5");

View File

@@ -9,8 +9,8 @@ use ark_std::vec::Vec;
use crate::{Fq, Fq3, Fr};
pub type G2Affine = Affine<Config>;
pub type G2Projective = Projective<Config>;
pub type G2Affine = Affine<Parameters>;
pub type G2Projective = Projective<Parameters>;
#[derive(Clone, Debug, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)]
pub struct G2Prepared(pub G2Affine);
@@ -52,9 +52,9 @@ impl Default for G2Prepared {
}
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq3;
type ScalarField = Fr;
@@ -100,7 +100,7 @@ impl CurveConfig for Config {
const COFACTOR_INV: Fr = MontFp!("45586359457219724873147353901735745013467692594291916855200979604570630929674383405372210802279573887880950375598");
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = (0, 0, COEFF_A * TWIST^2) = (0, 0, 5)
const COEFF_A: Fq3 = Fq3::new(Fq::ZERO, Fq::ZERO, MontFp!("5"));

View File

@@ -78,7 +78,7 @@ impl CP6_782 {
let old_rx_square = old_rx.square();
let old_rx_square_3 = old_rx_square.double() + &old_rx_square;
let old_rx_square_3_a = old_rx_square_3 + &g2::Config::COEFF_A;
let old_rx_square_3_a = old_rx_square_3 + &g2::Parameters::COEFF_A;
let old_ry_double_inverse = old_ry.double().inverse().unwrap();
let gamma = old_rx_square_3_a * &old_ry_double_inverse;
@@ -129,19 +129,19 @@ impl CP6_782 {
// elt_q3 = elt^(q^3)
let mut elt_q3 = elt.clone();
elt_q3.frobenius_map_in_place(3);
elt_q3.frobenius_map(3);
// elt_q3_over_elt = elt^(q^3-1)
let elt_q3_over_elt = elt_q3 * elt_inv;
// alpha = elt^((q^3-1) * q)
let mut alpha = elt_q3_over_elt.clone();
alpha.frobenius_map_in_place(1);
alpha.frobenius_map(1);
// beta = elt^((q^3-1)*(q+1)
alpha * &elt_q3_over_elt
}
fn final_exponentiation_last(elt: &Fq6, elt_inv: &Fq6) -> Fq6 {
let mut elt_q = elt.clone();
elt_q.frobenius_map_in_place(1);
elt_q.frobenius_map(1);
let w1_part = elt_q.cyclotomic_exp(&FINAL_EXPONENT_LAST_CHUNK_W1);
let w0_part = if FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG {

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-curve-constraint-tests"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "A library for testing constraints for finite fields, elliptic curves, and pairings"
homepage = "https://arkworks.rs"

View File

@@ -211,7 +211,7 @@ pub mod fields {
let mut a = F::rand(&mut rng);
let mut a_gadget = AF::new_variable(ark_relations::ns!(cs, "a"), || Ok(a), mode)?;
a_gadget.frobenius_map_in_place(i)?;
a.frobenius_map_in_place(i);
a.frobenius_map(i);
assert_eq!(a_gadget.value()?, a);
}
@@ -321,10 +321,8 @@ pub mod curves {
*limb = u64::MAX;
}
let modulus_num_bits_mod_64 = <C::ScalarField as PrimeField>::MODULUS_BIT_SIZE % 64;
if modulus_num_bits_mod_64 != 0 {
*max.last_mut().unwrap() >>= 64 - modulus_num_bits_mod_64;
}
let modulus_last_limb_bits = <C::ScalarField as PrimeField>::MODULUS_BIT_SIZE % 64;
*max.last_mut().unwrap() >>= 64 - modulus_last_limb_bits;
let scalars = [
C::ScalarField::rand(&mut rng)
.into_bigint()

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-curve25519"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "The curve25519 Montgomery curve"
homepage = "https://arkworks.rs"

View File

@@ -3,7 +3,5 @@ use ark_ff::fields::{Fp256, MontBackend, MontConfig};
#[derive(MontConfig)]
#[modulus = "57896044618658097711785492504343953926634992332820282019728792003956564819949"]
#[generator = "2"]
#[small_subgroup_base = "3"]
#[small_subgroup_power = "1"]
pub struct FqConfig;
pub type Fq = Fp256<MontBackend<FqConfig, 4>>;

View File

@@ -3,7 +3,5 @@ use ark_ff::fields::{Fp256, MontBackend, MontConfig};
#[derive(MontConfig)]
#[modulus = "7237005577332262213973186563042994240857116359379907606001950938285454250989"]
#[generator = "2"]
#[small_subgroup_base = "3"]
#[small_subgroup_power = "1"]
pub struct FrConfig;
pub type Fr = Fp256<MontBackend<FrConfig, 4>>;

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-ed25519"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "The ed25519 twisted Edwards curve"
homepage = "https://arkworks.rs"
@@ -17,7 +17,6 @@ ark-ff = { version = "0.4.0-alpha", default-features = false }
ark-ec = { version = "0.4.0-alpha", default-features = false }
ark-std = { version = "0.4.0-alpha", default-features = false }
ark-r1cs-std = { version = "0.4.0-alpha", default-features = false, optional = true }
ark-curve25519 = { version = "0.4.0-alpha", path = "../curve25519" }
[dev-dependencies]
ark-relations = { version = "0.4.0-alpha", default-features = false }

View File

@@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
#[test]
fn test() {
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
}

View File

@@ -8,13 +8,13 @@ use ark_ff::MontFp;
#[cfg(test)]
mod tests;
pub type EdwardsAffine = Affine<EdwardsConfig>;
pub type EdwardsProjective = Projective<EdwardsConfig>;
pub type EdwardsAffine = Affine<EdwardsParameters>;
pub type EdwardsProjective = Projective<EdwardsParameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsConfig;
pub struct EdwardsParameters;
impl CurveConfig for EdwardsConfig {
impl CurveConfig for EdwardsParameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -27,7 +27,7 @@ impl CurveConfig for EdwardsConfig {
MontFp!("2713877091499598330239944961141122840321418634767465352250731601857045344121");
}
impl TECurveConfig for EdwardsConfig {
impl TECurveConfig for EdwardsParameters {
/// COEFF_A = -1
const COEFF_A: Fq = MontFp!("-1");
@@ -38,7 +38,7 @@ impl TECurveConfig for EdwardsConfig {
/// Standard generators from <https://neuromancer.sk/std/other/Ed25519>.
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
type MontCurveConfig = EdwardsConfig;
type MontCurveConfig = EdwardsParameters;
/// Multiplication by `a` is just negation.
#[inline(always)]
@@ -48,7 +48,7 @@ impl TECurveConfig for EdwardsConfig {
}
// We want to emphasize that this Montgomery curve is not Curve25519.
impl MontCurveConfig for EdwardsConfig {
impl MontCurveConfig for EdwardsParameters {
/// COEFF_A = 486662
const COEFF_A: Fq = MontFp!("486662");
@@ -57,7 +57,7 @@ impl MontCurveConfig for EdwardsConfig {
const COEFF_B: Fq =
MontFp!("57896044618658097711785492504343953926634992332820282019728792003956564333285");
type TECurveConfig = EdwardsConfig;
type TECurveConfig = EdwardsParameters;
}
/// GENERATOR_X =

View File

@@ -1 +1,7 @@
pub use ark_curve25519::{Fq, FqConfig};
use ark_ff::fields::{Fp256, MontBackend, MontConfig};
#[derive(MontConfig)]
#[modulus = "57896044618658097711785492504343953926634992332820282019728792003956564819949"]
#[generator = "2"]
pub struct FqConfig;
pub type Fq = Fp256<MontBackend<FqConfig, 4>>;

View File

@@ -1 +1,7 @@
pub use ark_curve25519::{Fr, FrConfig};
use ark_ff::fields::{Fp256, MontBackend, MontConfig};
#[derive(MontConfig)]
#[modulus = "7237005577332262213973186563042994240857116359379907606001950938285454250989"]
#[generator = "2"]
pub struct FrConfig;
pub type Fr = Fp256<MontBackend<FrConfig, 4>>;

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-ed-on-bls12-377"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "A Twisted Edwards curve defined over the scalar field of the BLS12-377 curve"
homepage = "https://arkworks.rs"

View File

@@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
#[test]
fn test() {
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
}

View File

@@ -9,13 +9,13 @@ use crate::{fq::Fq, fr::Fr};
#[cfg(test)]
mod tests;
pub type EdwardsAffine = Affine<EdwardsConfig>;
pub type EdwardsProjective = Projective<EdwardsConfig>;
pub type EdwardsAffine = Affine<EdwardsParameters>;
pub type EdwardsProjective = Projective<EdwardsParameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsConfig;
pub struct EdwardsParameters;
impl CurveConfig for EdwardsConfig {
impl CurveConfig for EdwardsParameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -28,7 +28,7 @@ impl CurveConfig for EdwardsConfig {
MontFp!("527778859339273151515551558673846658209717731602102048798421311598680340096");
}
impl TECurveConfig for EdwardsConfig {
impl TECurveConfig for EdwardsParameters {
/// COEFF_A = -1
const COEFF_A: Fq = MontFp!("-1");
@@ -38,7 +38,7 @@ impl TECurveConfig for EdwardsConfig {
/// Generated randomly
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
type MontCurveConfig = EdwardsConfig;
type MontCurveConfig = EdwardsParameters;
/// Multiplication by `a` is just negation.
/// Is `a` 1 or -1?
@@ -48,7 +48,7 @@ impl TECurveConfig for EdwardsConfig {
}
}
impl MontCurveConfig for EdwardsConfig {
impl MontCurveConfig for EdwardsParameters {
/// COEFF_A = 0x8D26E3FADA9010A26949031ECE3971B93952AD84D4753DDEDB748DA37E8F552
/// = 3990301581132929505568273333084066329187552697088022219156688740916631500114
const COEFF_A: Fq =
@@ -59,7 +59,7 @@ impl MontCurveConfig for EdwardsConfig {
const COEFF_B: Fq =
MontFp!("4454160168295440918680551605697480202188346638066041608778544715000777738925");
type TECurveConfig = EdwardsConfig;
type TECurveConfig = EdwardsParameters;
}
/// GENERATOR_X =

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-ed-on-bls12-381"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "A Twisted Edwards curve defined over the scalar field of the BLS12-381 curve"
homepage = "https://arkworks.rs"

View File

@@ -3,10 +3,10 @@ use ark_r1cs_std::groups::curves::{short_weierstrass::ProjectiveVar, twisted_edw
use crate::{constraints::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<JubjubConfig, FqVar>;
pub type EdwardsVar = AffineVar<JubjubParameters, FqVar>;
/// A variable that is the R1CS equivalent of `crate::SWProjective`
pub type SWVar = ProjectiveVar<JubjubConfig, FqVar>;
pub type SWVar = ProjectiveVar<JubjubParameters, FqVar>;
#[test]
fn test() {

View File

@@ -10,10 +10,10 @@ use crate::{Fq, Fr};
#[cfg(test)]
mod tests;
pub type EdwardsAffine = Affine<JubjubConfig>;
pub type EdwardsProjective = Projective<JubjubConfig>;
pub type SWAffine = short_weierstrass::Affine<JubjubConfig>;
pub type SWProjective = short_weierstrass::Projective<JubjubConfig>;
pub type EdwardsAffine = Affine<JubjubParameters>;
pub type EdwardsProjective = Projective<JubjubParameters>;
pub type SWAffine = short_weierstrass::Affine<JubjubParameters>;
pub type SWProjective = short_weierstrass::Projective<JubjubParameters>;
/// `JubJub` is a twisted Edwards curve. These curves have equations of the
/// form: ax² + y² = 1 - dx²y².
@@ -49,11 +49,11 @@ pub type SWProjective = short_weierstrass::Projective<JubjubConfig>;
/// [here](https://github.com/zhenfeizhang/bandersnatch/blob/main/bandersnatch/script/jubjub.sage)
/// to convert between the different representations.
#[derive(Clone, Default, PartialEq, Eq)]
pub struct JubjubConfig;
pub type EdwardsConfig = JubjubConfig;
pub type SWConfig = JubjubConfig;
pub struct JubjubParameters;
pub type EdwardsParameters = JubjubParameters;
pub type SWParameters = JubjubParameters;
impl CurveConfig for JubjubConfig {
impl CurveConfig for JubjubParameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -66,7 +66,7 @@ impl CurveConfig for JubjubConfig {
MontFp!("819310549611346726241370945440405716213240158234039660170669895299022906775");
}
impl TECurveConfig for JubjubConfig {
impl TECurveConfig for JubjubParameters {
/// COEFF_A = -1
const COEFF_A: Fq = MontFp!("-1");
@@ -77,7 +77,7 @@ impl TECurveConfig for JubjubConfig {
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
type MontCurveConfig = JubjubConfig;
type MontCurveConfig = JubjubParameters;
/// Multiplication by `a` is simply negation here.
#[inline(always)]
@@ -86,14 +86,14 @@ impl TECurveConfig for JubjubConfig {
}
}
impl MontCurveConfig for JubjubConfig {
impl MontCurveConfig for JubjubParameters {
/// COEFF_A = 40962
const COEFF_A: Fq = MontFp!("40962");
/// COEFF_B = -40964
const COEFF_B: Fq = MontFp!("-40964");
type TECurveConfig = JubjubConfig;
type TECurveConfig = JubjubParameters;
}
const GENERATOR_X: Fq =
@@ -102,7 +102,7 @@ const GENERATOR_X: Fq =
const GENERATOR_Y: Fq =
MontFp!("13262374693698910701929044844600465831413122818447359594527400194675274060458");
impl SWCurveConfig for JubjubConfig {
impl SWCurveConfig for JubjubParameters {
/// COEFF_A = 52296097456646850916096512823759002727550416093741407922227928430486925478210
const COEFF_A: Self::BaseField =
MontFp!("52296097456646850916096512823759002727550416093741407922227928430486925478210");

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-ed-on-bls12-381-bandersnatch"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "zhenfei zhang", "arkworks contributors" ]
description = "Bandersnatch: a curve defined over the scalar field of the BLS12-381 curve"
repository = "https://github.com/zhenfeizhang/bandersnatch-rust"

View File

@@ -2,11 +2,11 @@ use ark_r1cs_std::groups::curves::{short_weierstrass::ProjectiveVar, twisted_edw
use crate::{constraints::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::BandersnatchConfig`.
pub type EdwardsVar = AffineVar<BandersnatchConfig, FqVar>;
/// A variable that is the R1CS equivalent of `crate::BandersnatchParameters`.
pub type EdwardsVar = AffineVar<BandersnatchParameters, FqVar>;
/// A variable that is the R1CS equivalent of `crate::SWProjective`
pub type SWVar = ProjectiveVar<BandersnatchConfig, FqVar>;
pub type SWVar = ProjectiveVar<BandersnatchParameters, FqVar>;
#[test]
fn test() {

View File

@@ -10,11 +10,11 @@ use crate::{Fq, Fr};
#[cfg(test)]
mod tests;
pub type EdwardsAffine = Affine<BandersnatchConfig>;
pub type EdwardsProjective = Projective<BandersnatchConfig>;
pub type EdwardsAffine = Affine<BandersnatchParameters>;
pub type EdwardsProjective = Projective<BandersnatchParameters>;
pub type SWAffine = short_weierstrass::Affine<BandersnatchConfig>;
pub type SWProjective = short_weierstrass::Projective<BandersnatchConfig>;
pub type SWAffine = short_weierstrass::Affine<BandersnatchParameters>;
pub type SWProjective = short_weierstrass::Projective<BandersnatchParameters>;
/// `bandersnatch` is an incomplete twisted Edwards curve. These curves have
/// equations of the form: ax² + y² = 1 + dx²y².
@@ -49,12 +49,12 @@ pub type SWProjective = short_weierstrass::Projective<BandersnatchConfig>;
/// Script to transfer between different curves are available
/// <https://github.com/zhenfeizhang/bandersnatch/blob/main/bandersnatch/script/bandersnatch.sage>
#[derive(Clone, Default, PartialEq, Eq)]
pub struct BandersnatchConfig;
pub struct BandersnatchParameters;
pub type EdwardsConfig = BandersnatchConfig;
pub type SWConfig = BandersnatchConfig;
pub type EdwardsParameters = BandersnatchParameters;
pub type SWParameters = BandersnatchParameters;
impl CurveConfig for BandersnatchConfig {
impl CurveConfig for BandersnatchParameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -67,7 +67,7 @@ impl CurveConfig for BandersnatchConfig {
MontFp!("9831726595336160714896451345284868594481866920080427688839802480047265754601");
}
impl TECurveConfig for BandersnatchConfig {
impl TECurveConfig for BandersnatchParameters {
/// COEFF_A = -5
const COEFF_A: Fq = MontFp!("-5");
@@ -79,7 +79,7 @@ impl TECurveConfig for BandersnatchConfig {
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(TE_GENERATOR_X, TE_GENERATOR_Y);
type MontCurveConfig = BandersnatchConfig;
type MontCurveConfig = BandersnatchParameters;
/// Multiplication by `a` is multiply by `-5`.
#[inline(always)]
@@ -88,7 +88,7 @@ impl TECurveConfig for BandersnatchConfig {
}
}
impl MontCurveConfig for BandersnatchConfig {
impl MontCurveConfig for BandersnatchParameters {
/// COEFF_A = 29978822694968839326280996386011761570173833766074948509196803838190355340952
const COEFF_A: Fq =
MontFp!("29978822694968839326280996386011761570173833766074948509196803838190355340952");
@@ -97,7 +97,7 @@ impl MontCurveConfig for BandersnatchConfig {
const COEFF_B: Fq =
MontFp!("25465760566081946422412445027709227188579564747101592991722834452325077642517");
type TECurveConfig = BandersnatchConfig;
type TECurveConfig = BandersnatchParameters;
}
// The TE form generator is generated following Zcash's fashion:
@@ -125,7 +125,7 @@ const SW_GENERATOR_X: Fq =
const SW_GENERATOR_Y: Fq =
MontFp!("12663882780877899054958035777720958383845500985908634476792678820121468453298");
impl SWCurveConfig for BandersnatchConfig {
impl SWCurveConfig for BandersnatchParameters {
/// COEFF_A = 10773120815616481058602537765553212789256758185246796157495669123169359657269
const COEFF_A: Self::BaseField =
MontFp!("10773120815616481058602537765553212789256758185246796157495669123169359657269");

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-ed-on-bn254"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "A Twisted Edwards curve defined over the scalar field of the BN254 curve"
homepage = "https://arkworks.rs"

View File

@@ -3,7 +3,7 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
#[test]
fn test() {

View File

@@ -9,8 +9,8 @@ use crate::{Fq, Fr};
#[cfg(test)]
mod tests;
pub type EdwardsAffine = Affine<EdwardsConfig>;
pub type EdwardsProjective = Projective<EdwardsConfig>;
pub type EdwardsAffine = Affine<EdwardsParameters>;
pub type EdwardsProjective = Projective<EdwardsParameters>;
/// `Baby-JubJub` is a twisted Edwards curve. These curves have equations of the
/// form: ax² + y² = 1 + dx²y².
@@ -20,9 +20,9 @@ pub type EdwardsProjective = Projective<EdwardsConfig>;
///
/// q = 21888242871839275222246405745257275088548364400416034343698204186575808495617
#[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsConfig;
pub struct EdwardsParameters;
impl CurveConfig for EdwardsConfig {
impl CurveConfig for EdwardsParameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -35,7 +35,7 @@ impl CurveConfig for EdwardsConfig {
MontFp!("2394026564107420727433200628387514462817212225638746351800188703329891451411");
}
impl TECurveConfig for EdwardsConfig {
impl TECurveConfig for EdwardsParameters {
/// COEFF_A = 1
const COEFF_A: Fq = Fq::ONE;
@@ -52,16 +52,16 @@ impl TECurveConfig for EdwardsConfig {
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
type MontCurveConfig = EdwardsConfig;
type MontCurveConfig = EdwardsParameters;
}
impl MontCurveConfig for EdwardsConfig {
impl MontCurveConfig for EdwardsParameters {
/// COEFF_A = 168698
const COEFF_A: Fq = MontFp!("168698");
/// COEFF_B = 168700
const COEFF_B: Fq = MontFp!("168700");
type TECurveConfig = EdwardsConfig;
type TECurveConfig = EdwardsParameters;
}
const GENERATOR_X: Fq =

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-ed-on-bw6-761"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "A Twisted Edwards curve defined over the scalar field of the BW6-761 curve"
homepage = "https://arkworks.rs"

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-ed-on-cp6-782"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "A Twisted Edwards curve defined over the scalar field of the CP6-782 curve"
homepage = "https://arkworks.rs"

View File

@@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
#[test]
fn test() {
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
}

View File

@@ -9,13 +9,13 @@ use crate::{Fq, Fr};
#[cfg(test)]
mod tests;
pub type EdwardsAffine = Affine<EdwardsConfig>;
pub type EdwardsProjective = Projective<EdwardsConfig>;
pub type EdwardsAffine = Affine<EdwardsParameters>;
pub type EdwardsProjective = Projective<EdwardsParameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsConfig;
pub struct EdwardsParameters;
impl CurveConfig for EdwardsConfig {
impl CurveConfig for EdwardsParameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -27,7 +27,7 @@ impl CurveConfig for EdwardsConfig {
const COFACTOR_INV: Fr = MontFp!("12124894969357926281749346891948134384518445910386624712788431705725441736421489799867521238554906438478484045560");
}
impl TECurveConfig for EdwardsConfig {
impl TECurveConfig for EdwardsParameters {
/// COEFF_A = -1 =
const COEFF_A: Fq = MontFp!("-1");
@@ -37,7 +37,7 @@ impl TECurveConfig for EdwardsConfig {
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
type MontCurveConfig = EdwardsConfig;
type MontCurveConfig = EdwardsParameters;
/// Multiplication by `a` is just negation.
#[inline(always)]
@@ -46,14 +46,14 @@ impl TECurveConfig for EdwardsConfig {
}
}
impl MontCurveConfig for EdwardsConfig {
impl MontCurveConfig for EdwardsParameters {
/// COEFF_A = 0x95D53EB3F6AC3F7A53C26020144439DC6073BCAE513E03FD06B6B3BAA390F25E51534B26719E33F4CD906D4DA9B535
const COEFF_A: Fq = MontFp!("90083623084271891037116870487743067984710080209539149685414147055329063590616489392386084989619674926965747987765");
/// COEFF_B = 0x118650763CE64AB4BE743604C8D05013DC2663652A3D58B21ECAB7BFF65B70DB8BA09F9098E61CC903B2F92B2564ACA
const COEFF_B: Fq = MontFp!("168580802928697202973535863207150465551683432545375510854470115611391404757724333382582803149953685197474573470410");
type TECurveConfig = EdwardsConfig;
type TECurveConfig = EdwardsParameters;
}
/// GENERATOR_X =

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-ed-on-mnt4-298"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "A Twisted Edwards curve defined over the scalar field of the MNT4-298 curve"
homepage = "https://arkworks.rs"

View File

@@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::fields::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
#[test]
fn test() {
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
}

View File

@@ -9,13 +9,13 @@ use crate::{fq::Fq, fr::Fr};
#[cfg(test)]
mod tests;
pub type EdwardsAffine = Affine<EdwardsConfig>;
pub type EdwardsProjective = Projective<EdwardsConfig>;
pub type EdwardsAffine = Affine<EdwardsParameters>;
pub type EdwardsProjective = Projective<EdwardsParameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsConfig;
pub struct EdwardsParameters;
impl CurveConfig for EdwardsConfig {
impl CurveConfig for EdwardsParameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -34,7 +34,7 @@ impl CurveConfig for EdwardsConfig {
// R for Fq: 223364648326281414938801705359223029554923725549792420683051274872200260503540791531766876
// R for Fr: 104384076783966083500464392945960916666734135485183910065100558776489954102951241798239545
impl TECurveConfig for EdwardsConfig {
impl TECurveConfig for EdwardsParameters {
/// COEFF_A = -1
/// Needs to be in the Montgomery residue form in Fq
/// I.e., -1 * R for Fq
@@ -50,7 +50,7 @@ impl TECurveConfig for EdwardsConfig {
/// Generated randomly
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
type MontCurveConfig = EdwardsConfig;
type MontCurveConfig = EdwardsParameters;
/// Multiplication by `a` is just negation.
#[inline(always)]
@@ -59,14 +59,14 @@ impl TECurveConfig for EdwardsConfig {
}
}
impl MontCurveConfig for EdwardsConfig {
impl MontCurveConfig for EdwardsParameters {
/// COEFF_A = 203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204
const COEFF_A: Fq = MontFp!("203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204");
/// COEFF_B = 272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931
const COEFF_B: Fq = MontFp!("272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931");
type TECurveConfig = EdwardsConfig;
type TECurveConfig = EdwardsParameters;
}
/// GENERATOR_X =

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-ed-on-mnt4-753"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "A Twisted Edwards curve defined over the scalar field of the MNT4-753 curve"
homepage = "https://arkworks.rs"

View File

@@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar;
use crate::{constraints::fields::FqVar, *};
/// A variable that is the R1CS equivalent of `crate::EdwardsAffine`.
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
pub type EdwardsVar = AffineVar<EdwardsParameters, FqVar>;
#[test]
fn test() {
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
}

View File

@@ -9,13 +9,13 @@ use crate::{fq::Fq, fr::Fr};
#[cfg(test)]
mod tests;
pub type EdwardsAffine = Affine<EdwardsConfig>;
pub type EdwardsProjective = Projective<EdwardsConfig>;
pub type EdwardsAffine = Affine<EdwardsParameters>;
pub type EdwardsProjective = Projective<EdwardsParameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct EdwardsConfig;
pub struct EdwardsParameters;
impl CurveConfig for EdwardsConfig {
impl CurveConfig for EdwardsParameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -27,7 +27,7 @@ impl CurveConfig for EdwardsConfig {
const COFACTOR_INV: Fr = MontFp!("4582647449616135528381398492791944685893671397494963179726320631987147963874964803303316505414568319530101512550297775574042810022553679071007001162683923594233560231270043634777390699589793776691858866199511300853468155295505");
}
impl TECurveConfig for EdwardsConfig {
impl TECurveConfig for EdwardsParameters {
/// COEFF_A = -1
const COEFF_A: Fq = MontFp!("-1");
@@ -37,7 +37,7 @@ impl TECurveConfig for EdwardsConfig {
/// Generated randomly
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
type MontCurveConfig = EdwardsConfig;
type MontCurveConfig = EdwardsParameters;
/// Multiplication by `a` is just negation.
#[inline(always)]
@@ -46,14 +46,14 @@ impl TECurveConfig for EdwardsConfig {
}
}
impl MontCurveConfig for EdwardsConfig {
impl MontCurveConfig for EdwardsParameters {
/// COEFF_A = 40212480635445336270302172549278415015971955924352275480357619589919378421241453024646804979794897776496091377551124233752850182852486874251193367187677349266115879541798515219680194853352256809837126277708211496794264654247419
const COEFF_A: Fq = MontFp!("40212480635445336270302172549278415015971955924352275480357619589919378421241453024646804979794897776496091377551124233752850182852486874251193367187677349266115879541798515219680194853352256809837126277708211496794264654247419");
/// COEFF_B = 1686010332473617132042042241962222112198753995601673591425883331105974391329653748412088783995441144921979594337334243570322874639106980818502874667119046899605536783551549221790223284494141659774809441351696667426519821912580
const COEFF_B: Fq = MontFp!("1686010332473617132042042241962222112198753995601673591425883331105974391329653748412088783995441144921979594337334243570322874639106980818502874667119046899605536783551549221790223284494141659774809441351696667426519821912580");
type TECurveConfig = EdwardsConfig;
type TECurveConfig = EdwardsParameters;
}
/// GENERATOR_X =

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-mnt4-298"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "The MNT4-298 pairing-friendly elliptic curve"
homepage = "https://arkworks.rs"

View File

@@ -1,24 +1,30 @@
use ark_r1cs_std::groups::mnt4;
use crate::Config;
use crate::Parameters;
/// An element of G1 in the MNT4-298 bilinear group.
pub type G1Var = mnt4::G1Var<Config>;
pub type G1Var = mnt4::G1Var<Parameters>;
/// An element of G2 in the MNT4-298 bilinear group.
pub type G2Var = mnt4::G2Var<Config>;
pub type G2Var = mnt4::G2Var<Parameters>;
/// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation.
pub type G1PreparedVar = mnt4::G1PreparedVar<Config>;
pub type G1PreparedVar = mnt4::G1PreparedVar<Parameters>;
/// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation.
pub type G2PreparedVar = mnt4::G2PreparedVar<Config>;
pub type G2PreparedVar = mnt4::G2PreparedVar<Parameters>;
#[test]
fn test() {
use ark_ec::models::mnt4::MNT4Config;
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G1Config, G1Var>()
use ark_ec::models::mnt4::MNT4Parameters;
ark_curve_constraint_tests::curves::sw_test::<
<Parameters as MNT4Parameters>::G1Parameters,
G1Var,
>()
.unwrap();
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G2Config, G2Var>()
ark_curve_constraint_tests::curves::sw_test::<
<Parameters as MNT4Parameters>::G2Parameters,
G2Var,
>()
.unwrap();
}

View File

@@ -1,8 +1,8 @@
use crate::Config;
use crate::Parameters;
/// Specifies the constraints for computing a pairing in the MNT4-298 bilinear
/// group.
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Config>;
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Parameters>;
#[test]
fn test() {

View File

@@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr};
pub type G1Affine = mnt4::G1Affine<crate::Config>;
pub type G1Projective = mnt4::G1Projective<crate::Config>;
pub type G1Prepared = mnt4::G1Prepared<crate::Config>;
pub type G1Affine = mnt4::G1Affine<crate::Parameters>;
pub type G1Projective = mnt4::G1Projective<crate::Parameters>;
pub type G1Prepared = mnt4::G1Prepared<crate::Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -25,7 +25,7 @@ impl CurveConfig for Config {
const COFACTOR_INV: Fr = Fr::ONE;
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = 2
/// Reference: <https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L116>
const COEFF_A: Fq = MontFp!("2");

View File

@@ -1,20 +1,20 @@
use ark_ec::{
mnt4,
mnt4::MNT4Config,
mnt4::MNT4Parameters,
models::{short_weierstrass::SWCurveConfig, CurveConfig},
};
use ark_ff::{Field, MontFp};
use crate::{Fq, Fq2, Fr, G1_COEFF_A_NON_RESIDUE};
pub type G2Affine = mnt4::G2Affine<crate::Config>;
pub type G2Projective = mnt4::G2Projective<crate::Config>;
pub type G2Prepared = mnt4::G2Prepared<crate::Config>;
pub type G2Affine = mnt4::G2Affine<crate::Parameters>;
pub type G2Projective = mnt4::G2Projective<crate::Parameters>;
pub type G2Prepared = mnt4::G2Prepared<crate::Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq2;
type ScalarField = Fr;
@@ -40,8 +40,8 @@ pub const MUL_BY_A_C0: Fq = G1_COEFF_A_NON_RESIDUE;
/// MUL_BY_A_C1 = NONRESIDUE * COEFF_A
pub const MUL_BY_A_C1: Fq = G1_COEFF_A_NON_RESIDUE;
impl SWCurveConfig for Config {
const COEFF_A: Fq2 = crate::Config::TWIST_COEFF_A;
impl SWCurveConfig for Parameters {
const COEFF_A: Fq2 = crate::Parameters::TWIST_COEFF_A;
// B coefficient of MNT4-298 G2 =
// ```
// mnt4298_twist_coeff_b = mnt4298_Fq2(mnt4298_Fq::zero(),

View File

@@ -1,4 +1,4 @@
use ark_ec::models::mnt4::{MNT4Config, MNT4};
use ark_ec::models::mnt4::{MNT4Parameters, MNT4};
use ark_ff::{biginteger::BigInteger320, BigInt, Field, MontFp};
use crate::{Fq, Fq2, Fq2Config, Fq4Config, Fr};
@@ -14,11 +14,11 @@ pub use self::{
g2::{G2Affine, G2Prepared, G2Projective},
};
pub type MNT4_298 = MNT4<Config>;
pub type MNT4_298 = MNT4<Parameters>;
pub struct Config;
pub struct Parameters;
impl MNT4Config for Config {
impl MNT4Parameters for Parameters {
const TWIST: Fq2 = Fq2::new(Fq::ZERO, Fq::ONE);
// A coefficient of MNT4-298 G2 =
// ```
@@ -46,8 +46,8 @@ impl MNT4Config for Config {
type Fr = Fr;
type Fp2Config = Fq2Config;
type Fp4Config = Fq4Config;
type G1Config = self::g1::Config;
type G2Config = self::g2::Config;
type G1Parameters = self::g1::Parameters;
type G2Parameters = self::g2::Parameters;
}
// 34

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-mnt4-753"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "The MNT4-753 pairing-friendly elliptic curve"
homepage = "https://arkworks.rs"

View File

@@ -1,24 +1,30 @@
use ark_r1cs_std::groups::mnt4;
use crate::Config;
use crate::Parameters;
/// An element of G1 in the MNT4-753 bilinear group.
pub type G1Var = mnt4::G1Var<Config>;
pub type G1Var = mnt4::G1Var<Parameters>;
/// An element of G2 in the MNT4-753 bilinear group.
pub type G2Var = mnt4::G2Var<Config>;
pub type G2Var = mnt4::G2Var<Parameters>;
/// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation.
pub type G1PreparedVar = mnt4::G1PreparedVar<Config>;
pub type G1PreparedVar = mnt4::G1PreparedVar<Parameters>;
/// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation.
pub type G2PreparedVar = mnt4::G2PreparedVar<Config>;
pub type G2PreparedVar = mnt4::G2PreparedVar<Parameters>;
#[test]
fn test() {
use ark_ec::models::mnt4::MNT4Config;
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G1Config, G1Var>()
use ark_ec::models::mnt4::MNT4Parameters;
ark_curve_constraint_tests::curves::sw_test::<
<Parameters as MNT4Parameters>::G1Parameters,
G1Var,
>()
.unwrap();
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G2Config, G2Var>()
ark_curve_constraint_tests::curves::sw_test::<
<Parameters as MNT4Parameters>::G2Parameters,
G2Var,
>()
.unwrap();
}

View File

@@ -1,8 +1,8 @@
use crate::Config;
use crate::Parameters;
/// Specifies the constraints for computing a pairing in the MNT4-753 bilinear
/// group.
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Config>;
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Parameters>;
#[test]
fn test() {

View File

@@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr};
pub type G1Affine = mnt4::G1Affine<crate::Config>;
pub type G1Projective = mnt4::G1Projective<crate::Config>;
pub type G1Prepared = mnt4::G1Prepared<crate::Config>;
pub type G1Affine = mnt4::G1Affine<crate::Parameters>;
pub type G1Projective = mnt4::G1Projective<crate::Parameters>;
pub type G1Prepared = mnt4::G1Prepared<crate::Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -24,7 +24,7 @@ impl CurveConfig for Config {
const COFACTOR_INV: Fr = Fr::ONE;
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = 2
const COEFF_A: Fq = MontFp!("2");

View File

@@ -1,20 +1,20 @@
use ark_ec::{
mnt4,
mnt4::MNT4Config,
mnt4::MNT4Parameters,
models::{short_weierstrass::SWCurveConfig, CurveConfig},
};
use ark_ff::{Field, MontFp};
use crate::{Fq, Fq2, Fr, G1_COEFF_A_NON_RESIDUE};
pub type G2Affine = mnt4::G2Affine<crate::Config>;
pub type G2Projective = mnt4::G2Projective<crate::Config>;
pub type G2Prepared = mnt4::G2Prepared<crate::Config>;
pub type G2Affine = mnt4::G2Affine<crate::Parameters>;
pub type G2Projective = mnt4::G2Projective<crate::Parameters>;
pub type G2Prepared = mnt4::G2Prepared<crate::Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq2;
type ScalarField = Fr;
@@ -47,8 +47,8 @@ pub const MUL_BY_A_C0: Fq = G1_COEFF_A_NON_RESIDUE;
/// MUL_BY_A_C1 = NONRESIDUE * COEFF_A
pub const MUL_BY_A_C1: Fq = G1_COEFF_A_NON_RESIDUE;
impl SWCurveConfig for Config {
const COEFF_A: Fq2 = crate::Config::TWIST_COEFF_A;
impl SWCurveConfig for Parameters {
const COEFF_A: Fq2 = crate::Parameters::TWIST_COEFF_A;
// B coefficient of MNT4-753 G2 =
// ```
// mnt4753_twist_coeff_b = mnt4753_Fq2(mnt4753_Fq::zero(),

View File

@@ -1,4 +1,4 @@
use ark_ec::models::mnt4::{MNT4Config, MNT4};
use ark_ec::models::mnt4::{MNT4Parameters, MNT4};
use ark_ff::{
biginteger::{BigInt, BigInteger768},
Field, Fp2, MontFp,
@@ -17,11 +17,11 @@ pub use self::{
g2::{G2Affine, G2Prepared, G2Projective},
};
pub type MNT4_753 = MNT4<Config>;
pub type MNT4_753 = MNT4<Parameters>;
pub struct Config;
pub struct Parameters;
impl MNT4Config for Config {
impl MNT4Parameters for Parameters {
const TWIST: Fp2<Self::Fp2Config> = Fp2::new(Fq::ZERO, Fq::ONE);
// A coefficient of MNT4-753 G2 =
// ```
@@ -69,8 +69,8 @@ impl MNT4Config for Config {
type Fr = Fr;
type Fp2Config = Fq2Config;
type Fp4Config = Fq4Config;
type G1Config = self::g1::Config;
type G2Config = self::g2::Config;
type G1Parameters = self::g1::Parameters;
type G2Parameters = self::g2::Parameters;
}
// 26

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-mnt6-298"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "The MNT6-298 pairing-friendly elliptic curve"
homepage = "https://arkworks.rs"

View File

@@ -1,24 +1,30 @@
use ark_r1cs_std::groups::mnt6;
use crate::Config;
use crate::Parameters;
/// An element of G1 in the MNT6-298 bilinear group.
pub type G1Var = mnt6::G1Var<Config>;
pub type G1Var = mnt6::G1Var<Parameters>;
/// An element of G2 in the MNT6-298 bilinear group.
pub type G2Var = mnt6::G2Var<Config>;
pub type G2Var = mnt6::G2Var<Parameters>;
/// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation.
pub type G1PreparedVar = mnt6::G1PreparedVar<Config>;
pub type G1PreparedVar = mnt6::G1PreparedVar<Parameters>;
/// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation.
pub type G2PreparedVar = mnt6::G2PreparedVar<Config>;
pub type G2PreparedVar = mnt6::G2PreparedVar<Parameters>;
#[test]
fn test() {
use ark_ec::models::mnt6::MNT6Config;
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G1Config, G1Var>()
use ark_ec::models::mnt6::MNT6Parameters;
ark_curve_constraint_tests::curves::sw_test::<
<Parameters as MNT6Parameters>::G1Parameters,
G1Var,
>()
.unwrap();
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G2Config, G2Var>()
ark_curve_constraint_tests::curves::sw_test::<
<Parameters as MNT6Parameters>::G2Parameters,
G2Var,
>()
.unwrap();
}

View File

@@ -1,8 +1,8 @@
use crate::Config;
use crate::Parameters;
/// Specifies the constraints for computing a pairing in the MNT6-298 bilinear
/// group.
pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Config>;
pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Parameters>;
#[test]
fn test() {

View File

@@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr};
pub type G1Affine = mnt6::G1Affine<crate::Config>;
pub type G1Projective = mnt6::G1Projective<crate::Config>;
pub type G1Prepared = mnt6::G1Prepared<crate::Config>;
pub type G1Affine = mnt6::G1Affine<crate::Parameters>;
pub type G1Projective = mnt6::G1Projective<crate::Parameters>;
pub type G1Prepared = mnt6::G1Prepared<crate::Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -24,7 +24,7 @@ impl CurveConfig for Config {
const COFACTOR_INV: Fr = Fr::ONE;
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = 11
const COEFF_A: Fq = MontFp!("11");

View File

@@ -1,20 +1,20 @@
use ark_ec::{
mnt6,
mnt6::MNT6Config,
mnt6::MNT6Parameters,
models::{short_weierstrass::SWCurveConfig, CurveConfig},
};
use ark_ff::{Field, MontFp};
use crate::{g1, Fq, Fq3, Fr};
pub type G2Affine = mnt6::G2Affine<crate::Config>;
pub type G2Projective = mnt6::G2Projective<crate::Config>;
pub type G2Prepared = mnt6::G2Prepared<crate::Config>;
pub type G2Affine = mnt6::G2Affine<crate::Parameters>;
pub type G2Projective = mnt6::G2Projective<crate::Parameters>;
pub type G2Prepared = mnt6::G2Prepared<crate::Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq3;
type ScalarField = Fr;
@@ -48,10 +48,10 @@ pub const MUL_BY_A_C0: Fq = MontFp!("55");
pub const MUL_BY_A_C1: Fq = MontFp!("55");
/// MUL_BY_A_C2 = COEFF_A
pub const MUL_BY_A_C2: Fq = g1::Config::COEFF_A;
pub const MUL_BY_A_C2: Fq = g1::Parameters::COEFF_A;
impl SWCurveConfig for Config {
const COEFF_A: Fq3 = crate::Config::TWIST_COEFF_A;
impl SWCurveConfig for Parameters {
const COEFF_A: Fq3 = crate::Parameters::TWIST_COEFF_A;
const COEFF_B: Fq3 = Fq3::new(
// 5 * G1::COEFF_B
MontFp!("57578116384997352636487348509878309737146377454014423897662211075515354005624851787652233"),

View File

@@ -1,5 +1,5 @@
use ark_ec::{
models::mnt6::{MNT6Config, MNT6},
models::mnt6::{MNT6Parameters, MNT6},
short_weierstrass::SWCurveConfig,
};
use ark_ff::{biginteger::BigInteger320, BigInt, Field, Fp3};
@@ -17,14 +17,14 @@ pub use self::{
g2::{G2Affine, G2Prepared, G2Projective},
};
pub type MNT6_298 = MNT6<Config>;
pub type MNT6_298 = MNT6<Parameters>;
pub struct Config;
pub struct Parameters;
impl MNT6Config for Config {
impl MNT6Parameters for Parameters {
const TWIST: Fp3<Self::Fp3Config> = Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ONE, Fq::ZERO);
const TWIST_COEFF_A: Fp3<Self::Fp3Config> =
Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ZERO, g1::Config::COEFF_A);
Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ZERO, g1::Parameters::COEFF_A);
// https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt4_80.ml#L88
const ATE_LOOP_COUNT: &'static [i8] = &[
@@ -44,6 +44,6 @@ impl MNT6Config for Config {
type Fr = Fr;
type Fp3Config = Fq3Config;
type Fp6Config = Fq6Config;
type G1Config = self::g1::Config;
type G2Config = self::g2::Config;
type G1Parameters = self::g1::Parameters;
type G2Parameters = self::g2::Parameters;
}

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-mnt6-753"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "arkworks contributors" ]
description = "The MNT6-753 pairing-friendly elliptic curve"
homepage = "https://arkworks.rs"

View File

@@ -1,24 +1,30 @@
use ark_r1cs_std::groups::mnt6;
use crate::Config;
use crate::Parameters;
/// An element of G1 in the MNT6-753 bilinear group.
pub type G1Var = mnt6::G1Var<Config>;
pub type G1Var = mnt6::G1Var<Parameters>;
/// An element of G2 in the MNT6-753 bilinear group.
pub type G2Var = mnt6::G2Var<Config>;
pub type G2Var = mnt6::G2Var<Parameters>;
/// Represents the cached precomputation that can be performed on a G1 element
/// which enables speeding up pairing computation.
pub type G1PreparedVar = mnt6::G1PreparedVar<Config>;
pub type G1PreparedVar = mnt6::G1PreparedVar<Parameters>;
/// Represents the cached precomputation that can be performed on a G2 element
/// which enables speeding up pairing computation.
pub type G2PreparedVar = mnt6::G2PreparedVar<Config>;
pub type G2PreparedVar = mnt6::G2PreparedVar<Parameters>;
#[test]
fn test() {
use ark_ec::models::mnt6::MNT6Config;
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G1Config, G1Var>()
use ark_ec::models::mnt6::MNT6Parameters;
ark_curve_constraint_tests::curves::sw_test::<
<Parameters as MNT6Parameters>::G1Parameters,
G1Var,
>()
.unwrap();
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G2Config, G2Var>()
ark_curve_constraint_tests::curves::sw_test::<
<Parameters as MNT6Parameters>::G2Parameters,
G2Var,
>()
.unwrap();
}

View File

@@ -1,8 +1,8 @@
use crate::Config;
use crate::Parameters;
/// Specifies the constraints for computing a pairing in the MNT6-753 bilinear
/// group.
pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Config>;
pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Parameters>;
#[test]
fn test() {

View File

@@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
use crate::{Fq, Fr};
pub type G1Affine = mnt6::G1Affine<crate::Config>;
pub type G1Projective = mnt6::G1Projective<crate::Config>;
pub type G1Prepared = mnt6::G1Prepared<crate::Config>;
pub type G1Affine = mnt6::G1Affine<crate::Parameters>;
pub type G1Projective = mnt6::G1Projective<crate::Parameters>;
pub type G1Prepared = mnt6::G1Prepared<crate::Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -24,7 +24,7 @@ impl CurveConfig for Config {
const COFACTOR_INV: Fr = Fr::ONE;
}
impl SWCurveConfig for Config {
impl SWCurveConfig for Parameters {
/// COEFF_A = 11
const COEFF_A: Fq = MontFp!("11");

View File

@@ -1,20 +1,20 @@
use ark_ec::{
mnt6,
mnt6::MNT6Config,
mnt6::MNT6Parameters,
models::{short_weierstrass::SWCurveConfig, CurveConfig},
};
use ark_ff::{Field, MontFp};
use crate::{g1, Fq, Fq3, Fr};
pub type G2Affine = mnt6::G2Affine<crate::Config>;
pub type G2Projective = mnt6::G2Projective<crate::Config>;
pub type G2Prepared = mnt6::G2Prepared<crate::Config>;
pub type G2Affine = mnt6::G2Affine<crate::Parameters>;
pub type G2Projective = mnt6::G2Projective<crate::Parameters>;
pub type G2Prepared = mnt6::G2Prepared<crate::Parameters>;
#[derive(Clone, Default, PartialEq, Eq)]
pub struct Config;
pub struct Parameters;
impl CurveConfig for Config {
impl CurveConfig for Parameters {
type BaseField = Fq3;
type ScalarField = Fr;
@@ -64,10 +64,10 @@ pub const MUL_BY_A_C0: Fq = MontFp!("121");
pub const MUL_BY_A_C1: Fq = MontFp!("121");
/// MUL_BY_A_C2 = COEFF_A
pub const MUL_BY_A_C2: Fq = g1::Config::COEFF_A;
pub const MUL_BY_A_C2: Fq = g1::Parameters::COEFF_A;
impl SWCurveConfig for Config {
const COEFF_A: Fq3 = crate::Config::TWIST_COEFF_A;
impl SWCurveConfig for Parameters {
const COEFF_A: Fq3 = crate::Parameters::TWIST_COEFF_A;
// B coefficient of MNT6-753 G2 =
// ```
// mnt6753_twist_coeff_b = mnt6753_Fq3(mnt6753_G1::coeff_b * mnt6753_Fq3::non_residue,

View File

@@ -1,5 +1,5 @@
use ark_ec::models::{
mnt6::{MNT6Config, MNT6},
mnt6::{MNT6Parameters, MNT6},
short_weierstrass::SWCurveConfig,
};
use ark_ff::{biginteger::BigInteger768, BigInt, Field, Fp3};
@@ -17,11 +17,11 @@ pub use self::{
g2::{G2Affine, G2Prepared, G2Projective},
};
pub type MNT6_753 = MNT6<Config>;
pub type MNT6_753 = MNT6<Parameters>;
pub struct Config;
pub struct Parameters;
impl MNT6Config for Config {
impl MNT6Parameters for Parameters {
const TWIST: Fp3<Self::Fp3Config> = Fp3::new(Fq::ZERO, Fq::ONE, Fq::ZERO);
// A coefficient of MNT6-753 G2 =
// ```
@@ -29,7 +29,8 @@ impl MNT6Config for Config {
// mnt6753_G1::coeff_a);
// = (ZERO, ZERO, A_COEFF);
// ```
const TWIST_COEFF_A: Fp3<Self::Fp3Config> = Fp3::new(Fq::ZERO, Fq::ZERO, g1::Config::COEFF_A);
const TWIST_COEFF_A: Fp3<Self::Fp3Config> =
Fp3::new(Fq::ZERO, Fq::ZERO, g1::Parameters::COEFF_A);
// https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt6753.ml
const ATE_LOOP_COUNT: &'static [i8] = &[
@@ -70,6 +71,6 @@ impl MNT6Config for Config {
type Fr = Fr;
type Fp3Config = Fq3Config;
type Fp6Config = Fq6Config;
type G1Config = self::g1::Config;
type G2Config = self::g2::Config;
type G1Parameters = self::g1::Parameters;
type G2Parameters = self::g2::Parameters;
}

View File

@@ -1,6 +1,6 @@
[package]
name = "ark-pallas"
version = "0.4.0-alpha.2"
version = "0.4.0-alpha.1"
authors = [ "Ying Tong Lai", "Daira Hopwood", "O(1) Labs", "arkworks contributors" ]
description = "The Pallas prime-order elliptic curve"
homepage = "https://arkworks.rs"

View File

@@ -3,9 +3,9 @@ use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar;
use crate::{constraints::FBaseVar, *};
/// A group element in the Pallas prime-order group.
pub type GVar = ProjectiveVar<PallasConfig, FBaseVar>;
pub type GVar = ProjectiveVar<PallasParameters, FBaseVar>;
#[test]
fn test() {
ark_curve_constraint_tests::curves::sw_test::<PallasConfig, GVar>().unwrap();
ark_curve_constraint_tests::curves::sw_test::<PallasParameters, GVar>().unwrap();
}

View File

@@ -10,9 +10,9 @@ use crate::{fq::Fq, fr::Fr};
mod tests;
#[derive(Copy, Clone, Default, PartialEq, Eq)]
pub struct PallasConfig;
pub struct PallasParameters;
impl CurveConfig for PallasConfig {
impl CurveConfig for PallasParameters {
type BaseField = Fq;
type ScalarField = Fr;
@@ -23,10 +23,10 @@ impl CurveConfig for PallasConfig {
const COFACTOR_INV: Fr = Fr::ONE;
}
pub type Affine = sw::Affine<PallasConfig>;
pub type Projective = sw::Projective<PallasConfig>;
pub type Affine = sw::Affine<PallasParameters>;
pub type Projective = sw::Projective<PallasParameters>;
impl SWCurveConfig for PallasConfig {
impl SWCurveConfig for PallasParameters {
/// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO;

View File

@@ -1,30 +0,0 @@
[package]
name = "ark-secp256k1"
version = "0.4.0-alpha.2"
authors = [ "arkworks contributors" ]
description = "The secp256k1 curve"
homepage = "https://arkworks.rs"
repository = "https://github.com/arkworks-rs/curves"
documentation = "https://docs.rs/ark-secp256k1/"
keywords = ["cryptography", "finite-fields", "elliptic-curves" ]
categories = ["cryptography"]
include = ["Cargo.toml", "src", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT/Apache-2.0"
edition = "2021"
[dependencies]
ark-ff = { version = "0.4.0-alpha", default-features = false }
ark-ec = { version = "0.4.0-alpha", default-features = false }
ark-r1cs-std = { version = "0.4.0-alpha", default-features = false, optional = true }
ark-std = { version = "0.4.0-alpha", default-features = false }
[dev-dependencies]
ark-relations = { version = "0.4.0-alpha", default-features = false }
ark-serialize = { version = "0.4.0-alpha", default-features = false }
ark-algebra-test-templates = { version = "0.4.0-alpha", default-features = false }
ark-curve-constraint-tests = { path = "../curve-constraint-tests", default-features = false }
[features]
default = []
std = [ "ark-std/std", "ark-ff/std", "ark-ec/std" ]
r1cs = [ "ark-r1cs-std" ]

View File

@@ -1 +0,0 @@
../LICENSE-APACHE

View File

@@ -1 +0,0 @@
../LICENSE-MIT

View File

@@ -1,10 +0,0 @@
use crate::{constraints::FqVar, *};
use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar;
/// A group element in the secp256k1 curve.
pub type GVar = ProjectiveVar<Config, FqVar>;
#[test]
fn test() {
ark_curve_constraint_tests::curves::sw_test::<Config, GVar>().unwrap();
}

View File

@@ -1,11 +0,0 @@
use ark_r1cs_std::fields::fp::FpVar;
use crate::fq::Fq;
/// A variable that is the R1CS equivalent of `crate::Fq`.
pub type FqVar = FpVar<Fq>;
#[test]
fn test() {
ark_curve_constraint_tests::fields::field_test::<_, _, FqVar>().unwrap();
}

View File

@@ -1,7 +0,0 @@
//! This module implements the R1CS equivalent of `ark_secp256k1`.
mod curves;
mod fields;
pub use curves::*;
pub use fields::*;

View File

@@ -1,52 +0,0 @@
use ark_ec::{
models::CurveConfig,
short_weierstrass::{self as sw, SWCurveConfig},
};
use ark_ff::{Field, MontFp, Zero};
use crate::{fq::Fq, fr::Fr};
#[cfg(test)]
mod tests;
pub type Affine = sw::Affine<Config>;
pub type Projective = sw::Projective<Config>;
#[derive(Copy, Clone, Default, PartialEq, Eq)]
pub struct Config;
impl CurveConfig for Config {
type BaseField = Fq;
type ScalarField = Fr;
/// COFACTOR = 1
const COFACTOR: &'static [u64] = &[0x1];
/// COFACTOR_INV = COFACTOR^{-1} mod r = 1
#[rustfmt::skip]
const COFACTOR_INV: Fr = Fr::ONE;
}
impl SWCurveConfig for Config {
/// COEFF_A = 0
const COEFF_A: Fq = Fq::ZERO;
/// COEFF_B = 7
const COEFF_B: Fq = MontFp!("7");
/// GENERATOR = (G_GENERATOR_X, G_GENERATOR_Y)
const GENERATOR: Affine = Affine::new_unchecked(G_GENERATOR_X, G_GENERATOR_Y);
#[inline(always)]
fn mul_by_a(_: Self::BaseField) -> Self::BaseField {
Self::BaseField::zero()
}
}
/// G_GENERATOR_X = 55066263022277343669578718895168534326250603453777594175500187360389116729240
pub const G_GENERATOR_X: Fq =
MontFp!("55066263022277343669578718895168534326250603453777594175500187360389116729240");
/// G_GENERATOR_Y = 32670510020758816978083085130507043184471273380659243275938904335757337482424
pub const G_GENERATOR_Y: Fq =
MontFp!("32670510020758816978083085130507043184471273380659243275938904335757337482424");

View File

@@ -1,4 +0,0 @@
use crate::Projective;
use ark_algebra_test_templates::*;
test_group!(g1; Projective; sw);

View File

@@ -1,9 +0,0 @@
use ark_ff::fields::{Fp256, MontBackend, MontConfig};
#[derive(MontConfig)]
#[modulus = "115792089237316195423570985008687907853269984665640564039457584007908834671663"]
#[generator = "3"]
#[small_subgroup_base = "3"]
#[small_subgroup_power = "1"]
pub struct FqConfig;
pub type Fq = Fp256<MontBackend<FqConfig, 4>>;

View File

@@ -1,9 +0,0 @@
use ark_ff::fields::{Fp256, MontBackend, MontConfig};
#[derive(MontConfig)]
#[modulus = "115792089237316195423570985008687907852837564279074904382605163141518161494337"]
#[generator = "7"]
#[small_subgroup_base = "3"]
#[small_subgroup_power = "1"]
pub struct FrConfig;
pub type Fr = Fp256<MontBackend<FrConfig, 4>>;

View File

@@ -1,8 +0,0 @@
pub mod fq;
pub use self::fq::*;
pub mod fr;
pub use self::fr::*;
#[cfg(test)]
mod tests;

View File

@@ -1,5 +0,0 @@
use crate::{Fq, Fr};
use ark_algebra_test_templates::*;
test_field!(fr; Fr; mont_prime_field);
test_field!(fq; Fq; mont_prime_field);

View File

@@ -1,27 +0,0 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(
warnings,
unused,
future_incompatible,
nonstandard_style,
rust_2018_idioms
)]
#![forbid(unsafe_code)]
//! This library implements the secp256k1 curve.
//! Source: <https://en.bitcoin.it/wiki/Secp256k1>
//!
//! Curve information:
//! * Base field: q =
//! 115792089237316195423570985008687907853269984665640564039457584007908834671663
//! * Scalar field: r =
//! 115792089237316195423570985008687907852837564279074904382605163141518161494337
//! * Curve equation: y^2 = x^3 + 7
#[cfg(feature = "r1cs")]
pub mod constraints;
mod curves;
mod fields;
pub use curves::*;
pub use fields::*;

Some files were not shown because too many files have changed in this diff Show More