mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-27 14:13:46 +01:00
Compare commits
9 Commits
v0.4.0-alp
...
cherry-pic
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d56cc2630 | ||
|
|
5a0b8eca0b | ||
|
|
a986e08ce4 | ||
|
|
5831ddbfe7 | ||
|
|
cba0c7ef0d | ||
|
|
a82486db1d | ||
|
|
febd7635fb | ||
|
|
f8a6a4050e | ||
|
|
cdf4d182a6 |
@@ -13,6 +13,7 @@
|
||||
### 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
|
||||
|
||||
18
Cargo.toml
18
Cargo.toml
@@ -18,6 +18,7 @@ members = [
|
||||
|
||||
"bn254",
|
||||
"ed_on_bn254",
|
||||
"grumpkin",
|
||||
|
||||
"mnt4_298",
|
||||
"mnt6_298",
|
||||
@@ -30,6 +31,9 @@ members = [
|
||||
"pallas",
|
||||
"vesta",
|
||||
|
||||
"secp256k1",
|
||||
"secq256k1",
|
||||
|
||||
"curve25519",
|
||||
"ed25519",
|
||||
]
|
||||
@@ -60,12 +64,10 @@ incremental = true
|
||||
debug-assertions = true
|
||||
debug = true
|
||||
|
||||
# To be removed in the new release.
|
||||
# The following patch is to use a version of ark-r1cs-std compatible with
|
||||
# v0.4.0 but that includes a cherry-picked commit from after v0.4.0 which fixes
|
||||
# the in-circuit scalar multiplication of the zero point. The commit is from
|
||||
# https://github.com/arkworks-rs/r1cs-std/pull/124, without including other
|
||||
# changes done between v0.4.0 and this fix which would break compatibility.
|
||||
[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-r1cs-std = { git = "https://github.com/arnaucube/ark-r1cs-std-cherry-picked/" }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-bls12-377"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "The BLS12-377 pairing-friendly elliptic curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,16 +13,16 @@ license = "MIT/Apache-2.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
ark-ff = { version="^0.3.0", default-features = false }
|
||||
ark-ec = { version="^0.3.0", default-features = false }
|
||||
ark-r1cs-std = { version="^0.3.0", default-features = false, optional = true }
|
||||
ark-std = { version="^0.3.0", default-features = false }
|
||||
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.3.0", default-features = false }
|
||||
ark-serialize = { version="^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version="^0.3.0", default-features = false }
|
||||
ark-algebra-bench-templates = { version = "^0.3.0", default-features = false }
|
||||
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-algebra-bench-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-curve-constraint-tests = { path = "../curve-constraint-tests", default-features = false }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -1,45 +1,39 @@
|
||||
use ark_ec::{bls12::Bls12Parameters, CurveConfig};
|
||||
use ark_ec::{bls12::Bls12Config, CurveConfig};
|
||||
use ark_r1cs_std::{
|
||||
fields::fp::FpVar,
|
||||
groups::{bls12, curves::twisted_edwards::AffineVar as TEAffineVar},
|
||||
};
|
||||
|
||||
use crate::Parameters;
|
||||
use crate::Config;
|
||||
|
||||
/// An element of G1 in the BLS12-377 bilinear group.
|
||||
pub type G1Var = bls12::G1Var<Parameters>;
|
||||
pub type G1Var = bls12::G1Var<Config>;
|
||||
/// An element of G2 in the BLS12-377 bilinear group.
|
||||
pub type G2Var = bls12::G2Var<Parameters>;
|
||||
pub type G2Var = bls12::G2Var<Config>;
|
||||
|
||||
/// An element of G1 (in TE Affine form) in the BLS12-377 bilinear group.
|
||||
pub type G1TEAffineVar = TEAffineVar<
|
||||
<Parameters as Bls12Parameters>::G1Parameters,
|
||||
FpVar<<<Parameters as Bls12Parameters>::G1Parameters as CurveConfig>::BaseField>,
|
||||
<Config as Bls12Config>::G1Config,
|
||||
FpVar<<<Config as Bls12Config>::G1Config 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<Parameters>;
|
||||
pub type G1PreparedVar = bls12::G1PreparedVar<Config>;
|
||||
/// Represents the cached precomputation that can be performed on a G2 element
|
||||
/// which enables speeding up pairing computation.
|
||||
pub type G2PreparedVar = bls12::G2PreparedVar<Parameters>;
|
||||
pub type G2PreparedVar = bls12::G2PreparedVar<Config>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
use ark_ec::models::bls12::Bls12Parameters;
|
||||
ark_curve_constraint_tests::curves::sw_test::<
|
||||
<Parameters as Bls12Parameters>::G1Parameters,
|
||||
G1Var,
|
||||
>()
|
||||
.unwrap();
|
||||
use ark_ec::models::bls12::Bls12Config;
|
||||
ark_curve_constraint_tests::curves::sw_test::<<Config as Bls12Config>::G1Config, G1Var>()
|
||||
.unwrap();
|
||||
ark_curve_constraint_tests::curves::te_test::<
|
||||
<Parameters as Bls12Parameters>::G1Parameters,
|
||||
<Config as Bls12Config>::G1Config,
|
||||
G1TEAffineVar,
|
||||
>()
|
||||
.unwrap();
|
||||
ark_curve_constraint_tests::curves::sw_test::<
|
||||
<Parameters as Bls12Parameters>::G2Parameters,
|
||||
G2Var,
|
||||
>()
|
||||
.unwrap();
|
||||
ark_curve_constraint_tests::curves::sw_test::<<Config as Bls12Config>::G2Config, G2Var>()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::Parameters;
|
||||
use crate::Config;
|
||||
|
||||
/// Specifies the constraints for computing a pairing in the BLS12-377 bilinear
|
||||
/// group.
|
||||
pub type PairingVar = ark_r1cs_std::pairing::bls12::PairingVar<Parameters>;
|
||||
pub type PairingVar = ark_r1cs_std::pairing::bls12::PairingVar<Config>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
|
||||
@@ -11,9 +11,9 @@ use core::ops::Neg;
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -25,7 +25,7 @@ impl CurveConfig for Parameters {
|
||||
const COFACTOR_INV: Fr = MontFp!("5285428838741532253824584287042945485047145357130994810877");
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = 0
|
||||
const COEFF_A: Fq = Fq::ZERO;
|
||||
|
||||
@@ -41,9 +41,9 @@ impl SWCurveConfig for Parameters {
|
||||
}
|
||||
}
|
||||
|
||||
pub type G1SWAffine = SWAffine<Parameters>;
|
||||
pub type G1TEAffine = TEAffine<Parameters>;
|
||||
pub type G1TEProjective = TEProjective<Parameters>;
|
||||
pub type G1SWAffine = SWAffine<Config>;
|
||||
pub type G1TEAffine = TEAffine<Config>;
|
||||
pub type G1TEProjective = TEProjective<Config>;
|
||||
|
||||
/// 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<Parameters>;
|
||||
/// # b = -TE1d/TE1a
|
||||
/// TE2d = Fp(122268283598675559488486339158635529096981886914877139579534153582033676785385790730042363341236035746924960903179)
|
||||
/// ```
|
||||
impl TECurveConfig for Parameters {
|
||||
impl TECurveConfig for Config {
|
||||
/// COEFF_A = -1
|
||||
const COEFF_A: Fq = MontFp!("-1");
|
||||
|
||||
@@ -102,7 +102,7 @@ impl TECurveConfig for Parameters {
|
||||
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
|
||||
const GENERATOR: G1TEAffine = G1TEAffine::new_unchecked(TE_GENERATOR_X, TE_GENERATOR_Y);
|
||||
|
||||
type MontCurveConfig = Parameters;
|
||||
type MontCurveConfig = Config;
|
||||
|
||||
/// Multiplication by `a` is multiply by `-1`.
|
||||
#[inline(always)]
|
||||
@@ -140,14 +140,14 @@ impl TECurveConfig for Parameters {
|
||||
// # MB = s
|
||||
// MB=Fp(10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931)
|
||||
// ```
|
||||
impl MontCurveConfig for Parameters {
|
||||
impl MontCurveConfig for Config {
|
||||
/// COEFF_A = 228097355113300204138531148905234651262148041026195375645000724271212049151994375092458297304264351187709081232384
|
||||
const COEFF_A: Fq = MontFp!("228097355113300204138531148905234651262148041026195375645000724271212049151994375092458297304264351187709081232384");
|
||||
|
||||
/// COEFF_B = 10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931
|
||||
const COEFF_B: Fq = MontFp!("10189023633222963290707194929886294091415157242906428298294512798502806398782149227503530278436336312243746741931");
|
||||
|
||||
type TECurveConfig = Parameters;
|
||||
type TECurveConfig = Config;
|
||||
}
|
||||
|
||||
/// G1_GENERATOR_X =
|
||||
|
||||
@@ -6,11 +6,11 @@ use ark_ff::{Field, MontFp, Zero};
|
||||
|
||||
use crate::{g1, Fq, Fq2, Fr};
|
||||
|
||||
pub type G2Affine = Affine<Parameters>;
|
||||
pub type G2Affine = Affine<Config>;
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq2;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -34,9 +34,9 @@ impl CurveConfig for Parameters {
|
||||
MontFp!("6764900296503390671038341982857278410319949526107311149686707033187604810669");
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = [0, 0]
|
||||
const COEFF_A: Fq2 = Fq2::new(g1::Parameters::COEFF_A, g1::Parameters::COEFF_A);
|
||||
const COEFF_A: Fq2 = Fq2::new(g1::Config::COEFF_A, g1::Config::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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use ark_ec::{
|
||||
bls12,
|
||||
bls12::{Bls12, Bls12Parameters, TwistType},
|
||||
bls12::{Bls12, Bls12Config, TwistType},
|
||||
};
|
||||
|
||||
use crate::*;
|
||||
@@ -11,9 +11,9 @@ pub mod g2;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl Bls12Parameters for Parameters {
|
||||
impl Bls12Config for Config {
|
||||
const X: &'static [u64] = &[0x8508c00000000001];
|
||||
/// `x` is positive.
|
||||
const X_IS_NEGATIVE: bool = false;
|
||||
@@ -22,15 +22,15 @@ impl Bls12Parameters for Parameters {
|
||||
type Fp2Config = Fq2Config;
|
||||
type Fp6Config = Fq6Config;
|
||||
type Fp12Config = Fq12Config;
|
||||
type G1Parameters = g1::Parameters;
|
||||
type G2Parameters = g2::Parameters;
|
||||
type G1Config = g1::Config;
|
||||
type G2Config = g2::Config;
|
||||
}
|
||||
|
||||
pub type Bls12_377 = Bls12<Parameters>;
|
||||
pub type Bls12_377 = Bls12<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 type G1Affine = bls12::G1Affine<Config>;
|
||||
pub type G1Projective = bls12::G1Projective<Config>;
|
||||
pub type G2Affine = bls12::G2Affine<Config>;
|
||||
pub type G2Projective = bls12::G2Projective<Config>;
|
||||
|
||||
pub use g1::{G1TEAffine, G1TEProjective};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-bls12-381"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "The BLS12-381 pairing-friendly elliptic curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,14 +13,14 @@ license = "MIT/Apache-2.0"
|
||||
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-serialize = { version="^0.3.0", default-features = false }
|
||||
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-serialize = { version = "0.4.0-alpha", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-algebra-test-templates = { version="^0.3.0", default-features = false }
|
||||
ark-algebra-bench-templates = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-algebra-bench-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
hex = "^0.4.0"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::*;
|
||||
use ark_ec::{
|
||||
bls12,
|
||||
bls12::Bls12Parameters,
|
||||
bls12::Bls12Config,
|
||||
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::Parameters>;
|
||||
pub type G1Projective = bls12::G1Projective<crate::Parameters>;
|
||||
pub type G1Affine = bls12::G1Affine<crate::Config>;
|
||||
pub type G1Projective = bls12::G1Projective<crate::Config>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -33,7 +33,7 @@ impl CurveConfig for Parameters {
|
||||
MontFp!("52435875175126190458656871551744051925719901746859129887267498875565241663483");
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = 0
|
||||
const COEFF_A: Fq = Fq::ZERO;
|
||||
|
||||
@@ -57,12 +57,12 @@ impl SWCurveConfig for Parameters {
|
||||
// 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::Parameters::X);
|
||||
let x_times_p = p.mul_bigint(crate::Config::X);
|
||||
if x_times_p.eq(p) && !p.infinity {
|
||||
return false;
|
||||
}
|
||||
|
||||
let minus_x_squared_times_p = x_times_p.mul_bigint(crate::Parameters::X).neg();
|
||||
let minus_x_squared_times_p = x_times_p.mul_bigint(crate::Config::X).neg();
|
||||
let endomorphism_p = endomorphism(p);
|
||||
minus_x_squared_times_p.eq(&endomorphism_p)
|
||||
}
|
||||
@@ -74,7 +74,7 @@ impl SWCurveConfig for Parameters {
|
||||
//
|
||||
// It is enough to multiply by (1 - x), instead of (x - 1)^2 / 3
|
||||
let h_eff = one_minus_x().into_bigint();
|
||||
Parameters::mul_affine(&p, h_eff.as_ref()).into()
|
||||
Config::mul_affine(&p, h_eff.as_ref()).into()
|
||||
}
|
||||
|
||||
fn deserialize_with_mode<R: ark_serialize::Read>(
|
||||
@@ -139,7 +139,7 @@ impl SWCurveConfig for Parameters {
|
||||
}
|
||||
|
||||
fn one_minus_x() -> Fr {
|
||||
const X: Fr = Fr::from_sign_and_limbs(!crate::Parameters::X_IS_NEGATIVE, crate::Parameters::X);
|
||||
const X: Fr = Fr::from_sign_and_limbs(!crate::Config::X_IS_NEGATIVE, crate::Config::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<Parameters>) -> Affine<Parameters> {
|
||||
pub fn endomorphism(p: &Affine<Config>) -> Affine<Config> {
|
||||
// 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::Parameters> {
|
||||
fn sample_unchecked() -> Affine<g1::Config> {
|
||||
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::Parameters> = sample_unchecked();
|
||||
let p: Affine<g1::Config> = sample_unchecked();
|
||||
let p = p.clear_cofactor();
|
||||
assert!(p.is_on_curve());
|
||||
assert!(p.is_in_correct_subgroup_assuming_on_curve());
|
||||
|
||||
@@ -2,7 +2,7 @@ use ark_std::ops::Neg;
|
||||
|
||||
use ark_ec::{
|
||||
bls12,
|
||||
bls12::Bls12Parameters,
|
||||
bls12::Bls12Config,
|
||||
models::CurveConfig,
|
||||
short_weierstrass::{Affine, Projective, SWCurveConfig},
|
||||
AffineRepr, CurveGroup, Group,
|
||||
@@ -16,13 +16,13 @@ use crate::{
|
||||
*,
|
||||
};
|
||||
|
||||
pub type G2Affine = bls12::G2Affine<crate::Parameters>;
|
||||
pub type G2Projective = bls12::G2Projective<crate::Parameters>;
|
||||
pub type G2Affine = bls12::G2Affine<crate::Config>;
|
||||
pub type G2Projective = bls12::G2Projective<crate::Config>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq2;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -47,12 +47,12 @@ impl CurveConfig for Parameters {
|
||||
MontFp!("26652489039290660355457965112010883481355318854675681319708643586776743290055");
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = [0, 0]
|
||||
const COEFF_A: Fq2 = Fq2::new(g1::Parameters::COEFF_A, g1::Parameters::COEFF_A);
|
||||
const COEFF_A: Fq2 = Fq2::new(g1::Config::COEFF_A, g1::Config::COEFF_A);
|
||||
|
||||
/// COEFF_B = [4, 4]
|
||||
const COEFF_B: Fq2 = Fq2::new(g1::Parameters::COEFF_B, g1::Parameters::COEFF_B);
|
||||
const COEFF_B: Fq2 = Fq2::new(g1::Config::COEFF_B, g1::Config::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 Parameters {
|
||||
//
|
||||
// Checks that [p]P = [X]P
|
||||
|
||||
let mut x_times_point = point.mul_bigint(crate::Parameters::X);
|
||||
if crate::Parameters::X_IS_NEGATIVE {
|
||||
let mut x_times_point = point.mul_bigint(crate::Config::X);
|
||||
if crate::Config::X_IS_NEGATIVE {
|
||||
x_times_point = -x_times_point;
|
||||
}
|
||||
|
||||
@@ -86,11 +86,11 @@ impl SWCurveConfig for Parameters {
|
||||
// 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::Parameters::X;
|
||||
let x: &'static [u64] = crate::Config::X;
|
||||
let p_projective = p.into_group();
|
||||
|
||||
// [x]P
|
||||
let x_p = Parameters::mul_affine(p, &x).neg();
|
||||
let x_p = Config::mul_affine(p, &x).neg();
|
||||
// ψ(P)
|
||||
let psi_p = p_power_endomorphism(&p);
|
||||
// (ψ^2)(2P)
|
||||
@@ -101,7 +101,7 @@ impl SWCurveConfig for Parameters {
|
||||
tmp += &psi_p;
|
||||
|
||||
// tmp2 = [x^2]P + [x]ψ(P)
|
||||
let mut tmp2: Projective<Parameters> = tmp;
|
||||
let mut tmp2: Projective<Config> = 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<Parameters>) -> Affine<Parameters> {
|
||||
pub fn p_power_endomorphism(p: &Affine<Config>) -> Affine<Config> {
|
||||
// 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<Parameters>) -> Affine<Parameters> {
|
||||
// as implemented in the code as follows.
|
||||
|
||||
let mut res = *p;
|
||||
res.x.frobenius_map(1);
|
||||
res.y.frobenius_map(1);
|
||||
res.x.frobenius_map_in_place(1);
|
||||
res.y.frobenius_map_in_place(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<Parameters>) -> Affine<Parameters> {
|
||||
}
|
||||
|
||||
/// For a p-power endomorphism psi(P), compute psi(psi(P))
|
||||
pub fn double_p_power_endomorphism(p: &Projective<Parameters>) -> Projective<Parameters> {
|
||||
pub fn double_p_power_endomorphism(p: &Projective<Config>) -> Projective<Config> {
|
||||
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::Parameters>::rand(&mut rng);
|
||||
let p = Affine::<g2::Config>::rand(&mut rng);
|
||||
let optimised = p.clear_cofactor().into_group();
|
||||
let naive = g2::Parameters::mul_affine(&p, h_eff);
|
||||
let naive = g2::Config::mul_affine(&p, h_eff);
|
||||
assert_eq!(optimised, naive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ark_ec::bls12::{Bls12, Bls12Parameters, TwistType};
|
||||
use ark_ec::bls12::{Bls12, Bls12Config, TwistType};
|
||||
|
||||
use crate::{Fq, Fq12Config, Fq2Config, Fq6Config};
|
||||
|
||||
@@ -14,11 +14,11 @@ pub use self::{
|
||||
g2::{G2Affine, G2Projective},
|
||||
};
|
||||
|
||||
pub type Bls12_381 = Bls12<Parameters>;
|
||||
pub type Bls12_381 = Bls12<Config>;
|
||||
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl Bls12Parameters for Parameters {
|
||||
impl Bls12Config for Config {
|
||||
const X: &'static [u64] = &[0xd201000000010000];
|
||||
const X_IS_NEGATIVE: bool = true;
|
||||
const TWIST_TYPE: TwistType = TwistType::M;
|
||||
@@ -26,6 +26,6 @@ impl Bls12Parameters for Parameters {
|
||||
type Fp2Config = Fq2Config;
|
||||
type Fp6Config = Fq6Config;
|
||||
type Fp12Config = Fq12Config;
|
||||
type G1Parameters = self::g1::Parameters;
|
||||
type G2Parameters = self::g2::Parameters;
|
||||
type G1Config = self::g1::Config;
|
||||
type G2Config = self::g2::Config;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@ use ark_ec::{short_weierstrass::Affine, AffineRepr};
|
||||
use ark_ff::{BigInteger384, PrimeField};
|
||||
use ark_serialize::SerializationError;
|
||||
|
||||
use crate::{
|
||||
g1::Parameters as G1Parameters, g2::Parameters as G2Parameters, Fq, Fq2, G1Affine, G2Affine,
|
||||
};
|
||||
use crate::{g1::Config as G1Config, g2::Config as G2Config, Fq, Fq2, G1Affine, G2Affine};
|
||||
|
||||
pub const G1_SERIALIZED_SIZE: usize = 48;
|
||||
pub const G2_SERIALIZED_SIZE: usize = 96;
|
||||
@@ -91,7 +89,7 @@ pub(crate) fn read_fq_with_offset(
|
||||
|
||||
pub(crate) fn read_g1_compressed<R: ark_serialize::Read>(
|
||||
mut reader: R,
|
||||
) -> Result<Affine<G1Parameters>, ark_serialize::SerializationError> {
|
||||
) -> Result<Affine<G1Config>, ark_serialize::SerializationError> {
|
||||
let mut bytes = [0u8; G1_SERIALIZED_SIZE];
|
||||
reader
|
||||
.read_exact(&mut bytes)
|
||||
@@ -121,7 +119,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<G1Parameters>, ark_serialize::SerializationError> {
|
||||
) -> Result<Affine<G1Config>, ark_serialize::SerializationError> {
|
||||
let mut bytes = [0u8; 2 * G1_SERIALIZED_SIZE];
|
||||
reader
|
||||
.read_exact(&mut bytes)
|
||||
@@ -151,7 +149,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<G2Parameters>, ark_serialize::SerializationError> {
|
||||
) -> Result<Affine<G2Config>, ark_serialize::SerializationError> {
|
||||
let mut bytes = [0u8; G2_SERIALIZED_SIZE];
|
||||
reader
|
||||
.read_exact(&mut bytes)
|
||||
@@ -183,7 +181,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<G2Parameters>, ark_serialize::SerializationError> {
|
||||
) -> Result<Affine<G2Config>, ark_serialize::SerializationError> {
|
||||
let mut bytes = [0u8; 2 * G2_SERIALIZED_SIZE];
|
||||
reader
|
||||
.read_exact(&mut bytes)
|
||||
|
||||
@@ -3,5 +3,7 @@ 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>>;
|
||||
|
||||
@@ -3,5 +3,7 @@ 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>>;
|
||||
|
||||
@@ -1601,7 +1601,7 @@ fn test_fq2_doubling() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fq2_frobenius_map() {
|
||||
fn test_fq2_frobenius_map_in_place() {
|
||||
let mut a = Fq2::new(
|
||||
Fq::from(BigInt::new([
|
||||
0x2d0078036923ffc7,
|
||||
@@ -1620,7 +1620,7 @@ fn test_fq2_frobenius_map() {
|
||||
0x12d1137b8a6a837,
|
||||
])),
|
||||
);
|
||||
a.frobenius_map(0);
|
||||
a.frobenius_map_in_place(0);
|
||||
assert_eq!(
|
||||
a,
|
||||
Fq2::new(
|
||||
@@ -1642,7 +1642,7 @@ fn test_fq2_frobenius_map() {
|
||||
])),
|
||||
)
|
||||
);
|
||||
a.frobenius_map(1);
|
||||
a.frobenius_map_in_place(1);
|
||||
assert_eq!(
|
||||
a,
|
||||
Fq2::new(
|
||||
@@ -1664,7 +1664,7 @@ fn test_fq2_frobenius_map() {
|
||||
])),
|
||||
)
|
||||
);
|
||||
a.frobenius_map(1);
|
||||
a.frobenius_map_in_place(1);
|
||||
assert_eq!(
|
||||
a,
|
||||
Fq2::new(
|
||||
@@ -1686,7 +1686,7 @@ fn test_fq2_frobenius_map() {
|
||||
])),
|
||||
)
|
||||
);
|
||||
a.frobenius_map(2);
|
||||
a.frobenius_map_in_place(2);
|
||||
assert_eq!(
|
||||
a,
|
||||
Fq2::new(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-bn254"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "The BN254 pairing-friendly elliptic curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,18 +13,20 @@ license = "MIT/Apache-2.0"
|
||||
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-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 }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-serialize = { version="^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version="^0.3.0", default-features = false }
|
||||
ark-algebra-bench-templates = { version = "^0.3.0", 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-algebra-bench-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
|
||||
[features]
|
||||
default = [ "curve" ]
|
||||
std = [ "ark-std/std", "ark-ff/std", "ark-ec/std" ]
|
||||
r1cs = [ "ark-r1cs-std" ]
|
||||
|
||||
curve = [ "scalar_field" ]
|
||||
scalar_field = []
|
||||
|
||||
11
bn254/src/constraints/curves.rs
Normal file
11
bn254/src/constraints/curves.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar;
|
||||
|
||||
use crate::{constraints::FBaseVar, g1::Config};
|
||||
|
||||
/// A group element in the Bn254 prime-order group.
|
||||
pub type GVar = ProjectiveVar<Config, FBaseVar>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
ark_curve_constraint_tests::curves::sw_test::<Config, GVar>().unwrap();
|
||||
}
|
||||
11
bn254/src/constraints/fields.rs
Normal file
11
bn254/src/constraints/fields.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use ark_r1cs_std::fields::fp::FpVar;
|
||||
|
||||
use crate::fq::Fq;
|
||||
|
||||
/// A variable that is the R1CS equivalent of `crate::Fq`.
|
||||
pub type FBaseVar = FpVar<Fq>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
ark_curve_constraint_tests::fields::field_test::<_, _, FBaseVar>().unwrap();
|
||||
}
|
||||
107
bn254/src/constraints/mod.rs
Normal file
107
bn254/src/constraints/mod.rs
Normal file
@@ -0,0 +1,107 @@
|
||||
//! This module implements the R1CS equivalent of `ark_bn254`.
|
||||
//!
|
||||
//! It implements field variables for `crate::Fq`,
|
||||
//! and group variables for `crate::G1Projective`.
|
||||
//!
|
||||
//! The field underlying these constraints is `crate::Fq`.
|
||||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
//! One can perform standard algebraic operations on `FBaseVar`:
|
||||
//!
|
||||
//! ```
|
||||
//! # fn main() -> Result<(), ark_relations::r1cs::SynthesisError> {
|
||||
//! use ark_std::UniformRand;
|
||||
//! use ark_relations::r1cs::*;
|
||||
//! use ark_r1cs_std::prelude::*;
|
||||
//! use ark_bn254::{*, constraints::*};
|
||||
//!
|
||||
//! let cs = ConstraintSystem::<Fq>::new_ref();
|
||||
//! // This rng is just for test purposes; do not use it
|
||||
//! // in real applications.
|
||||
//! let mut rng = ark_std::test_rng();
|
||||
//!
|
||||
//! // Generate some random `Fq` elements.
|
||||
//! let a_native = Fq::rand(&mut rng);
|
||||
//! let b_native = Fq::rand(&mut rng);
|
||||
//!
|
||||
//! // Allocate `a_native` and `b_native` as witness variables in `cs`.
|
||||
//! let a = FBaseVar::new_witness(ark_relations::ns!(cs, "generate_a"), || Ok(a_native))?;
|
||||
//! let b = FBaseVar::new_witness(ark_relations::ns!(cs, "generate_b"), || Ok(b_native))?;
|
||||
//!
|
||||
//! // Allocate `a_native` and `b_native` as constants in `cs`. This does not add any
|
||||
//! // constraints or variables.
|
||||
//! let a_const = FBaseVar::new_constant(ark_relations::ns!(cs, "a_as_constant"), a_native)?;
|
||||
//! let b_const = FBaseVar::new_constant(ark_relations::ns!(cs, "b_as_constant"), b_native)?;
|
||||
//!
|
||||
//! let one = FBaseVar::one();
|
||||
//! let zero = FBaseVar::zero();
|
||||
//!
|
||||
//! // Sanity check one + one = two
|
||||
//! let two = &one + &one + &zero;
|
||||
//! two.enforce_equal(&one.double()?)?;
|
||||
//!
|
||||
//! assert!(cs.is_satisfied()?);
|
||||
//!
|
||||
//! // Check that the value of &a + &b is correct.
|
||||
//! assert_eq!((&a + &b).value()?, a_native + &b_native);
|
||||
//!
|
||||
//! // Check that the value of &a * &b is correct.
|
||||
//! assert_eq!((&a * &b).value()?, a_native * &b_native);
|
||||
//!
|
||||
//! // Check that operations on variables and constants are equivalent.
|
||||
//! (&a + &b).enforce_equal(&(&a_const + &b_const))?;
|
||||
//! assert!(cs.is_satisfied()?);
|
||||
//! # Ok(())
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! One can also perform standard algebraic operations on `GVar`:
|
||||
//!
|
||||
//! ```
|
||||
//! # fn main() -> Result<(), ark_relations::r1cs::SynthesisError> {
|
||||
//! # use ark_std::UniformRand;
|
||||
//! # use ark_relations::r1cs::*;
|
||||
//! # use ark_r1cs_std::prelude::*;
|
||||
//! # use ark_bn254::{*, constraints::*};
|
||||
//!
|
||||
//! # let cs = ConstraintSystem::<Fq>::new_ref();
|
||||
//! # let mut rng = ark_std::test_rng();
|
||||
//!
|
||||
//! // Generate some random `G1Projective` elements.
|
||||
//! let a_native = G1Projective::rand(&mut rng);
|
||||
//! let b_native = G1Projective::rand(&mut rng);
|
||||
//!
|
||||
//! // Allocate `a_native` and `b_native` as witness variables in `cs`.
|
||||
//! let a = GVar::new_witness(ark_relations::ns!(cs, "a"), || Ok(a_native))?;
|
||||
//! let b = GVar::new_witness(ark_relations::ns!(cs, "b"), || Ok(b_native))?;
|
||||
//!
|
||||
//! // Allocate `a_native` and `b_native` as constants in `cs`. This does not add any
|
||||
//! // constraints or variables.
|
||||
//! let a_const = GVar::new_constant(ark_relations::ns!(cs, "a_as_constant"), a_native)?;
|
||||
//! let b_const = GVar::new_constant(ark_relations::ns!(cs, "b_as_constant"), b_native)?;
|
||||
//!
|
||||
//! // This returns the identity.
|
||||
//! let zero = GVar::zero();
|
||||
//!
|
||||
//! // Sanity check one + one = two
|
||||
//! let two_a = &a + &a + &zero;
|
||||
//! two_a.enforce_equal(&a.double()?)?;
|
||||
//!
|
||||
//! assert!(cs.is_satisfied()?);
|
||||
//!
|
||||
//! // Check that the value of &a + &b is correct.
|
||||
//! assert_eq!((&a + &b).value()?, a_native + &b_native);
|
||||
//!
|
||||
//! // Check that operations on variables and constants are equivalent.
|
||||
//! (&a + &b).enforce_equal(&(&a_const + &b_const))?;
|
||||
//! assert!(cs.is_satisfied()?);
|
||||
//! # Ok(())
|
||||
//! # }
|
||||
//! ```
|
||||
|
||||
mod curves;
|
||||
mod fields;
|
||||
|
||||
pub use curves::*;
|
||||
pub use fields::*;
|
||||
@@ -7,11 +7,11 @@ use ark_ff::{Field, MontFp, Zero};
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
pub type G1Affine = Affine<Parameters>;
|
||||
pub type G1Affine = Affine<Config>;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -22,7 +22,7 @@ impl CurveConfig for Parameters {
|
||||
const COFACTOR_INV: Fr = Fr::ONE;
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = 0
|
||||
const COEFF_A: Fq = Fq::ZERO;
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ use ark_ff::{Field, MontFp, Zero};
|
||||
|
||||
use crate::{Fq, Fq2, Fr};
|
||||
|
||||
pub type G2Affine = Affine<Parameters>;
|
||||
pub type G2Affine = Affine<Config>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq2;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -30,7 +30,7 @@ impl CurveConfig for Parameters {
|
||||
MontFp!("10944121435919637613327163357776759465618812564592884533313067514031822496649");
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = [0, 0]
|
||||
const COEFF_A: Fq2 = Fq2::ZERO;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use ark_ec::{
|
||||
bn,
|
||||
bn::{Bn, BnParameters, TwistType},
|
||||
bn::{Bn, BnConfig, TwistType},
|
||||
};
|
||||
use ark_ff::MontFp;
|
||||
|
||||
@@ -12,9 +12,9 @@ pub mod g2;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl BnParameters for Parameters {
|
||||
impl BnConfig for Config {
|
||||
const X: &'static [u64] = &[4965661367192848881];
|
||||
/// `x` is positive.
|
||||
const X_IS_NEGATIVE: bool = false;
|
||||
@@ -37,13 +37,13 @@ impl BnParameters for Parameters {
|
||||
type Fp2Config = Fq2Config;
|
||||
type Fp6Config = Fq6Config;
|
||||
type Fp12Config = Fq12Config;
|
||||
type G1Parameters = g1::Parameters;
|
||||
type G2Parameters = g2::Parameters;
|
||||
type G1Config = g1::Config;
|
||||
type G2Config = g2::Config;
|
||||
}
|
||||
|
||||
pub type Bn254 = Bn<Parameters>;
|
||||
pub type Bn254 = Bn<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>;
|
||||
pub type G1Affine = bn::G1Affine<Config>;
|
||||
pub type G1Projective = bn::G1Projective<Config>;
|
||||
pub type G2Affine = bn::G2Affine<Config>;
|
||||
pub type G2Projective = bn::G2Projective<Config>;
|
||||
|
||||
@@ -41,3 +41,6 @@ mod fields;
|
||||
pub use curves::*;
|
||||
|
||||
pub use fields::*;
|
||||
|
||||
#[cfg(feature = "r1cs")]
|
||||
pub mod constraints;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-bw6-761"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "The BW6-761 pairing-friendly elliptic curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,15 +13,15 @@ license = "MIT/Apache-2.0"
|
||||
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" ] }
|
||||
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-bls12-377 = { version = "0.4.0-alpha", path = "../bls12_377", default-features = false, features = [ "base_field" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-serialize = { version="^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version="^0.3.0", default-features = false }
|
||||
ark-algebra-bench-templates = { version="^0.3.0", 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-algebra-bench-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
@@ -6,13 +6,13 @@ use ark_ff::{Field, MontFp};
|
||||
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
pub type G1Affine = Affine<Parameters>;
|
||||
pub type G1Projective = Projective<Parameters>;
|
||||
pub type G1Affine = Affine<Config>;
|
||||
pub type G1Projective = Projective<Config>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -33,7 +33,7 @@ impl CurveConfig for Parameters {
|
||||
const COFACTOR_INV: Fr = MontFp!("91141326767669940707819291241958318717982251277713150053234367522357946997763584490607453720072232540829942217804");
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = 0
|
||||
const COEFF_A: Fq = Fq::ZERO;
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ use ark_ff::{Field, MontFp};
|
||||
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
pub type G2Affine = Affine<Parameters>;
|
||||
pub type G2Projective = Projective<Parameters>;
|
||||
pub type G2Affine = Affine<Config>;
|
||||
pub type G2Projective = Projective<Config>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -33,7 +33,7 @@ impl CurveConfig for Parameters {
|
||||
const COFACTOR_INV: Fr = MontFp!("214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124");
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = 0
|
||||
const COEFF_A: Fq = Fq::ZERO;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use ark_ec::{
|
||||
bw6,
|
||||
bw6::{BW6Parameters, TwistType, BW6},
|
||||
bw6::{BW6Config, TwistType, BW6},
|
||||
};
|
||||
use ark_ff::{biginteger::BigInteger768 as BigInteger, BigInt};
|
||||
|
||||
@@ -13,9 +13,9 @@ pub mod g2;
|
||||
mod tests;
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl BW6Parameters for Parameters {
|
||||
impl BW6Config for Config {
|
||||
const X: BigInteger = BigInt::new([
|
||||
0x8508c00000000001,
|
||||
0x0,
|
||||
@@ -50,13 +50,13 @@ impl BW6Parameters for Parameters {
|
||||
type Fp = Fq;
|
||||
type Fp3Config = Fq3Config;
|
||||
type Fp6Config = Fq6Config;
|
||||
type G1Parameters = g1::Parameters;
|
||||
type G2Parameters = g2::Parameters;
|
||||
type G1Config = g1::Config;
|
||||
type G2Config = g2::Config;
|
||||
}
|
||||
|
||||
pub type BW6_761 = BW6<Parameters>;
|
||||
pub type BW6_761 = BW6<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>;
|
||||
pub type G1Affine = bw6::G1Affine<Config>;
|
||||
pub type G1Projective = bw6::G1Projective<Config>;
|
||||
pub type G2Affine = bw6::G2Affine<Config>;
|
||||
pub type G2Projective = bw6::G2Projective<Config>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-cp6-782"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "The CP6-782 pairing-friendly elliptic curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,16 +13,16 @@ license = "MIT/Apache-2.0"
|
||||
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" ] }
|
||||
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-bls12-377 = { version = "0.4.0-alpha", path = "../bls12_377", default-features = false, features = [ "base_field" ] }
|
||||
itertools = { version = "0.10", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "0.4.0-alpha", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-bench-templates = { version="^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-algebra-bench-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
@@ -9,8 +9,8 @@ use ark_std::vec::Vec;
|
||||
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
pub type G1Affine = Affine<Parameters>;
|
||||
pub type G1Projective = Projective<Parameters>;
|
||||
pub type G1Affine = Affine<Config>;
|
||||
pub type G1Projective = Projective<Config>;
|
||||
|
||||
#[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 Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -76,7 +76,7 @@ impl CurveConfig for Parameters {
|
||||
const COFACTOR_INV: Fr = MontFp!("163276846538158998893990986356139314746223949404500031940624325017036397274793417940375498603127780919653358641788");
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = 5
|
||||
const COEFF_A: Fq = MontFp!("5");
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ use ark_std::vec::Vec;
|
||||
|
||||
use crate::{Fq, Fq3, Fr};
|
||||
|
||||
pub type G2Affine = Affine<Parameters>;
|
||||
pub type G2Projective = Projective<Parameters>;
|
||||
pub type G2Affine = Affine<Config>;
|
||||
pub type G2Projective = Projective<Config>;
|
||||
|
||||
#[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 Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq3;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -100,7 +100,7 @@ impl CurveConfig for Parameters {
|
||||
const COFACTOR_INV: Fr = MontFp!("45586359457219724873147353901735745013467692594291916855200979604570630929674383405372210802279573887880950375598");
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = (0, 0, COEFF_A * TWIST^2) = (0, 0, 5)
|
||||
const COEFF_A: Fq3 = Fq3::new(Fq::ZERO, Fq::ZERO, MontFp!("5"));
|
||||
|
||||
|
||||
@@ -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::Parameters::COEFF_A;
|
||||
let old_rx_square_3_a = old_rx_square_3 + &g2::Config::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(3);
|
||||
elt_q3.frobenius_map_in_place(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(1);
|
||||
alpha.frobenius_map_in_place(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(1);
|
||||
elt_q.frobenius_map_in_place(1);
|
||||
|
||||
let w1_part = elt_q.cyclotomic_exp(&FINAL_EXPONENT_LAST_CHUNK_W1);
|
||||
let w0_part = if FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-curve-constraint-tests"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "A library for testing constraints for finite fields, elliptic curves, and pairings"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,12 +13,12 @@ license = "MIT/Apache-2.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
ark-std = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-ff = { version = "^0.3.0", default-features = false }
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-r1cs-std = { version = "^0.3.0", default-features = false }
|
||||
ark-ec = { version = "^0.3.0", default-features = false }
|
||||
ark-std = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-serialize = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-ff = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-relations = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-r1cs-std = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-ec = { version = "0.4.0-alpha", default-features = false }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
@@ -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(i);
|
||||
a.frobenius_map_in_place(i);
|
||||
|
||||
assert_eq!(a_gadget.value()?, a);
|
||||
}
|
||||
@@ -321,8 +321,10 @@ pub mod curves {
|
||||
*limb = u64::MAX;
|
||||
}
|
||||
|
||||
let modulus_last_limb_bits = <C::ScalarField as PrimeField>::MODULUS_BIT_SIZE % 64;
|
||||
*max.last_mut().unwrap() >>= 64 - modulus_last_limb_bits;
|
||||
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 scalars = [
|
||||
C::ScalarField::rand(&mut rng)
|
||||
.into_bigint()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-curve25519"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "The curve25519 Montgomery curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,15 +13,15 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
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 }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
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]
|
||||
|
||||
@@ -3,5 +3,7 @@ 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>>;
|
||||
|
||||
@@ -3,5 +3,7 @@ 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>>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-ed25519"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "The ed25519 twisted Edwards curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,15 +13,16 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
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.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
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]
|
||||
|
||||
@@ -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<EdwardsParameters, FqVar>;
|
||||
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
|
||||
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ use ark_ff::MontFp;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub type EdwardsAffine = Affine<EdwardsParameters>;
|
||||
pub type EdwardsProjective = Projective<EdwardsParameters>;
|
||||
pub type EdwardsAffine = Affine<EdwardsConfig>;
|
||||
pub type EdwardsProjective = Projective<EdwardsConfig>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct EdwardsParameters;
|
||||
pub struct EdwardsConfig;
|
||||
|
||||
impl CurveConfig for EdwardsParameters {
|
||||
impl CurveConfig for EdwardsConfig {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -27,7 +27,7 @@ impl CurveConfig for EdwardsParameters {
|
||||
MontFp!("2713877091499598330239944961141122840321418634767465352250731601857045344121");
|
||||
}
|
||||
|
||||
impl TECurveConfig for EdwardsParameters {
|
||||
impl TECurveConfig for EdwardsConfig {
|
||||
/// COEFF_A = -1
|
||||
const COEFF_A: Fq = MontFp!("-1");
|
||||
|
||||
@@ -38,7 +38,7 @@ impl TECurveConfig for EdwardsParameters {
|
||||
/// Standard generators from <https://neuromancer.sk/std/other/Ed25519>.
|
||||
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
|
||||
|
||||
type MontCurveConfig = EdwardsParameters;
|
||||
type MontCurveConfig = EdwardsConfig;
|
||||
|
||||
/// Multiplication by `a` is just negation.
|
||||
#[inline(always)]
|
||||
@@ -48,7 +48,7 @@ impl TECurveConfig for EdwardsParameters {
|
||||
}
|
||||
|
||||
// We want to emphasize that this Montgomery curve is not Curve25519.
|
||||
impl MontCurveConfig for EdwardsParameters {
|
||||
impl MontCurveConfig for EdwardsConfig {
|
||||
/// COEFF_A = 486662
|
||||
const COEFF_A: Fq = MontFp!("486662");
|
||||
|
||||
@@ -57,7 +57,7 @@ impl MontCurveConfig for EdwardsParameters {
|
||||
const COEFF_B: Fq =
|
||||
MontFp!("57896044618658097711785492504343953926634992332820282019728792003956564333285");
|
||||
|
||||
type TECurveConfig = EdwardsParameters;
|
||||
type TECurveConfig = EdwardsConfig;
|
||||
}
|
||||
|
||||
/// GENERATOR_X =
|
||||
|
||||
@@ -1,7 +1 @@
|
||||
use ark_ff::fields::{Fp256, MontBackend, MontConfig};
|
||||
|
||||
#[derive(MontConfig)]
|
||||
#[modulus = "57896044618658097711785492504343953926634992332820282019728792003956564819949"]
|
||||
#[generator = "2"]
|
||||
pub struct FqConfig;
|
||||
pub type Fq = Fp256<MontBackend<FqConfig, 4>>;
|
||||
pub use ark_curve25519::{Fq, FqConfig};
|
||||
|
||||
@@ -1,7 +1 @@
|
||||
use ark_ff::fields::{Fp256, MontBackend, MontConfig};
|
||||
|
||||
#[derive(MontConfig)]
|
||||
#[modulus = "7237005577332262213973186563042994240857116359379907606001950938285454250989"]
|
||||
#[generator = "2"]
|
||||
pub struct FrConfig;
|
||||
pub type Fr = Fp256<MontBackend<FrConfig, 4>>;
|
||||
pub use ark_curve25519::{Fr, FrConfig};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-ed-on-bls12-377"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "A Twisted Edwards curve defined over the scalar field of the BLS12-377 curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,16 +13,16 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
ark-bls12-377 = { version = "^0.3.0", path = "../bls12_377", default-features = false, features = [ "scalar_field" ] }
|
||||
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-bls12-377 = { version = "0.4.0-alpha", path = "../bls12_377", default-features = false, features = [ "scalar_field" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
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]
|
||||
|
||||
@@ -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<EdwardsParameters, FqVar>;
|
||||
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
|
||||
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ use crate::{fq::Fq, fr::Fr};
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub type EdwardsAffine = Affine<EdwardsParameters>;
|
||||
pub type EdwardsProjective = Projective<EdwardsParameters>;
|
||||
pub type EdwardsAffine = Affine<EdwardsConfig>;
|
||||
pub type EdwardsProjective = Projective<EdwardsConfig>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct EdwardsParameters;
|
||||
pub struct EdwardsConfig;
|
||||
|
||||
impl CurveConfig for EdwardsParameters {
|
||||
impl CurveConfig for EdwardsConfig {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -28,7 +28,7 @@ impl CurveConfig for EdwardsParameters {
|
||||
MontFp!("527778859339273151515551558673846658209717731602102048798421311598680340096");
|
||||
}
|
||||
|
||||
impl TECurveConfig for EdwardsParameters {
|
||||
impl TECurveConfig for EdwardsConfig {
|
||||
/// COEFF_A = -1
|
||||
const COEFF_A: Fq = MontFp!("-1");
|
||||
|
||||
@@ -38,7 +38,7 @@ impl TECurveConfig for EdwardsParameters {
|
||||
/// Generated randomly
|
||||
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
|
||||
|
||||
type MontCurveConfig = EdwardsParameters;
|
||||
type MontCurveConfig = EdwardsConfig;
|
||||
|
||||
/// Multiplication by `a` is just negation.
|
||||
/// Is `a` 1 or -1?
|
||||
@@ -48,7 +48,7 @@ impl TECurveConfig for EdwardsParameters {
|
||||
}
|
||||
}
|
||||
|
||||
impl MontCurveConfig for EdwardsParameters {
|
||||
impl MontCurveConfig for EdwardsConfig {
|
||||
/// COEFF_A = 0x8D26E3FADA9010A26949031ECE3971B93952AD84D4753DDEDB748DA37E8F552
|
||||
/// = 3990301581132929505568273333084066329187552697088022219156688740916631500114
|
||||
const COEFF_A: Fq =
|
||||
@@ -59,7 +59,7 @@ impl MontCurveConfig for EdwardsParameters {
|
||||
const COEFF_B: Fq =
|
||||
MontFp!("4454160168295440918680551605697480202188346638066041608778544715000777738925");
|
||||
|
||||
type TECurveConfig = EdwardsParameters;
|
||||
type TECurveConfig = EdwardsConfig;
|
||||
}
|
||||
|
||||
/// GENERATOR_X =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-ed-on-bls12-381"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "A Twisted Edwards curve defined over the scalar field of the BLS12-381 curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,17 +13,17 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
ark-bls12-381 = { version = "^0.3.0", path = "../bls12_381", default-features = false, features = [ "scalar_field" ] }
|
||||
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-bls12-381 = { version = "0.4.0-alpha", path = "../bls12_381", default-features = false, features = [ "scalar_field" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-bench-templates = { version = "^0.3.0", default-features = false }
|
||||
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-algebra-bench-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-curve-constraint-tests = { path = "../curve-constraint-tests", default-features = false }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -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<JubjubParameters, FqVar>;
|
||||
pub type EdwardsVar = AffineVar<JubjubConfig, FqVar>;
|
||||
|
||||
/// A variable that is the R1CS equivalent of `crate::SWProjective`
|
||||
pub type SWVar = ProjectiveVar<JubjubParameters, FqVar>;
|
||||
pub type SWVar = ProjectiveVar<JubjubConfig, FqVar>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
|
||||
@@ -10,10 +10,10 @@ use crate::{Fq, Fr};
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub type EdwardsAffine = Affine<JubjubParameters>;
|
||||
pub type EdwardsProjective = Projective<JubjubParameters>;
|
||||
pub type SWAffine = short_weierstrass::Affine<JubjubParameters>;
|
||||
pub type SWProjective = short_weierstrass::Projective<JubjubParameters>;
|
||||
pub type EdwardsAffine = Affine<JubjubConfig>;
|
||||
pub type EdwardsProjective = Projective<JubjubConfig>;
|
||||
pub type SWAffine = short_weierstrass::Affine<JubjubConfig>;
|
||||
pub type SWProjective = short_weierstrass::Projective<JubjubConfig>;
|
||||
|
||||
/// `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<JubjubParameters>;
|
||||
/// [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 JubjubParameters;
|
||||
pub type EdwardsParameters = JubjubParameters;
|
||||
pub type SWParameters = JubjubParameters;
|
||||
pub struct JubjubConfig;
|
||||
pub type EdwardsConfig = JubjubConfig;
|
||||
pub type SWConfig = JubjubConfig;
|
||||
|
||||
impl CurveConfig for JubjubParameters {
|
||||
impl CurveConfig for JubjubConfig {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -66,7 +66,7 @@ impl CurveConfig for JubjubParameters {
|
||||
MontFp!("819310549611346726241370945440405716213240158234039660170669895299022906775");
|
||||
}
|
||||
|
||||
impl TECurveConfig for JubjubParameters {
|
||||
impl TECurveConfig for JubjubConfig {
|
||||
/// COEFF_A = -1
|
||||
const COEFF_A: Fq = MontFp!("-1");
|
||||
|
||||
@@ -77,7 +77,7 @@ impl TECurveConfig for JubjubParameters {
|
||||
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
|
||||
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
|
||||
|
||||
type MontCurveConfig = JubjubParameters;
|
||||
type MontCurveConfig = JubjubConfig;
|
||||
|
||||
/// Multiplication by `a` is simply negation here.
|
||||
#[inline(always)]
|
||||
@@ -86,14 +86,14 @@ impl TECurveConfig for JubjubParameters {
|
||||
}
|
||||
}
|
||||
|
||||
impl MontCurveConfig for JubjubParameters {
|
||||
impl MontCurveConfig for JubjubConfig {
|
||||
/// COEFF_A = 40962
|
||||
const COEFF_A: Fq = MontFp!("40962");
|
||||
|
||||
/// COEFF_B = -40964
|
||||
const COEFF_B: Fq = MontFp!("-40964");
|
||||
|
||||
type TECurveConfig = JubjubParameters;
|
||||
type TECurveConfig = JubjubConfig;
|
||||
}
|
||||
|
||||
const GENERATOR_X: Fq =
|
||||
@@ -102,7 +102,7 @@ const GENERATOR_X: Fq =
|
||||
const GENERATOR_Y: Fq =
|
||||
MontFp!("13262374693698910701929044844600465831413122818447359594527400194675274060458");
|
||||
|
||||
impl SWCurveConfig for JubjubParameters {
|
||||
impl SWCurveConfig for JubjubConfig {
|
||||
/// COEFF_A = 52296097456646850916096512823759002727550416093741407922227928430486925478210
|
||||
const COEFF_A: Self::BaseField =
|
||||
MontFp!("52296097456646850916096512823759002727550416093741407922227928430486925478210");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-ed-on-bls12-381-bandersnatch"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
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"
|
||||
@@ -11,16 +11,16 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
ark-bls12-381 = { version = "^0.3.0", path = "../bls12_381", default-features = false, features = [ "scalar_field" ] }
|
||||
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-bls12-381 = { version = "0.4.0-alpha", path = "../bls12_381", default-features = false, features = [ "scalar_field" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
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]
|
||||
|
||||
@@ -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::BandersnatchParameters`.
|
||||
pub type EdwardsVar = AffineVar<BandersnatchParameters, 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::SWProjective`
|
||||
pub type SWVar = ProjectiveVar<BandersnatchParameters, FqVar>;
|
||||
pub type SWVar = ProjectiveVar<BandersnatchConfig, FqVar>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
|
||||
@@ -10,11 +10,11 @@ use crate::{Fq, Fr};
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub type EdwardsAffine = Affine<BandersnatchParameters>;
|
||||
pub type EdwardsProjective = Projective<BandersnatchParameters>;
|
||||
pub type EdwardsAffine = Affine<BandersnatchConfig>;
|
||||
pub type EdwardsProjective = Projective<BandersnatchConfig>;
|
||||
|
||||
pub type SWAffine = short_weierstrass::Affine<BandersnatchParameters>;
|
||||
pub type SWProjective = short_weierstrass::Projective<BandersnatchParameters>;
|
||||
pub type SWAffine = short_weierstrass::Affine<BandersnatchConfig>;
|
||||
pub type SWProjective = short_weierstrass::Projective<BandersnatchConfig>;
|
||||
|
||||
/// `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<BandersnatchParameters>;
|
||||
/// 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 BandersnatchParameters;
|
||||
pub struct BandersnatchConfig;
|
||||
|
||||
pub type EdwardsParameters = BandersnatchParameters;
|
||||
pub type SWParameters = BandersnatchParameters;
|
||||
pub type EdwardsConfig = BandersnatchConfig;
|
||||
pub type SWConfig = BandersnatchConfig;
|
||||
|
||||
impl CurveConfig for BandersnatchParameters {
|
||||
impl CurveConfig for BandersnatchConfig {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -67,7 +67,7 @@ impl CurveConfig for BandersnatchParameters {
|
||||
MontFp!("9831726595336160714896451345284868594481866920080427688839802480047265754601");
|
||||
}
|
||||
|
||||
impl TECurveConfig for BandersnatchParameters {
|
||||
impl TECurveConfig for BandersnatchConfig {
|
||||
/// COEFF_A = -5
|
||||
const COEFF_A: Fq = MontFp!("-5");
|
||||
|
||||
@@ -79,7 +79,7 @@ impl TECurveConfig for BandersnatchParameters {
|
||||
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
|
||||
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(TE_GENERATOR_X, TE_GENERATOR_Y);
|
||||
|
||||
type MontCurveConfig = BandersnatchParameters;
|
||||
type MontCurveConfig = BandersnatchConfig;
|
||||
|
||||
/// Multiplication by `a` is multiply by `-5`.
|
||||
#[inline(always)]
|
||||
@@ -88,7 +88,7 @@ impl TECurveConfig for BandersnatchParameters {
|
||||
}
|
||||
}
|
||||
|
||||
impl MontCurveConfig for BandersnatchParameters {
|
||||
impl MontCurveConfig for BandersnatchConfig {
|
||||
/// COEFF_A = 29978822694968839326280996386011761570173833766074948509196803838190355340952
|
||||
const COEFF_A: Fq =
|
||||
MontFp!("29978822694968839326280996386011761570173833766074948509196803838190355340952");
|
||||
@@ -97,7 +97,7 @@ impl MontCurveConfig for BandersnatchParameters {
|
||||
const COEFF_B: Fq =
|
||||
MontFp!("25465760566081946422412445027709227188579564747101592991722834452325077642517");
|
||||
|
||||
type TECurveConfig = BandersnatchParameters;
|
||||
type TECurveConfig = BandersnatchConfig;
|
||||
}
|
||||
|
||||
// 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 BandersnatchParameters {
|
||||
impl SWCurveConfig for BandersnatchConfig {
|
||||
/// COEFF_A = 10773120815616481058602537765553212789256758185246796157495669123169359657269
|
||||
const COEFF_A: Self::BaseField =
|
||||
MontFp!("10773120815616481058602537765553212789256758185246796157495669123169359657269");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-ed-on-bn254"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "A Twisted Edwards curve defined over the scalar field of the BN254 curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,16 +13,16 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
ark-bn254 = { version = "^0.3.0", path = "../bn254", default-features = false, features = [ "scalar_field" ] }
|
||||
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-bn254 = { version = "0.4.0-alpha", path = "../bn254", default-features = false, features = [ "scalar_field" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
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]
|
||||
|
||||
@@ -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<EdwardsParameters, FqVar>;
|
||||
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
|
||||
@@ -9,8 +9,8 @@ use crate::{Fq, Fr};
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub type EdwardsAffine = Affine<EdwardsParameters>;
|
||||
pub type EdwardsProjective = Projective<EdwardsParameters>;
|
||||
pub type EdwardsAffine = Affine<EdwardsConfig>;
|
||||
pub type EdwardsProjective = Projective<EdwardsConfig>;
|
||||
|
||||
/// `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<EdwardsParameters>;
|
||||
///
|
||||
/// q = 21888242871839275222246405745257275088548364400416034343698204186575808495617
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct EdwardsParameters;
|
||||
pub struct EdwardsConfig;
|
||||
|
||||
impl CurveConfig for EdwardsParameters {
|
||||
impl CurveConfig for EdwardsConfig {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -35,7 +35,7 @@ impl CurveConfig for EdwardsParameters {
|
||||
MontFp!("2394026564107420727433200628387514462817212225638746351800188703329891451411");
|
||||
}
|
||||
|
||||
impl TECurveConfig for EdwardsParameters {
|
||||
impl TECurveConfig for EdwardsConfig {
|
||||
/// COEFF_A = 1
|
||||
const COEFF_A: Fq = Fq::ONE;
|
||||
|
||||
@@ -52,16 +52,16 @@ impl TECurveConfig for EdwardsParameters {
|
||||
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
|
||||
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
|
||||
|
||||
type MontCurveConfig = EdwardsParameters;
|
||||
type MontCurveConfig = EdwardsConfig;
|
||||
}
|
||||
|
||||
impl MontCurveConfig for EdwardsParameters {
|
||||
impl MontCurveConfig for EdwardsConfig {
|
||||
/// COEFF_A = 168698
|
||||
const COEFF_A: Fq = MontFp!("168698");
|
||||
/// COEFF_B = 168700
|
||||
const COEFF_B: Fq = MontFp!("168700");
|
||||
|
||||
type TECurveConfig = EdwardsParameters;
|
||||
type TECurveConfig = EdwardsConfig;
|
||||
}
|
||||
|
||||
const GENERATOR_X: Fq =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-ed-on-bw6-761"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "A Twisted Edwards curve defined over the scalar field of the BW6-761 curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,13 +13,13 @@ license = "MIT/Apache-2.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
ark-ed-on-cp6-782 = { version = "^0.3.0", path = "../ed_on_cp6_782", default-features = false }
|
||||
ark-ed-on-cp6-782 = { version = "0.4.0-alpha", path = "../ed_on_cp6_782", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-r1cs-std = { version = "^0.3.0", default-features = false }
|
||||
ark-ff = { version = "^0.3.0", default-features = false }
|
||||
ark-std = { version = "^0.3.0", default-features = false }
|
||||
ark-relations = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-r1cs-std = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-ff = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-std = { version = "0.4.0-alpha", default-features = false }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-ed-on-cp6-782"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "A Twisted Edwards curve defined over the scalar field of the CP6-782 curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,16 +13,16 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
ark-bls12-377 = { version = "^0.3.0", path = "../bls12_377", default-features = false, features = [ "base_field" ] }
|
||||
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-bls12-377 = { version = "0.4.0-alpha", path = "../bls12_377", default-features = false, features = [ "base_field" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
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]
|
||||
|
||||
@@ -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<EdwardsParameters, FqVar>;
|
||||
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
|
||||
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ use crate::{Fq, Fr};
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub type EdwardsAffine = Affine<EdwardsParameters>;
|
||||
pub type EdwardsProjective = Projective<EdwardsParameters>;
|
||||
pub type EdwardsAffine = Affine<EdwardsConfig>;
|
||||
pub type EdwardsProjective = Projective<EdwardsConfig>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct EdwardsParameters;
|
||||
pub struct EdwardsConfig;
|
||||
|
||||
impl CurveConfig for EdwardsParameters {
|
||||
impl CurveConfig for EdwardsConfig {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -27,7 +27,7 @@ impl CurveConfig for EdwardsParameters {
|
||||
const COFACTOR_INV: Fr = MontFp!("12124894969357926281749346891948134384518445910386624712788431705725441736421489799867521238554906438478484045560");
|
||||
}
|
||||
|
||||
impl TECurveConfig for EdwardsParameters {
|
||||
impl TECurveConfig for EdwardsConfig {
|
||||
/// COEFF_A = -1 =
|
||||
const COEFF_A: Fq = MontFp!("-1");
|
||||
|
||||
@@ -37,7 +37,7 @@ impl TECurveConfig for EdwardsParameters {
|
||||
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
|
||||
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
|
||||
|
||||
type MontCurveConfig = EdwardsParameters;
|
||||
type MontCurveConfig = EdwardsConfig;
|
||||
|
||||
/// Multiplication by `a` is just negation.
|
||||
#[inline(always)]
|
||||
@@ -46,14 +46,14 @@ impl TECurveConfig for EdwardsParameters {
|
||||
}
|
||||
}
|
||||
|
||||
impl MontCurveConfig for EdwardsParameters {
|
||||
impl MontCurveConfig for EdwardsConfig {
|
||||
/// COEFF_A = 0x95D53EB3F6AC3F7A53C26020144439DC6073BCAE513E03FD06B6B3BAA390F25E51534B26719E33F4CD906D4DA9B535
|
||||
const COEFF_A: Fq = MontFp!("90083623084271891037116870487743067984710080209539149685414147055329063590616489392386084989619674926965747987765");
|
||||
|
||||
/// COEFF_B = 0x118650763CE64AB4BE743604C8D05013DC2663652A3D58B21ECAB7BFF65B70DB8BA09F9098E61CC903B2F92B2564ACA
|
||||
const COEFF_B: Fq = MontFp!("168580802928697202973535863207150465551683432545375510854470115611391404757724333382582803149953685197474573470410");
|
||||
|
||||
type TECurveConfig = EdwardsParameters;
|
||||
type TECurveConfig = EdwardsConfig;
|
||||
}
|
||||
|
||||
/// GENERATOR_X =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-ed-on-mnt4-298"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "A Twisted Edwards curve defined over the scalar field of the MNT4-298 curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,16 +13,16 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
ark-mnt4-298 = { version = "^0.3.0", path = "../mnt4_298", default-features = false, features = [ "scalar_field" ] }
|
||||
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-mnt4-298 = { version = "0.4.0-alpha", path = "../mnt4_298", default-features = false, features = [ "scalar_field" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
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]
|
||||
|
||||
@@ -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<EdwardsParameters, FqVar>;
|
||||
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
|
||||
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ use crate::{fq::Fq, fr::Fr};
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub type EdwardsAffine = Affine<EdwardsParameters>;
|
||||
pub type EdwardsProjective = Projective<EdwardsParameters>;
|
||||
pub type EdwardsAffine = Affine<EdwardsConfig>;
|
||||
pub type EdwardsProjective = Projective<EdwardsConfig>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct EdwardsParameters;
|
||||
pub struct EdwardsConfig;
|
||||
|
||||
impl CurveConfig for EdwardsParameters {
|
||||
impl CurveConfig for EdwardsConfig {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -34,7 +34,7 @@ impl CurveConfig for EdwardsParameters {
|
||||
// R for Fq: 223364648326281414938801705359223029554923725549792420683051274872200260503540791531766876
|
||||
// R for Fr: 104384076783966083500464392945960916666734135485183910065100558776489954102951241798239545
|
||||
|
||||
impl TECurveConfig for EdwardsParameters {
|
||||
impl TECurveConfig for EdwardsConfig {
|
||||
/// 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 EdwardsParameters {
|
||||
/// Generated randomly
|
||||
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
|
||||
|
||||
type MontCurveConfig = EdwardsParameters;
|
||||
type MontCurveConfig = EdwardsConfig;
|
||||
|
||||
/// Multiplication by `a` is just negation.
|
||||
#[inline(always)]
|
||||
@@ -59,14 +59,14 @@ impl TECurveConfig for EdwardsParameters {
|
||||
}
|
||||
}
|
||||
|
||||
impl MontCurveConfig for EdwardsParameters {
|
||||
impl MontCurveConfig for EdwardsConfig {
|
||||
/// COEFF_A = 203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204
|
||||
const COEFF_A: Fq = MontFp!("203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204");
|
||||
|
||||
/// COEFF_B = 272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931
|
||||
const COEFF_B: Fq = MontFp!("272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931");
|
||||
|
||||
type TECurveConfig = EdwardsParameters;
|
||||
type TECurveConfig = EdwardsConfig;
|
||||
}
|
||||
|
||||
/// GENERATOR_X =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-ed-on-mnt4-753"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "A Twisted Edwards curve defined over the scalar field of the MNT4-753 curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,16 +13,16 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
ark-mnt4-753 = { version = "^0.3.0", path = "../mnt4_753", default-features = false, features = [ "scalar_field" ] }
|
||||
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-mnt4-753 = { version = "0.4.0-alpha", path = "../mnt4_753", default-features = false, features = [ "scalar_field" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
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]
|
||||
|
||||
@@ -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<EdwardsParameters, FqVar>;
|
||||
pub type EdwardsVar = AffineVar<EdwardsConfig, FqVar>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
ark_curve_constraint_tests::curves::te_test::<EdwardsParameters, EdwardsVar>().unwrap();
|
||||
ark_curve_constraint_tests::curves::te_test::<EdwardsConfig, EdwardsVar>().unwrap();
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ use crate::{fq::Fq, fr::Fr};
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub type EdwardsAffine = Affine<EdwardsParameters>;
|
||||
pub type EdwardsProjective = Projective<EdwardsParameters>;
|
||||
pub type EdwardsAffine = Affine<EdwardsConfig>;
|
||||
pub type EdwardsProjective = Projective<EdwardsConfig>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct EdwardsParameters;
|
||||
pub struct EdwardsConfig;
|
||||
|
||||
impl CurveConfig for EdwardsParameters {
|
||||
impl CurveConfig for EdwardsConfig {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -27,7 +27,7 @@ impl CurveConfig for EdwardsParameters {
|
||||
const COFACTOR_INV: Fr = MontFp!("4582647449616135528381398492791944685893671397494963179726320631987147963874964803303316505414568319530101512550297775574042810022553679071007001162683923594233560231270043634777390699589793776691858866199511300853468155295505");
|
||||
}
|
||||
|
||||
impl TECurveConfig for EdwardsParameters {
|
||||
impl TECurveConfig for EdwardsConfig {
|
||||
/// COEFF_A = -1
|
||||
const COEFF_A: Fq = MontFp!("-1");
|
||||
|
||||
@@ -37,7 +37,7 @@ impl TECurveConfig for EdwardsParameters {
|
||||
/// Generated randomly
|
||||
const GENERATOR: EdwardsAffine = EdwardsAffine::new_unchecked(GENERATOR_X, GENERATOR_Y);
|
||||
|
||||
type MontCurveConfig = EdwardsParameters;
|
||||
type MontCurveConfig = EdwardsConfig;
|
||||
|
||||
/// Multiplication by `a` is just negation.
|
||||
#[inline(always)]
|
||||
@@ -46,14 +46,14 @@ impl TECurveConfig for EdwardsParameters {
|
||||
}
|
||||
}
|
||||
|
||||
impl MontCurveConfig for EdwardsParameters {
|
||||
impl MontCurveConfig for EdwardsConfig {
|
||||
/// COEFF_A = 40212480635445336270302172549278415015971955924352275480357619589919378421241453024646804979794897776496091377551124233752850182852486874251193367187677349266115879541798515219680194853352256809837126277708211496794264654247419
|
||||
const COEFF_A: Fq = MontFp!("40212480635445336270302172549278415015971955924352275480357619589919378421241453024646804979794897776496091377551124233752850182852486874251193367187677349266115879541798515219680194853352256809837126277708211496794264654247419");
|
||||
|
||||
/// COEFF_B = 1686010332473617132042042241962222112198753995601673591425883331105974391329653748412088783995441144921979594337334243570322874639106980818502874667119046899605536783551549221790223284494141659774809441351696667426519821912580
|
||||
const COEFF_B: Fq = MontFp!("1686010332473617132042042241962222112198753995601673591425883331105974391329653748412088783995441144921979594337334243570322874639106980818502874667119046899605536783551549221790223284494141659774809441351696667426519821912580");
|
||||
|
||||
type TECurveConfig = EdwardsParameters;
|
||||
type TECurveConfig = EdwardsConfig;
|
||||
}
|
||||
|
||||
/// GENERATOR_X =
|
||||
|
||||
37
grumpkin/Cargo.toml
Normal file
37
grumpkin/Cargo.toml
Normal file
@@ -0,0 +1,37 @@
|
||||
[package]
|
||||
name = "ark-grumpkin"
|
||||
version = "0.4.0"
|
||||
authors = [ "CPerezz", "arkworks contributors" ]
|
||||
description = "The Grumpkin prime-order elliptic curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
repository = "https://github.com/arkworks-rs/curves"
|
||||
documentation = "https://docs.rs/ark-grumpkin/"
|
||||
keywords = ["cryptography", "finite-fields", "elliptic-curves" ]
|
||||
categories = ["cryptography"]
|
||||
include = ["Cargo.toml", "src"]
|
||||
license = "MIT/Apache-2.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
ark-ff = { version = "0.4.0", default-features = false }
|
||||
ark-ec = { version = "0.4.0", default-features = false }
|
||||
ark-r1cs-std = { version = "0.4.0", default-features = false, optional = true }
|
||||
ark-std = { version = "0.4.0", default-features = false }
|
||||
ark-bn254 = { version = "0.4.0", path = "../bn254", default-features = false, features = [ "scalar_field", "curve" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "0.4.0", default-features = false }
|
||||
ark-serialize = { version = "0.4.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "0.4.0", default-features = false }
|
||||
ark-algebra-bench-templates = { version = "0.4.0", 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" ]
|
||||
|
||||
[[bench]]
|
||||
name = "grumpkin"
|
||||
path = "benches/grumpkin.rs"
|
||||
harness = false
|
||||
1
grumpkin/LICENSE-APACHE
Symbolic link
1
grumpkin/LICENSE-APACHE
Symbolic link
@@ -0,0 +1 @@
|
||||
../LICENSE-APACHE
|
||||
1
grumpkin/LICENSE-MIT
Symbolic link
1
grumpkin/LICENSE-MIT
Symbolic link
@@ -0,0 +1 @@
|
||||
../LICENSE-MIT
|
||||
9
grumpkin/benches/grumpkin.rs
Normal file
9
grumpkin/benches/grumpkin.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use ark_algebra_bench_templates::*;
|
||||
use ark_grumpkin::{fq::Fq, fr::Fr, Projective as G};
|
||||
|
||||
bench!(
|
||||
Name = "Grumpkin",
|
||||
Group = G,
|
||||
ScalarField = Fr,
|
||||
PrimeBaseField = Fq,
|
||||
);
|
||||
28
grumpkin/scripts/base_field.sage
Normal file
28
grumpkin/scripts/base_field.sage
Normal file
@@ -0,0 +1,28 @@
|
||||
modulus = 21888242871839275222246405745257275088548364400416034343698204186575808495617
|
||||
|
||||
assert(modulus.is_prime())
|
||||
|
||||
Fp = GF(modulus)
|
||||
|
||||
generator = Fp(0);
|
||||
for i in range(0, 20):
|
||||
i = Fp(i);
|
||||
neg_i = Fp(-i)
|
||||
if not(i.is_primitive_root() or neg_i.is_primitive_root()):
|
||||
continue
|
||||
elif i.is_primitive_root():
|
||||
assert(i.is_primitive_root());
|
||||
print("Generator: %d" % i)
|
||||
generator = i
|
||||
break
|
||||
else:
|
||||
assert(neg_i.is_primitive_root());
|
||||
print("Generator: %d" % neg_i)
|
||||
generator = neg_i
|
||||
break
|
||||
|
||||
|
||||
two_adicity = valuation(modulus - 1, 2);
|
||||
trace = (modulus - 1) / 2**two_adicity;
|
||||
two_adic_root_of_unity = generator^trace
|
||||
print("2-adic Root of Unity: %d " % two_adic_root_of_unity)
|
||||
28
grumpkin/scripts/scalar_field.sage
Normal file
28
grumpkin/scripts/scalar_field.sage
Normal file
@@ -0,0 +1,28 @@
|
||||
modulus = 21888242871839275222246405745257275088696311157297823662689037894645226208583
|
||||
|
||||
assert(modulus.is_prime())
|
||||
|
||||
Fp = GF(modulus)
|
||||
|
||||
generator = Fp(0);
|
||||
for i in range(0, 20):
|
||||
i = Fp(i);
|
||||
neg_i = Fp(-i)
|
||||
if not(i.is_primitive_root() or neg_i.is_primitive_root()):
|
||||
continue
|
||||
elif i.is_primitive_root():
|
||||
assert(i.is_primitive_root());
|
||||
print("Generator: %d" % i)
|
||||
generator = i
|
||||
break
|
||||
else:
|
||||
assert(neg_i.is_primitive_root());
|
||||
print("Generator: %d" % neg_i)
|
||||
generator = neg_i
|
||||
break
|
||||
|
||||
|
||||
two_adicity = valuation(modulus - 1, 2);
|
||||
trace = (modulus - 1) / 2**two_adicity;
|
||||
two_adic_root_of_unity = generator^trace
|
||||
print("2-adic Root of Unity: %d " % two_adic_root_of_unity)
|
||||
11
grumpkin/src/constraints/curves.rs
Normal file
11
grumpkin/src/constraints/curves.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use ark_r1cs_std::groups::curves::short_weierstrass::ProjectiveVar;
|
||||
|
||||
use crate::{constraints::FBaseVar, *};
|
||||
|
||||
/// A group element in the Grumpkin prime-order group.
|
||||
pub type GVar = ProjectiveVar<GrumpkinConfig, FBaseVar>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
ark_curve_constraint_tests::curves::sw_test::<GrumpkinConfig, GVar>().unwrap();
|
||||
}
|
||||
11
grumpkin/src/constraints/fields.rs
Normal file
11
grumpkin/src/constraints/fields.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use ark_r1cs_std::fields::fp::FpVar;
|
||||
|
||||
use crate::fq::Fq;
|
||||
|
||||
/// A variable that is the R1CS equivalent of `crate::Fq`.
|
||||
pub type FBaseVar = FpVar<Fq>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
ark_curve_constraint_tests::fields::field_test::<_, _, FBaseVar>().unwrap();
|
||||
}
|
||||
107
grumpkin/src/constraints/mod.rs
Normal file
107
grumpkin/src/constraints/mod.rs
Normal file
@@ -0,0 +1,107 @@
|
||||
//! This module implements the R1CS equivalent of `ark_grumpkin`.
|
||||
//!
|
||||
//! It implements field variables for `crate::Fq`,
|
||||
//! and group variables for `crate::Projective`.
|
||||
//!
|
||||
//! The field underlying these constraints is `crate::Fq`.
|
||||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
//! One can perform standard algebraic operations on `FBaseVar`:
|
||||
//!
|
||||
//! ```
|
||||
//! # fn main() -> Result<(), ark_relations::r1cs::SynthesisError> {
|
||||
//! use ark_std::UniformRand;
|
||||
//! use ark_relations::r1cs::*;
|
||||
//! use ark_r1cs_std::prelude::*;
|
||||
//! use ark_grumpkin::{*, constraints::*};
|
||||
//!
|
||||
//! let cs = ConstraintSystem::<Fq>::new_ref();
|
||||
//! // This rng is just for test purposes; do not use it
|
||||
//! // in real applications.
|
||||
//! let mut rng = ark_std::test_rng();
|
||||
//!
|
||||
//! // Generate some random `Fq` elements.
|
||||
//! let a_native = Fq::rand(&mut rng);
|
||||
//! let b_native = Fq::rand(&mut rng);
|
||||
//!
|
||||
//! // Allocate `a_native` and `b_native` as witness variables in `cs`.
|
||||
//! let a = FBaseVar::new_witness(ark_relations::ns!(cs, "generate_a"), || Ok(a_native))?;
|
||||
//! let b = FBaseVar::new_witness(ark_relations::ns!(cs, "generate_b"), || Ok(b_native))?;
|
||||
//!
|
||||
//! // Allocate `a_native` and `b_native` as constants in `cs`. This does not add any
|
||||
//! // constraints or variables.
|
||||
//! let a_const = FBaseVar::new_constant(ark_relations::ns!(cs, "a_as_constant"), a_native)?;
|
||||
//! let b_const = FBaseVar::new_constant(ark_relations::ns!(cs, "b_as_constant"), b_native)?;
|
||||
//!
|
||||
//! let one = FBaseVar::one();
|
||||
//! let zero = FBaseVar::zero();
|
||||
//!
|
||||
//! // Sanity check one + one = two
|
||||
//! let two = &one + &one + &zero;
|
||||
//! two.enforce_equal(&one.double()?)?;
|
||||
//!
|
||||
//! assert!(cs.is_satisfied()?);
|
||||
//!
|
||||
//! // Check that the value of &a + &b is correct.
|
||||
//! assert_eq!((&a + &b).value()?, a_native + &b_native);
|
||||
//!
|
||||
//! // Check that the value of &a * &b is correct.
|
||||
//! assert_eq!((&a * &b).value()?, a_native * &b_native);
|
||||
//!
|
||||
//! // Check that operations on variables and constants are equivalent.
|
||||
//! (&a + &b).enforce_equal(&(&a_const + &b_const))?;
|
||||
//! assert!(cs.is_satisfied()?);
|
||||
//! # Ok(())
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! One can also perform standard algebraic operations on `GVar`:
|
||||
//!
|
||||
//! ```
|
||||
//! # fn main() -> Result<(), ark_relations::r1cs::SynthesisError> {
|
||||
//! # use ark_std::UniformRand;
|
||||
//! # use ark_relations::r1cs::*;
|
||||
//! # use ark_r1cs_std::prelude::*;
|
||||
//! # use ark_grumpkin::{*, constraints::*};
|
||||
//!
|
||||
//! # let cs = ConstraintSystem::<Fq>::new_ref();
|
||||
//! # let mut rng = ark_std::test_rng();
|
||||
//!
|
||||
//! // Generate some random `Projective` elements.
|
||||
//! let a_native = Projective::rand(&mut rng);
|
||||
//! let b_native = Projective::rand(&mut rng);
|
||||
//!
|
||||
//! // Allocate `a_native` and `b_native` as witness variables in `cs`.
|
||||
//! let a = GVar::new_witness(ark_relations::ns!(cs, "a"), || Ok(a_native))?;
|
||||
//! let b = GVar::new_witness(ark_relations::ns!(cs, "b"), || Ok(b_native))?;
|
||||
//!
|
||||
//! // Allocate `a_native` and `b_native` as constants in `cs`. This does not add any
|
||||
//! // constraints or variables.
|
||||
//! let a_const = GVar::new_constant(ark_relations::ns!(cs, "a_as_constant"), a_native)?;
|
||||
//! let b_const = GVar::new_constant(ark_relations::ns!(cs, "b_as_constant"), b_native)?;
|
||||
//!
|
||||
//! // This returns the identity.
|
||||
//! let zero = GVar::zero();
|
||||
//!
|
||||
//! // Sanity check one + one = two
|
||||
//! let two_a = &a + &a + &zero;
|
||||
//! two_a.enforce_equal(&a.double()?)?;
|
||||
//!
|
||||
//! assert!(cs.is_satisfied()?);
|
||||
//!
|
||||
//! // Check that the value of &a + &b is correct.
|
||||
//! assert_eq!((&a + &b).value()?, a_native + &b_native);
|
||||
//!
|
||||
//! // Check that operations on variables and constants are equivalent.
|
||||
//! (&a + &b).enforce_equal(&(&a_const + &b_const))?;
|
||||
//! assert!(cs.is_satisfied()?);
|
||||
//! # Ok(())
|
||||
//! # }
|
||||
//! ```
|
||||
|
||||
mod curves;
|
||||
mod fields;
|
||||
|
||||
pub use curves::*;
|
||||
pub use fields::*;
|
||||
52
grumpkin/src/curves/mod.rs
Normal file
52
grumpkin/src/curves/mod.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
// The parameters for the curve have been taken from
|
||||
// https://github.com/AztecProtocol/barretenberg/blob/97ccf76c42db581a8b8f8bfbcffe8ca015a3dd22/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp
|
||||
|
||||
use crate::{fq::Fq, fr::Fr};
|
||||
use ark_ec::{
|
||||
models::CurveConfig,
|
||||
short_weierstrass::{self as sw, SWCurveConfig},
|
||||
};
|
||||
use ark_ff::{Field, MontFp, Zero};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[derive(Copy, Clone, Default, PartialEq, Eq)]
|
||||
pub struct GrumpkinConfig;
|
||||
|
||||
impl CurveConfig for GrumpkinConfig {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
/// COFACTOR = 1
|
||||
const COFACTOR: &'static [u64] = &[0x1];
|
||||
|
||||
/// COFACTOR_INV = 1
|
||||
const COFACTOR_INV: Fr = Fr::ONE;
|
||||
}
|
||||
|
||||
pub type Affine = sw::Affine<GrumpkinConfig>;
|
||||
pub type Projective = sw::Projective<GrumpkinConfig>;
|
||||
|
||||
impl SWCurveConfig for GrumpkinConfig {
|
||||
/// COEFF_A = 0
|
||||
const COEFF_A: Fq = Fq::ZERO;
|
||||
|
||||
/// COEFF_B = -17
|
||||
const COEFF_B: Fq = MontFp!("-17");
|
||||
|
||||
/// 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 {
|
||||
Self::BaseField::zero()
|
||||
}
|
||||
}
|
||||
|
||||
/// G_GENERATOR_X = 1
|
||||
pub const G_GENERATOR_X: Fq = MontFp!("1");
|
||||
|
||||
/// G_GENERATOR_Y = sqrt(-16)
|
||||
pub const G_GENERATOR_Y: Fq =
|
||||
MontFp!("17631683881184975370165255887551781615748388533673675138860");
|
||||
4
grumpkin/src/curves/tests.rs
Executable file
4
grumpkin/src/curves/tests.rs
Executable file
@@ -0,0 +1,4 @@
|
||||
use crate::Projective;
|
||||
use ark_algebra_test_templates::*;
|
||||
|
||||
test_group!(g1; Projective; sw);
|
||||
1
grumpkin/src/fields/fq.rs
Normal file
1
grumpkin/src/fields/fq.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub use ark_bn254::{Fr as Fq, FrConfig as FqConfig};
|
||||
1
grumpkin/src/fields/fr.rs
Normal file
1
grumpkin/src/fields/fr.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub use ark_bn254::{Fq as Fr, FqConfig as FrConfig};
|
||||
8
grumpkin/src/fields/mod.rs
Normal file
8
grumpkin/src/fields/mod.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
pub mod fq;
|
||||
pub use self::fq::*;
|
||||
|
||||
pub mod fr;
|
||||
pub use self::fr::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
5
grumpkin/src/fields/tests.rs
Normal file
5
grumpkin/src/fields/tests.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
use crate::{Fq, Fr};
|
||||
use ark_algebra_test_templates::*;
|
||||
|
||||
test_field!(fr; Fr; mont_prime_field);
|
||||
test_field!(fq; Fq; mont_prime_field);
|
||||
33
grumpkin/src/lib.rs
Normal file
33
grumpkin/src/lib.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![deny(
|
||||
warnings,
|
||||
unused,
|
||||
future_incompatible,
|
||||
nonstandard_style,
|
||||
rust_2018_idioms
|
||||
)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
//! This library implements the prime-order curve Grumpkin, generated by
|
||||
//! Zachary J. Williamson from Aztec protocol. The main feature of this
|
||||
//! curve is that it forms a cycle with bn254, i.e. its scalar field and base
|
||||
//! field respectively are the base field and scalar field of bn254.
|
||||
//!
|
||||
//!
|
||||
//! Curve information:
|
||||
//! Grumpkin:
|
||||
//! * Base field: q =
|
||||
//! 21888242871839275222246405745257275088548364400416034343698204186575808495617
|
||||
//! * Scalar field: r =
|
||||
//! 21888242871839275222246405745257275088696311157297823662689037894645226208583
|
||||
//! * Curve equation: y^2 = x^3 - 17
|
||||
//! * Valuation(q - 1, 2) = 28
|
||||
//! * Valuation(r - 1, 2) = 1
|
||||
|
||||
#[cfg(feature = "r1cs")]
|
||||
pub mod constraints;
|
||||
mod curves;
|
||||
mod fields;
|
||||
|
||||
pub use curves::*;
|
||||
pub use fields::*;
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-mnt4-298"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "The MNT4-298 pairing-friendly elliptic curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,16 +13,16 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
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 }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-bench-templates = { version = "^0.3.0", default-features = false }
|
||||
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-algebra-bench-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-curve-constraint-tests = { path = "../curve-constraint-tests", default-features = false }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -1,30 +1,24 @@
|
||||
use ark_r1cs_std::groups::mnt4;
|
||||
|
||||
use crate::Parameters;
|
||||
use crate::Config;
|
||||
|
||||
/// An element of G1 in the MNT4-298 bilinear group.
|
||||
pub type G1Var = mnt4::G1Var<Parameters>;
|
||||
pub type G1Var = mnt4::G1Var<Config>;
|
||||
/// An element of G2 in the MNT4-298 bilinear group.
|
||||
pub type G2Var = mnt4::G2Var<Parameters>;
|
||||
pub type G2Var = mnt4::G2Var<Config>;
|
||||
|
||||
/// Represents the cached precomputation that can be performed on a G1 element
|
||||
/// which enables speeding up pairing computation.
|
||||
pub type G1PreparedVar = mnt4::G1PreparedVar<Parameters>;
|
||||
pub type G1PreparedVar = mnt4::G1PreparedVar<Config>;
|
||||
/// Represents the cached precomputation that can be performed on a G2 element
|
||||
/// which enables speeding up pairing computation.
|
||||
pub type G2PreparedVar = mnt4::G2PreparedVar<Parameters>;
|
||||
pub type G2PreparedVar = mnt4::G2PreparedVar<Config>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
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::<
|
||||
<Parameters as MNT4Parameters>::G2Parameters,
|
||||
G2Var,
|
||||
>()
|
||||
.unwrap();
|
||||
use ark_ec::models::mnt4::MNT4Config;
|
||||
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G1Config, G1Var>()
|
||||
.unwrap();
|
||||
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G2Config, G2Var>()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::Parameters;
|
||||
use crate::Config;
|
||||
|
||||
/// Specifies the constraints for computing a pairing in the MNT4-298 bilinear
|
||||
/// group.
|
||||
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Parameters>;
|
||||
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Config>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
|
||||
@@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
|
||||
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
pub type G1Affine = mnt4::G1Affine<crate::Parameters>;
|
||||
pub type G1Projective = mnt4::G1Projective<crate::Parameters>;
|
||||
pub type G1Prepared = mnt4::G1Prepared<crate::Parameters>;
|
||||
pub type G1Affine = mnt4::G1Affine<crate::Config>;
|
||||
pub type G1Projective = mnt4::G1Projective<crate::Config>;
|
||||
pub type G1Prepared = mnt4::G1Prepared<crate::Config>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -25,7 +25,7 @@ impl CurveConfig for Parameters {
|
||||
const COFACTOR_INV: Fr = Fr::ONE;
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// 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");
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
use ark_ec::{
|
||||
mnt4,
|
||||
mnt4::MNT4Parameters,
|
||||
mnt4::MNT4Config,
|
||||
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::Parameters>;
|
||||
pub type G2Projective = mnt4::G2Projective<crate::Parameters>;
|
||||
pub type G2Prepared = mnt4::G2Prepared<crate::Parameters>;
|
||||
pub type G2Affine = mnt4::G2Affine<crate::Config>;
|
||||
pub type G2Projective = mnt4::G2Projective<crate::Config>;
|
||||
pub type G2Prepared = mnt4::G2Prepared<crate::Config>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
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 Parameters {
|
||||
const COEFF_A: Fq2 = crate::Parameters::TWIST_COEFF_A;
|
||||
impl SWCurveConfig for Config {
|
||||
const COEFF_A: Fq2 = crate::Config::TWIST_COEFF_A;
|
||||
// B coefficient of MNT4-298 G2 =
|
||||
// ```
|
||||
// mnt4298_twist_coeff_b = mnt4298_Fq2(mnt4298_Fq::zero(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ark_ec::models::mnt4::{MNT4Parameters, MNT4};
|
||||
use ark_ec::models::mnt4::{MNT4Config, 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<Parameters>;
|
||||
pub type MNT4_298 = MNT4<Config>;
|
||||
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl MNT4Parameters for Parameters {
|
||||
impl MNT4Config for Config {
|
||||
const TWIST: Fq2 = Fq2::new(Fq::ZERO, Fq::ONE);
|
||||
// A coefficient of MNT4-298 G2 =
|
||||
// ```
|
||||
@@ -46,8 +46,8 @@ impl MNT4Parameters for Parameters {
|
||||
type Fr = Fr;
|
||||
type Fp2Config = Fq2Config;
|
||||
type Fp4Config = Fq4Config;
|
||||
type G1Parameters = self::g1::Parameters;
|
||||
type G2Parameters = self::g2::Parameters;
|
||||
type G1Config = self::g1::Config;
|
||||
type G2Config = self::g2::Config;
|
||||
}
|
||||
|
||||
// 34
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-mnt4-753"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "The MNT4-753 pairing-friendly elliptic curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,16 +13,16 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
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 }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-bench-templates = { version = "^0.3.0", default-features = false }
|
||||
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-algebra-bench-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-curve-constraint-tests = { path = "../curve-constraint-tests", default-features = false }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -1,30 +1,24 @@
|
||||
use ark_r1cs_std::groups::mnt4;
|
||||
|
||||
use crate::Parameters;
|
||||
use crate::Config;
|
||||
|
||||
/// An element of G1 in the MNT4-753 bilinear group.
|
||||
pub type G1Var = mnt4::G1Var<Parameters>;
|
||||
pub type G1Var = mnt4::G1Var<Config>;
|
||||
/// An element of G2 in the MNT4-753 bilinear group.
|
||||
pub type G2Var = mnt4::G2Var<Parameters>;
|
||||
pub type G2Var = mnt4::G2Var<Config>;
|
||||
|
||||
/// Represents the cached precomputation that can be performed on a G1 element
|
||||
/// which enables speeding up pairing computation.
|
||||
pub type G1PreparedVar = mnt4::G1PreparedVar<Parameters>;
|
||||
pub type G1PreparedVar = mnt4::G1PreparedVar<Config>;
|
||||
/// Represents the cached precomputation that can be performed on a G2 element
|
||||
/// which enables speeding up pairing computation.
|
||||
pub type G2PreparedVar = mnt4::G2PreparedVar<Parameters>;
|
||||
pub type G2PreparedVar = mnt4::G2PreparedVar<Config>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
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::<
|
||||
<Parameters as MNT4Parameters>::G2Parameters,
|
||||
G2Var,
|
||||
>()
|
||||
.unwrap();
|
||||
use ark_ec::models::mnt4::MNT4Config;
|
||||
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G1Config, G1Var>()
|
||||
.unwrap();
|
||||
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT4Config>::G2Config, G2Var>()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::Parameters;
|
||||
use crate::Config;
|
||||
|
||||
/// Specifies the constraints for computing a pairing in the MNT4-753 bilinear
|
||||
/// group.
|
||||
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Parameters>;
|
||||
pub type PairingVar = ark_r1cs_std::pairing::mnt4::PairingVar<Config>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
|
||||
@@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
|
||||
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
pub type G1Affine = mnt4::G1Affine<crate::Parameters>;
|
||||
pub type G1Projective = mnt4::G1Projective<crate::Parameters>;
|
||||
pub type G1Prepared = mnt4::G1Prepared<crate::Parameters>;
|
||||
pub type G1Affine = mnt4::G1Affine<crate::Config>;
|
||||
pub type G1Projective = mnt4::G1Projective<crate::Config>;
|
||||
pub type G1Prepared = mnt4::G1Prepared<crate::Config>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -24,7 +24,7 @@ impl CurveConfig for Parameters {
|
||||
const COFACTOR_INV: Fr = Fr::ONE;
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = 2
|
||||
const COEFF_A: Fq = MontFp!("2");
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
use ark_ec::{
|
||||
mnt4,
|
||||
mnt4::MNT4Parameters,
|
||||
mnt4::MNT4Config,
|
||||
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::Parameters>;
|
||||
pub type G2Projective = mnt4::G2Projective<crate::Parameters>;
|
||||
pub type G2Prepared = mnt4::G2Prepared<crate::Parameters>;
|
||||
pub type G2Affine = mnt4::G2Affine<crate::Config>;
|
||||
pub type G2Projective = mnt4::G2Projective<crate::Config>;
|
||||
pub type G2Prepared = mnt4::G2Prepared<crate::Config>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
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 Parameters {
|
||||
const COEFF_A: Fq2 = crate::Parameters::TWIST_COEFF_A;
|
||||
impl SWCurveConfig for Config {
|
||||
const COEFF_A: Fq2 = crate::Config::TWIST_COEFF_A;
|
||||
// B coefficient of MNT4-753 G2 =
|
||||
// ```
|
||||
// mnt4753_twist_coeff_b = mnt4753_Fq2(mnt4753_Fq::zero(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ark_ec::models::mnt4::{MNT4Parameters, MNT4};
|
||||
use ark_ec::models::mnt4::{MNT4Config, 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<Parameters>;
|
||||
pub type MNT4_753 = MNT4<Config>;
|
||||
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl MNT4Parameters for Parameters {
|
||||
impl MNT4Config for Config {
|
||||
const TWIST: Fp2<Self::Fp2Config> = Fp2::new(Fq::ZERO, Fq::ONE);
|
||||
// A coefficient of MNT4-753 G2 =
|
||||
// ```
|
||||
@@ -69,8 +69,8 @@ impl MNT4Parameters for Parameters {
|
||||
type Fr = Fr;
|
||||
type Fp2Config = Fq2Config;
|
||||
type Fp4Config = Fq4Config;
|
||||
type G1Parameters = self::g1::Parameters;
|
||||
type G2Parameters = self::g2::Parameters;
|
||||
type G1Config = self::g1::Config;
|
||||
type G2Config = self::g2::Config;
|
||||
}
|
||||
|
||||
// 26
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-mnt6-298"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "The MNT6-298 pairing-friendly elliptic curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,17 +13,17 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
ark-mnt4-298 = { version = "^0.3.0", path = "../mnt4_298", default-features = false, features = [ "scalar_field", "base_field" ] }
|
||||
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-mnt4-298 = { version = "0.4.0-alpha", path = "../mnt4_298", default-features = false, features = [ "scalar_field", "base_field" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-bench-templates = { version = "^0.3.0", default-features = false }
|
||||
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-algebra-bench-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-curve-constraint-tests = { path = "../curve-constraint-tests", default-features = false }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -1,30 +1,24 @@
|
||||
use ark_r1cs_std::groups::mnt6;
|
||||
|
||||
use crate::Parameters;
|
||||
use crate::Config;
|
||||
|
||||
/// An element of G1 in the MNT6-298 bilinear group.
|
||||
pub type G1Var = mnt6::G1Var<Parameters>;
|
||||
pub type G1Var = mnt6::G1Var<Config>;
|
||||
/// An element of G2 in the MNT6-298 bilinear group.
|
||||
pub type G2Var = mnt6::G2Var<Parameters>;
|
||||
pub type G2Var = mnt6::G2Var<Config>;
|
||||
|
||||
/// Represents the cached precomputation that can be performed on a G1 element
|
||||
/// which enables speeding up pairing computation.
|
||||
pub type G1PreparedVar = mnt6::G1PreparedVar<Parameters>;
|
||||
pub type G1PreparedVar = mnt6::G1PreparedVar<Config>;
|
||||
/// Represents the cached precomputation that can be performed on a G2 element
|
||||
/// which enables speeding up pairing computation.
|
||||
pub type G2PreparedVar = mnt6::G2PreparedVar<Parameters>;
|
||||
pub type G2PreparedVar = mnt6::G2PreparedVar<Config>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
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::<
|
||||
<Parameters as MNT6Parameters>::G2Parameters,
|
||||
G2Var,
|
||||
>()
|
||||
.unwrap();
|
||||
use ark_ec::models::mnt6::MNT6Config;
|
||||
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G1Config, G1Var>()
|
||||
.unwrap();
|
||||
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G2Config, G2Var>()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::Parameters;
|
||||
use crate::Config;
|
||||
|
||||
/// Specifies the constraints for computing a pairing in the MNT6-298 bilinear
|
||||
/// group.
|
||||
pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Parameters>;
|
||||
pub type PairingVar = ark_r1cs_std::pairing::mnt6::PairingVar<Config>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
|
||||
@@ -6,14 +6,14 @@ use ark_ff::{Field, MontFp};
|
||||
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
pub type G1Affine = mnt6::G1Affine<crate::Parameters>;
|
||||
pub type G1Projective = mnt6::G1Projective<crate::Parameters>;
|
||||
pub type G1Prepared = mnt6::G1Prepared<crate::Parameters>;
|
||||
pub type G1Affine = mnt6::G1Affine<crate::Config>;
|
||||
pub type G1Projective = mnt6::G1Projective<crate::Config>;
|
||||
pub type G1Prepared = mnt6::G1Prepared<crate::Config>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
type BaseField = Fq;
|
||||
type ScalarField = Fr;
|
||||
|
||||
@@ -24,7 +24,7 @@ impl CurveConfig for Parameters {
|
||||
const COFACTOR_INV: Fr = Fr::ONE;
|
||||
}
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
impl SWCurveConfig for Config {
|
||||
/// COEFF_A = 11
|
||||
const COEFF_A: Fq = MontFp!("11");
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
use ark_ec::{
|
||||
mnt6,
|
||||
mnt6::MNT6Parameters,
|
||||
mnt6::MNT6Config,
|
||||
models::{short_weierstrass::SWCurveConfig, CurveConfig},
|
||||
};
|
||||
use ark_ff::{Field, MontFp};
|
||||
|
||||
use crate::{g1, Fq, Fq3, Fr};
|
||||
|
||||
pub type G2Affine = mnt6::G2Affine<crate::Parameters>;
|
||||
pub type G2Projective = mnt6::G2Projective<crate::Parameters>;
|
||||
pub type G2Prepared = mnt6::G2Prepared<crate::Parameters>;
|
||||
pub type G2Affine = mnt6::G2Affine<crate::Config>;
|
||||
pub type G2Projective = mnt6::G2Projective<crate::Config>;
|
||||
pub type G2Prepared = mnt6::G2Prepared<crate::Config>;
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl CurveConfig for Parameters {
|
||||
impl CurveConfig for Config {
|
||||
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::Parameters::COEFF_A;
|
||||
pub const MUL_BY_A_C2: Fq = g1::Config::COEFF_A;
|
||||
|
||||
impl SWCurveConfig for Parameters {
|
||||
const COEFF_A: Fq3 = crate::Parameters::TWIST_COEFF_A;
|
||||
impl SWCurveConfig for Config {
|
||||
const COEFF_A: Fq3 = crate::Config::TWIST_COEFF_A;
|
||||
const COEFF_B: Fq3 = Fq3::new(
|
||||
// 5 * G1::COEFF_B
|
||||
MontFp!("57578116384997352636487348509878309737146377454014423897662211075515354005624851787652233"),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use ark_ec::{
|
||||
models::mnt6::{MNT6Parameters, MNT6},
|
||||
models::mnt6::{MNT6Config, 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<Parameters>;
|
||||
pub type MNT6_298 = MNT6<Config>;
|
||||
|
||||
pub struct Parameters;
|
||||
pub struct Config;
|
||||
|
||||
impl MNT6Parameters for Parameters {
|
||||
impl MNT6Config for Config {
|
||||
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::Parameters::COEFF_A);
|
||||
Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ZERO, g1::Config::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 MNT6Parameters for Parameters {
|
||||
type Fr = Fr;
|
||||
type Fp3Config = Fq3Config;
|
||||
type Fp6Config = Fq6Config;
|
||||
type G1Parameters = self::g1::Parameters;
|
||||
type G2Parameters = self::g2::Parameters;
|
||||
type G1Config = self::g1::Config;
|
||||
type G2Config = self::g2::Config;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ark-mnt6-753"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-alpha.2"
|
||||
authors = [ "arkworks contributors" ]
|
||||
description = "The MNT6-753 pairing-friendly elliptic curve"
|
||||
homepage = "https://arkworks.rs"
|
||||
@@ -13,17 +13,17 @@ license = "MIT/Apache-2.0"
|
||||
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-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
|
||||
ark-mnt4-753 = { version = "^0.3.0", path = "../mnt4_753", default-features = false, features = [ "scalar_field", "base_field" ] }
|
||||
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-mnt4-753 = { version = "0.4.0-alpha", path = "../mnt4_753", default-features = false, features = [ "scalar_field", "base_field" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-relations = { version = "^0.3.0", default-features = false }
|
||||
ark-serialize = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-test-templates = { version = "^0.3.0", default-features = false }
|
||||
ark-algebra-bench-templates = { version = "^0.3.0", default-features = false }
|
||||
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-algebra-bench-templates = { version = "0.4.0-alpha", default-features = false }
|
||||
ark-curve-constraint-tests = { path = "../curve-constraint-tests", default-features = false }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -1,30 +1,24 @@
|
||||
use ark_r1cs_std::groups::mnt6;
|
||||
|
||||
use crate::Parameters;
|
||||
use crate::Config;
|
||||
|
||||
/// An element of G1 in the MNT6-753 bilinear group.
|
||||
pub type G1Var = mnt6::G1Var<Parameters>;
|
||||
pub type G1Var = mnt6::G1Var<Config>;
|
||||
/// An element of G2 in the MNT6-753 bilinear group.
|
||||
pub type G2Var = mnt6::G2Var<Parameters>;
|
||||
pub type G2Var = mnt6::G2Var<Config>;
|
||||
|
||||
/// Represents the cached precomputation that can be performed on a G1 element
|
||||
/// which enables speeding up pairing computation.
|
||||
pub type G1PreparedVar = mnt6::G1PreparedVar<Parameters>;
|
||||
pub type G1PreparedVar = mnt6::G1PreparedVar<Config>;
|
||||
/// Represents the cached precomputation that can be performed on a G2 element
|
||||
/// which enables speeding up pairing computation.
|
||||
pub type G2PreparedVar = mnt6::G2PreparedVar<Parameters>;
|
||||
pub type G2PreparedVar = mnt6::G2PreparedVar<Config>;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
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::<
|
||||
<Parameters as MNT6Parameters>::G2Parameters,
|
||||
G2Var,
|
||||
>()
|
||||
.unwrap();
|
||||
use ark_ec::models::mnt6::MNT6Config;
|
||||
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G1Config, G1Var>()
|
||||
.unwrap();
|
||||
ark_curve_constraint_tests::curves::sw_test::<<Config as MNT6Config>::G2Config, G2Var>()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user