Browse Source

Rename curves

master
Pratyush Mishra 4 years ago
parent
commit
1959a3de63
31 changed files with 91 additions and 83 deletions
  1. +1
    -1
      cp-benches/Cargo.toml
  2. +1
    -1
      cp-benches/benches/crypto_primitives/comm.rs
  3. +1
    -1
      cp-benches/benches/crypto_primitives/crh.rs
  4. +2
    -2
      cp-benches/benches/crypto_primitives/signature.rs
  5. +2
    -2
      crypto-primitives/Cargo.toml
  6. +1
    -1
      crypto-primitives/src/commitment/blake2s/constraints.rs
  7. +3
    -2
      crypto-primitives/src/commitment/pedersen/constraints.rs
  8. +3
    -3
      crypto-primitives/src/crh/bowe_hopwood/constraints.rs
  9. +3
    -3
      crypto-primitives/src/crh/bowe_hopwood/mod.rs
  10. +3
    -2
      crypto-primitives/src/crh/pedersen/constraints.rs
  11. +4
    -2
      crypto-primitives/src/merkle_tree/constraints.rs
  12. +1
    -1
      crypto-primitives/src/merkle_tree/mod.rs
  13. +1
    -1
      crypto-primitives/src/prf/blake2s/constraints.rs
  14. +2
    -1
      crypto-primitives/src/signature/mod.rs
  15. +4
    -4
      r1cs-std/Cargo.toml
  16. +0
    -11
      r1cs-std/src/instantiated/edwards_bls12/curves.rs
  17. +11
    -0
      r1cs-std/src/instantiated/edwards_on_bls12_377/curves.rs
  18. +1
    -1
      r1cs-std/src/instantiated/edwards_on_bls12_377/fields.rs
  19. +0
    -0
      r1cs-std/src/instantiated/edwards_on_bls12_377/mod.rs
  20. +11
    -0
      r1cs-std/src/instantiated/edwards_on_bls12_381/curves.rs
  21. +8
    -0
      r1cs-std/src/instantiated/edwards_on_bls12_381/fields.rs
  22. +0
    -0
      r1cs-std/src/instantiated/edwards_on_bls12_381/mod.rs
  23. +11
    -0
      r1cs-std/src/instantiated/edwards_on_cp6_782/curves.rs
  24. +1
    -1
      r1cs-std/src/instantiated/edwards_on_cp6_782/fields.rs
  25. +0
    -0
      r1cs-std/src/instantiated/edwards_on_cp6_782/mod.rs
  26. +0
    -11
      r1cs-std/src/instantiated/edwards_sw6/curves.rs
  27. +0
    -11
      r1cs-std/src/instantiated/jubjub/curves.rs
  28. +0
    -8
      r1cs-std/src/instantiated/jubjub/fields.rs
  29. +6
    -6
      r1cs-std/src/instantiated/mod.rs
  30. +6
    -6
      r1cs-std/src/lib.rs
  31. +4
    -1
      r1cs-std/src/test_constraint_system.rs

+ 1
- 1
cp-benches/Cargo.toml

@ -22,7 +22,7 @@ edition = "2018"
################################# Dependencies ################################ ################################# Dependencies ################################
[dev-dependencies] [dev-dependencies]
algebra = { path = "../algebra", default-features = false, features = [ "edwards_bls12" ] }
algebra = { path = "../algebra", default-features = false, features = [ "edwards_on_bls12_377" ] }
blake2 = { version = "0.8", default-features = false } blake2 = { version = "0.8", default-features = false }
criterion = "0.3.1" criterion = "0.3.1"
crypto-primitives = { path = "../crypto-primitives" } crypto-primitives = { path = "../crypto-primitives" }

+ 1
- 1
cp-benches/benches/crypto_primitives/comm.rs

@ -3,7 +3,7 @@ use rand;
#[macro_use] #[macro_use]
extern crate criterion; extern crate criterion;
use algebra::{edwards_bls12::EdwardsProjective as Edwards, UniformRand};
use algebra::{edwards_on_bls12_377::EdwardsProjective as Edwards, UniformRand};
use criterion::Criterion; use criterion::Criterion;
use crypto_primitives::commitment::{pedersen::*, CommitmentScheme}; use crypto_primitives::commitment::{pedersen::*, CommitmentScheme};

+ 1
- 1
cp-benches/benches/crypto_primitives/crh.rs

@ -3,7 +3,7 @@ use rand;
#[macro_use] #[macro_use]
extern crate criterion; extern crate criterion;
use algebra::edwards_bls12::EdwardsProjective as Edwards;
use algebra::edwards_on_bls12_377::EdwardsProjective as Edwards;
use criterion::Criterion; use criterion::Criterion;
use crypto_primitives::crh::{pedersen::*, FixedLengthCRH}; use crypto_primitives::crh::{pedersen::*, FixedLengthCRH};

+ 2
- 2
cp-benches/benches/crypto_primitives/signature.rs

@ -2,7 +2,7 @@
extern crate criterion; extern crate criterion;
mod affine { mod affine {
use algebra::edwards_bls12::EdwardsAffine as Edwards;
use algebra::edwards_on_bls12_377::EdwardsAffine as Edwards;
use blake2::Blake2s; use blake2::Blake2s;
use criterion::Criterion; use criterion::Criterion;
use crypto_primitives::signature::{schnorr::*, SignatureScheme}; use crypto_primitives::signature::{schnorr::*, SignatureScheme};
@ -90,7 +90,7 @@ mod affine {
} }
mod projective { mod projective {
use algebra::edwards_bls12::EdwardsProjective as Edwards;
use algebra::edwards_on_bls12_377::EdwardsProjective as Edwards;
use blake2::Blake2s; use blake2::Blake2s;
use criterion::Criterion; use criterion::Criterion;
use crypto_primitives::signature::{schnorr::*, SignatureScheme}; use crypto_primitives::signature::{schnorr::*, SignatureScheme};

+ 2
- 2
crypto-primitives/Cargo.toml

@ -46,6 +46,6 @@ std = ["r1cs", "algebra-core/std", "r1cs-core/std", "r1cs-std/std"]
parallel = ["std", "rayon", "gm17/parallel", "groth16/parallel", "ff-fft/parallel"] parallel = ["std", "rayon", "gm17/parallel", "groth16/parallel", "ff-fft/parallel"]
[dev-dependencies] [dev-dependencies]
algebra = { path = "../algebra", default-features = false, features = [ "jubjub", "bls12_377", "mnt4_298", "mnt6_298" ] }
r1cs-std = { path = "../r1cs-std", default-features = false, features = [ "jubjub", "bls12_377", "mnt4_298", "mnt6_298" ] }
algebra = { path = "../algebra", default-features = false, features = [ "edwards_on_bls12_381", "bls12_377", "mnt4_298", "mnt6_298" ] }
r1cs-std = { path = "../r1cs-std", default-features = false, features = [ "edwards_on_bls12_381", "bls12_377", "mnt4_298", "mnt6_298" ] }
rand_xorshift = { version = "0.2" } rand_xorshift = { version = "0.2" }

+ 1
- 1
crypto-primitives/src/commitment/blake2s/constraints.rs

@ -143,7 +143,7 @@ mod test {
}, },
*, *,
}; };
use algebra::{jubjub::Fq as Fr, test_rng};
use algebra::{edwards_on_bls12_381::Fq as Fr, test_rng};
use r1cs_core::ConstraintSystem; use r1cs_core::ConstraintSystem;
use r1cs_std::{prelude::*, test_constraint_system::TestConstraintSystem}; use r1cs_std::{prelude::*, test_constraint_system::TestConstraintSystem};
use rand::Rng; use rand::Rng;

+ 3
- 2
crypto-primitives/src/commitment/pedersen/constraints.rs

@ -200,7 +200,7 @@ where
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use algebra::{ use algebra::{
jubjub::{Fq, Fr, JubJubProjective as JubJub},
edwards_on_bls12_381::{EdwardsProjective as JubJub, Fq, Fr},
test_rng, ProjectiveCurve, UniformRand, test_rng, ProjectiveCurve, UniformRand,
}; };
@ -215,7 +215,8 @@ mod test {
}; };
use r1cs_core::ConstraintSystem; use r1cs_core::ConstraintSystem;
use r1cs_std::{ use r1cs_std::{
jubjub::JubJubGadget, prelude::*, test_constraint_system::TestConstraintSystem,
edwards_on_bls12_381::JubJubGadget, prelude::*,
test_constraint_system::TestConstraintSystem,
}; };
#[test] #[test]

+ 3
- 3
crypto-primitives/src/crh/bowe_hopwood/constraints.rs

@ -145,13 +145,13 @@ mod test {
FixedLengthCRH, FixedLengthCRHGadget, FixedLengthCRH, FixedLengthCRHGadget,
}; };
use algebra::{ use algebra::{
jubjub::{Fq as Fr, JubJubProjective as JubJub},
edwards_on_bls12_381::{EdwardsProjective as JubJub, Fq as Fr},
test_rng, ProjectiveCurve, test_rng, ProjectiveCurve,
}; };
use r1cs_core::ConstraintSystem; use r1cs_core::ConstraintSystem;
use r1cs_std::{ use r1cs_std::{
alloc::AllocGadget, jubjub::JubJubGadget, test_constraint_system::TestConstraintSystem,
uint8::UInt8,
alloc::AllocGadget, edwards_on_bls12_381::JubJubGadget,
test_constraint_system::TestConstraintSystem, uint8::UInt8,
}; };
type TestCRH = BoweHopwoodPedersenCRH<JubJub, Window>; type TestCRH = BoweHopwoodPedersenCRH<JubJub, Window>;

+ 3
- 3
crypto-primitives/src/crh/bowe_hopwood/mod.rs

@ -173,7 +173,7 @@ mod test {
crh::{bowe_hopwood::BoweHopwoodPedersenCRH, pedersen::PedersenWindow}, crh::{bowe_hopwood::BoweHopwoodPedersenCRH, pedersen::PedersenWindow},
FixedLengthCRH, FixedLengthCRH,
}; };
use algebra::{jubjub::JubJubProjective, test_rng};
use algebra::{edwards_on_bls12_381::EdwardsProjective, test_rng};
#[test] #[test]
fn test_simple_bh() { fn test_simple_bh() {
@ -186,9 +186,9 @@ mod test {
let rng = &mut test_rng(); let rng = &mut test_rng();
let params = let params =
<BoweHopwoodPedersenCRH<JubJubProjective, TestWindow> as FixedLengthCRH>::setup(rng)
<BoweHopwoodPedersenCRH<EdwardsProjective, TestWindow> as FixedLengthCRH>::setup(rng)
.unwrap(); .unwrap();
<BoweHopwoodPedersenCRH<JubJubProjective, TestWindow> as FixedLengthCRH>::evaluate(
<BoweHopwoodPedersenCRH<EdwardsProjective, TestWindow> as FixedLengthCRH>::evaluate(
&params, &params,
&[1, 2, 3], &[1, 2, 3],
) )

+ 3
- 2
crypto-primitives/src/crh/pedersen/constraints.rs

@ -133,12 +133,13 @@ mod test {
FixedLengthCRH, FixedLengthCRHGadget, FixedLengthCRH, FixedLengthCRHGadget,
}; };
use algebra::{ use algebra::{
jubjub::{Fq as Fr, JubJubProjective as JubJub},
edwards_on_bls12_381::{EdwardsProjective as JubJub, Fq as Fr},
test_rng, ProjectiveCurve, test_rng, ProjectiveCurve,
}; };
use r1cs_core::ConstraintSystem; use r1cs_core::ConstraintSystem;
use r1cs_std::{ use r1cs_std::{
jubjub::JubJubGadget, prelude::*, test_constraint_system::TestConstraintSystem,
edwards_on_bls12_381::JubJubGadget, prelude::*,
test_constraint_system::TestConstraintSystem,
}; };
use rand::Rng; use rand::Rng;

+ 4
- 2
crypto-primitives/src/merkle_tree/constraints.rs

@ -207,13 +207,15 @@ mod test {
}, },
merkle_tree::*, merkle_tree::*,
}; };
use algebra::jubjub::{Fq, JubJubAffine as JubJub};
use algebra::edwards_on_bls12_381::{EdwardsAffine as JubJub, Fq};
use r1cs_core::ConstraintSystem; use r1cs_core::ConstraintSystem;
use rand::SeedableRng; use rand::SeedableRng;
use rand_xorshift::XorShiftRng; use rand_xorshift::XorShiftRng;
use super::*; use super::*;
use r1cs_std::{jubjub::JubJubGadget, test_constraint_system::TestConstraintSystem};
use r1cs_std::{
edwards_on_bls12_381::JubJubGadget, test_constraint_system::TestConstraintSystem,
};
#[derive(Clone)] #[derive(Clone)]
pub(super) struct Window4x256; pub(super) struct Window4x256;

+ 1
- 1
crypto-primitives/src/merkle_tree/mod.rs

@ -369,7 +369,7 @@ mod test {
crh::{pedersen::*, *}, crh::{pedersen::*, *},
merkle_tree::*, merkle_tree::*,
}; };
use algebra::{jubjub::JubJubAffine as JubJub, Zero};
use algebra::{edwards_on_bls12_381::EdwardsAffine as JubJub, Zero};
use rand::SeedableRng; use rand::SeedableRng;
use rand_xorshift::XorShiftRng; use rand_xorshift::XorShiftRng;

+ 1
- 1
crypto-primitives/src/prf/blake2s/constraints.rs

@ -537,7 +537,7 @@ impl PRFGadget for Blake2sGadget
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use algebra::jubjub::Fq as Fr;
use algebra::edwards_on_bls12_381::Fq as Fr;
use rand::{Rng, SeedableRng}; use rand::{Rng, SeedableRng};
use rand_xorshift::XorShiftRng; use rand_xorshift::XorShiftRng;

+ 2
- 1
crypto-primitives/src/signature/mod.rs

@ -54,7 +54,8 @@ pub trait SignatureScheme {
mod test { mod test {
use crate::{signature::schnorr::SchnorrSignature, SignatureScheme}; use crate::{signature::schnorr::SchnorrSignature, SignatureScheme};
use algebra::{ use algebra::{
groups::Group, jubjub::JubJubAffine as JubJub, test_rng, to_bytes, ToBytes, UniformRand,
edwards_on_bls12_381::EdwardsAffine as JubJub, groups::Group, test_rng, to_bytes, ToBytes,
UniformRand,
}; };
use blake2::Blake2s; use blake2::Blake2s;

+ 4
- 4
r1cs-std/Cargo.toml

@ -35,12 +35,12 @@ algebra = { path = "../algebra", default-features = false, features = [ "bls12_3
[features] [features]
default = ["std"] default = ["std"]
full = [ "bls12_377", "jubjub", "edwards_bls12", "edwards_sw6", "mnt4_298", "mnt4_753", "mnt6_298", "mnt6_753" ]
full = [ "bls12_377", "edwards_on_bls12_381", "edwards_on_bls12_377", "edwards_on_cp6_782", "mnt4_298", "mnt4_753", "mnt6_298", "mnt6_753" ]
bls12_377 = [ "algebra/bls12_377" ] bls12_377 = [ "algebra/bls12_377" ]
jubjub = [ "algebra/jubjub" ]
edwards_bls12 = [ "algebra/edwards_bls12" ]
edwards_sw6 = [ "algebra/edwards_sw6" ]
edwards_on_bls12_381 = [ "algebra/edwards_on_bls12_381" ]
edwards_on_bls12_377 = [ "algebra/edwards_on_bls12_377" ]
edwards_on_cp6_782 = [ "algebra/edwards_on_cp6_782" ]
mnt4_298 = [ "algebra/mnt4_298" ] mnt4_298 = [ "algebra/mnt4_298" ]
mnt4_753 = [ "algebra/mnt4_753" ] mnt4_753 = [ "algebra/mnt4_753" ]
mnt6_298 = [ "algebra/mnt6_298" ] mnt6_298 = [ "algebra/mnt6_298" ]

+ 0
- 11
r1cs-std/src/instantiated/edwards_bls12/curves.rs

@ -1,11 +0,0 @@
use crate::groups::curves::twisted_edwards::AffineGadget;
use algebra::edwards_bls12::*;
use crate::edwards_bls12::FqGadget;
pub type EdwardsBlsGadget = AffineGadget<EdwardsParameters, Fq, FqGadget>;
#[test]
fn test() {
crate::groups::curves::twisted_edwards::test::<_, EdwardsParameters, EdwardsBlsGadget>();
}

+ 11
- 0
r1cs-std/src/instantiated/edwards_on_bls12_377/curves.rs

@ -0,0 +1,11 @@
use crate::groups::curves::twisted_edwards::AffineGadget;
use algebra::edwards_on_bls12_377::*;
use crate::edwards_on_bls12_377::FqGadget;
pub type EdwardsGadget = AffineGadget<EdwardsParameters, Fq, FqGadget>;
#[test]
fn test() {
crate::groups::curves::twisted_edwards::test::<_, EdwardsParameters, EdwardsGadget>();
}

r1cs-std/src/instantiated/edwards_sw6/fields.rs → r1cs-std/src/instantiated/edwards_on_bls12_377/fields.rs

@ -1,5 +1,5 @@
use crate::fields::fp::FpGadget; use crate::fields::fp::FpGadget;
use algebra::edwards_sw6::fq::Fq;
use algebra::edwards_on_bls12_377::fq::Fq;
pub type FqGadget = FpGadget<Fq>; pub type FqGadget = FpGadget<Fq>;

r1cs-std/src/instantiated/edwards_bls12/mod.rs → r1cs-std/src/instantiated/edwards_on_bls12_377/mod.rs


+ 11
- 0
r1cs-std/src/instantiated/edwards_on_bls12_381/curves.rs

@ -0,0 +1,11 @@
use crate::groups::curves::twisted_edwards::AffineGadget;
use algebra::edwards_on_bls12_381::*;
use crate::edwards_on_bls12_381::FqGadget;
pub type EdwardsGadget = AffineGadget<EdwardsParameters, Fq, FqGadget>;
#[test]
fn test() {
crate::groups::curves::twisted_edwards::test::<Fq, _, EdwardsGadget>();
}

+ 8
- 0
r1cs-std/src/instantiated/edwards_on_bls12_381/fields.rs

@ -0,0 +1,8 @@
use crate::fields::fp::FpGadget;
pub type FqGadget = FpGadget<algebra::edwards_on_bls12_381::Fq>;
#[test]
fn test() {
crate::fields::tests::field_test::<_, algebra::edwards_on_bls12_381::Fq, FqGadget>();
}

r1cs-std/src/instantiated/edwards_sw6/mod.rs → r1cs-std/src/instantiated/edwards_on_bls12_381/mod.rs


+ 11
- 0
r1cs-std/src/instantiated/edwards_on_cp6_782/curves.rs

@ -0,0 +1,11 @@
use crate::groups::curves::twisted_edwards::AffineGadget;
use algebra::edwards_on_cp6_782::*;
use crate::edwards_on_cp6_782::FqGadget;
pub type EdwardsGadget = AffineGadget<EdwardsParameters, Fq, FqGadget>;
#[test]
fn test() {
crate::groups::curves::twisted_edwards::test::<_, EdwardsParameters, EdwardsGadget>();
}

r1cs-std/src/instantiated/edwards_bls12/fields.rs → r1cs-std/src/instantiated/edwards_on_cp6_782/fields.rs

@ -1,5 +1,5 @@
use crate::fields::fp::FpGadget; use crate::fields::fp::FpGadget;
use algebra::edwards_bls12::fq::Fq;
use algebra::edwards_on_cp6_782::fq::Fq;
pub type FqGadget = FpGadget<Fq>; pub type FqGadget = FpGadget<Fq>;

r1cs-std/src/instantiated/jubjub/mod.rs → r1cs-std/src/instantiated/edwards_on_cp6_782/mod.rs


+ 0
- 11
r1cs-std/src/instantiated/edwards_sw6/curves.rs

@ -1,11 +0,0 @@
use crate::groups::curves::twisted_edwards::AffineGadget;
use algebra::edwards_sw6::*;
use crate::edwards_sw6::FqGadget;
pub type EdwardsSWGadget = AffineGadget<EdwardsParameters, Fq, FqGadget>;
#[test]
fn test() {
crate::groups::curves::twisted_edwards::test::<_, EdwardsParameters, EdwardsSWGadget>();
}

+ 0
- 11
r1cs-std/src/instantiated/jubjub/curves.rs

@ -1,11 +0,0 @@
use crate::groups::curves::twisted_edwards::AffineGadget;
use algebra::jubjub::*;
use crate::jubjub::FqGadget;
pub type JubJubGadget = AffineGadget<JubJubParameters, Fq, FqGadget>;
#[test]
fn test() {
crate::groups::curves::twisted_edwards::test::<Fq, _, JubJubGadget>();
}

+ 0
- 8
r1cs-std/src/instantiated/jubjub/fields.rs

@ -1,8 +0,0 @@
use crate::fields::fp::FpGadget;
pub type FqGadget = FpGadget<algebra::jubjub::Fq>;
#[test]
fn test() {
crate::fields::tests::field_test::<_, algebra::jubjub::Fq, FqGadget>();
}

+ 6
- 6
r1cs-std/src/instantiated/mod.rs

@ -1,14 +1,14 @@
#[cfg(feature = "bls12_377")] #[cfg(feature = "bls12_377")]
pub mod bls12_377; pub mod bls12_377;
#[cfg(feature = "edwards_bls12")]
pub mod edwards_bls12;
#[cfg(feature = "edwards_on_bls12_377")]
pub mod edwards_on_bls12_377;
#[cfg(feature = "edwards_sw6")]
pub mod edwards_sw6;
#[cfg(feature = "edwards_on_cp6_782")]
pub mod edwards_on_cp6_782;
#[cfg(feature = "jubjub")]
pub mod jubjub;
#[cfg(feature = "edwards_on_bls12_381")]
pub mod edwards_on_bls12_381;
#[cfg(feature = "mnt4_298")] #[cfg(feature = "mnt4_298")]
pub mod mnt4_298; pub mod mnt4_298;

+ 6
- 6
r1cs-std/src/lib.rs

@ -48,14 +48,14 @@ mod instantiated;
#[cfg(feature = "bls12_377")] #[cfg(feature = "bls12_377")]
pub use instantiated::bls12_377; pub use instantiated::bls12_377;
#[cfg(feature = "edwards_bls12")]
pub use instantiated::edwards_bls12;
#[cfg(feature = "edwards_on_bls12_377")]
pub use instantiated::edwards_on_bls12_377;
#[cfg(feature = "edwards_sw6")]
pub use instantiated::edwards_sw6;
#[cfg(feature = "edwards_on_cp6_782")]
pub use instantiated::edwards_on_cp6_782;
#[cfg(feature = "jubjub")]
pub use instantiated::jubjub;
#[cfg(feature = "edwards_on_bls12_381")]
pub use instantiated::edwards_on_bls12_381;
#[cfg(feature = "mnt4_298")] #[cfg(feature = "mnt4_298")]
pub use instantiated::mnt4_298; pub use instantiated::mnt4_298;

+ 4
- 1
r1cs-std/src/test_constraint_system.rs

@ -132,7 +132,10 @@ impl TestConstraintSystem {
fn compute_path(ns: &[String], this: String) -> String { fn compute_path(ns: &[String], this: String) -> String {
if this.chars().any(|a| a == '/') { if this.chars().any(|a| a == '/') {
panic!(format!("'/' is not allowed in namespace names. Error in namespace name: {:?}", this));
panic!(format!(
"'/' is not allowed in namespace names. Error in namespace name: {:?}",
this
));
} }
let mut name = String::new(); let mut name = String::new();

Loading…
Cancel
Save