Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
b11ea2d
Initial commit.
ebfull Jun 26, 2017
cf7d7e8
Add more stuff to the Cargo.toml files.
ebfull Jun 26, 2017
cb0c8f1
Fix description of `ff`.
ebfull Jun 26, 2017
6402b74
Fix comment.
ebfull Jun 26, 2017
e97f0df
Fix another comment.
ebfull Jun 26, 2017
13a822f
Add auto-derivation of prime fields, and modify the traits a little bit.
ebfull Jun 26, 2017
0395270
Absolute path to rand.
ebfull Jun 26, 2017
e6ad371
Remove dead code.
ebfull Jun 26, 2017
bbbd397
Add more efficient squaring implementation.
ebfull Jun 26, 2017
9aceb63
Add Tonelli-Shanks sqrt for 1 mod 16 primes.
ebfull Jun 27, 2017
b1f392a
Add multiplicative generator and other useful constants.
ebfull Jun 27, 2017
02f503c
Modify README.
ebfull Jun 27, 2017
bbc7b44
Comments and slight refactoring.
ebfull Jun 27, 2017
134b53e
Version bump.
ebfull Jun 27, 2017
c7252a4
Update README/Cargo.toml with correct documentation links.
ebfull Jun 27, 2017
755fc7a
cargo fmt
str4d Jun 26, 2018
428f463
Migrate ff_derive to syn 0.14 and quote 0.6
str4d Jun 27, 2018
1a3a2be
Update other ff_derive dependencies
str4d Jun 27, 2018
8201a39
Pull in arith changes from pairing
str4d Jun 27, 2018
58cb06e
Pull in trait changes from pairing
str4d Jun 27, 2018
29a9161
Implement changes to traits in ff_derive
str4d Jun 28, 2018
5a48059
Integrate changes to trait impls from pairing into ff_derive
str4d Jul 1, 2018
b0b754b
Return constants and sqrt impls separately for individual rendering
str4d Jul 1, 2018
623dbd0
[MOVEONLY] Move generated code around slightly in ff_derive
str4d Jul 1, 2018
4c98459
Add full paths for some manually-implemented derives
str4d Jul 2, 2018
91a8dc8
Update rand crate
str4d Jul 2, 2018
f6d9ec8
Initial commit
ebfull Jul 2, 2018
729138a
Merge pull request #1 from str4d/updates
ebfull Jul 2, 2018
44b601b
Adjust versions
ebfull Jul 2, 2018
1db099f
Use ff crate for Field traits
str4d Jul 1, 2018
d9d711e
Use explicit imports instead of re-exporting the ff crate
str4d Jul 1, 2018
a9d8079
Replace implementations of Fq and Fr with derives
str4d Jul 2, 2018
defdf8d
Connect ff u128-support to pairing u128-support
str4d Jul 2, 2018
bb22a16
Update authors
str4d Jul 2, 2018
c49590b
Change all remaining uses of *Field to reference ff crate
str4d Jul 2, 2018
06a1527
Add missing SqrtField import to benches
str4d Jul 2, 2018
002173e
Update README.md
str4d Jul 2, 2018
69ce66a
Place ff_derive re-exports behind a feature
str4d Jul 2, 2018
0eb9f50
Remove u128-support feature and arithmetic
str4d Jul 2, 2018
2067360
Add ScalarEngine trait
str4d Jul 2, 2018
526676e
Bump version to 0.4.0
str4d Jul 2, 2018
661558e
Merge pull request #5 from str4d/more-updates
ebfull Jul 3, 2018
94cacc6
Migrate curve traits and tests, and WNAF, from pairing
str4d Jul 2, 2018
cc5b835
Start using cargo-clippy for CI.
ebfull Jul 4, 2018
4752a91
Remove clippy from dependencies.
str4d Jul 2, 2018
c5b883f
Migrate to ff 0.4
str4d Jul 3, 2018
fa81037
cargo fmt
str4d Jul 3, 2018
183a64b
Auto merge of #90 - str4d:ff, r=ebfull
bmerge Jul 5, 2018
2ffa94f
Merge pull request #1 from str4d/from-pairing
ebfull Jul 5, 2018
ef56fab
Update version
ebfull Jul 5, 2018
7dfc50e
Use group crate for curve traits
str4d Jul 2, 2018
3d41ee5
Remove now-unused imports from root
str4d Jul 2, 2018
718b25c
Use ff crate for Field traits
str4d Jul 2, 2018
3e8f2f8
Use group crate for curve traits and wNAF
str4d Jul 6, 2018
276e09f
Use ff:ScalarEngine instead of pairing::Engine in bellman core
str4d Jul 6, 2018
4272cfa
Make pairing and groth16 optional 🎉
str4d Jul 6, 2018
fe16e4a
Merge commit '183a64b08e9dc7067f78624ec161371f1829623e' into ff-traits
str4d Jan 6, 2019
9f7e5fa
Dependency updates after pairing update
str4d Nov 9, 2018
794cf79
Merge commit '3d41ee5abaa4888ff3607689aba007be8856816d' into ff-traits
str4d Jan 6, 2019
88746e7
Cargo.lock changes after pairing update
str4d Nov 10, 2018
76cd0d9
Merge commit '4272cfa5b0dceac471bef115955e1534be84a018' into ff-traits
str4d Jan 6, 2019
22ccd1b
Update sapling-crypto crate to use ff crate
str4d Nov 10, 2018
2e40895
Update zip32 crate to use ff crate
str4d Nov 10, 2018
538de48
Update zcash_primitives crate to use ff crate
str4d Jan 6, 2019
00983c4
Update zcash_proofs crate to use ff crate
str4d Jan 6, 2019
0795509
Update librustzcash crate to use ff crate
str4d Jan 3, 2019
af9f9c1
Add 'ff/' from commit '661558e0c8a5e02e08dac6530d39b2e38919aa04'
str4d Jan 6, 2019
b1ce390
Add 'group/' from commit 'ef56fabf7ba3ed990a7886836c855298c9c5eefa'
str4d Jan 6, 2019
482bef8
Add ff and group crates to Cargo workspace
str4d Jan 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
368 changes: 28 additions & 340 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[workspace]
members = [
"bellman",
"ff",
"group",
"librustzcash",
"pairing",
"sapling-crypto",
Expand Down
12 changes: 10 additions & 2 deletions bellman/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ version = "0.1.0"
[dependencies]
rand = "0.4"
bit-vec = "0.4.4"
ff = { path = "../ff" }
futures = "0.1"
futures-cpupool = "0.1"
group = { path = "../group" }
num_cpus = "1"
crossbeam = "0.3"
pairing = { path = "../pairing" }
pairing = { path = "../pairing", optional = true }
byteorder = "1"

[features]
default = []
groth16 = ["pairing"]
default = ["groth16"]

[[test]]
name = "mimc"
path = "tests/mimc.rs"
required-features = ["groth16"]
39 changes: 19 additions & 20 deletions bellman/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@
//! This allows us to perform polynomial operations in O(n)
//! by performing an O(n log n) FFT over such a domain.

use pairing::{
Engine,
Field,
PrimeField,
CurveProjective
};
use ff::{Field, PrimeField, ScalarEngine};
use group::CurveProjective;

use super::{
SynthesisError
};

use super::multicore::Worker;

pub struct EvaluationDomain<E: Engine, G: Group<E>> {
pub struct EvaluationDomain<E: ScalarEngine, G: Group<E>> {
coeffs: Vec<G>,
exp: u32,
omega: E::Fr,
Expand All @@ -32,7 +28,7 @@ pub struct EvaluationDomain<E: Engine, G: Group<E>> {
minv: E::Fr
}

impl<E: Engine, G: Group<E>> EvaluationDomain<E, G> {
impl<E: ScalarEngine, G: Group<E>> EvaluationDomain<E, G> {
pub fn as_ref(&self) -> &[G] {
&self.coeffs
}
Expand Down Expand Up @@ -189,7 +185,7 @@ impl<E: Engine, G: Group<E>> EvaluationDomain<E, G> {
}
}

pub trait Group<E: Engine>: Sized + Copy + Clone + Send + Sync {
pub trait Group<E: ScalarEngine>: Sized + Copy + Clone + Send + Sync {
fn group_zero() -> Self;
fn group_mul_assign(&mut self, by: &E::Fr);
fn group_add_assign(&mut self, other: &Self);
Expand Down Expand Up @@ -227,23 +223,23 @@ impl<G: CurveProjective> Group<G::Engine> for Point<G> {
}
}

pub struct Scalar<E: Engine>(pub E::Fr);
pub struct Scalar<E: ScalarEngine>(pub E::Fr);

impl<E: Engine> PartialEq for Scalar<E> {
impl<E: ScalarEngine> PartialEq for Scalar<E> {
fn eq(&self, other: &Scalar<E>) -> bool {
self.0 == other.0
}
}

impl<E: Engine> Copy for Scalar<E> { }
impl<E: ScalarEngine> Copy for Scalar<E> { }

impl<E: Engine> Clone for Scalar<E> {
impl<E: ScalarEngine> Clone for Scalar<E> {
fn clone(&self) -> Scalar<E> {
*self
}
}

impl<E: Engine> Group<E> for Scalar<E> {
impl<E: ScalarEngine> Group<E> for Scalar<E> {
fn group_zero() -> Self {
Scalar(E::Fr::zero())
}
Expand All @@ -258,7 +254,7 @@ impl<E: Engine> Group<E> for Scalar<E> {
}
}

fn best_fft<E: Engine, T: Group<E>>(a: &mut [T], worker: &Worker, omega: &E::Fr, log_n: u32)
fn best_fft<E: ScalarEngine, T: Group<E>>(a: &mut [T], worker: &Worker, omega: &E::Fr, log_n: u32)
{
let log_cpus = worker.log_num_cpus();

Expand All @@ -269,7 +265,7 @@ fn best_fft<E: Engine, T: Group<E>>(a: &mut [T], worker: &Worker, omega: &E::Fr,
}
}

fn serial_fft<E: Engine, T: Group<E>>(a: &mut [T], omega: &E::Fr, log_n: u32)
fn serial_fft<E: ScalarEngine, T: Group<E>>(a: &mut [T], omega: &E::Fr, log_n: u32)
{
fn bitreverse(mut n: u32, l: u32) -> u32 {
let mut r = 0;
Expand Down Expand Up @@ -314,7 +310,7 @@ fn serial_fft<E: Engine, T: Group<E>>(a: &mut [T], omega: &E::Fr, log_n: u32)
}
}

fn parallel_fft<E: Engine, T: Group<E>>(
fn parallel_fft<E: ScalarEngine, T: Group<E>>(
a: &mut [T],
worker: &Worker,
omega: &E::Fr,
Expand Down Expand Up @@ -375,12 +371,13 @@ fn parallel_fft<E: Engine, T: Group<E>>(

// Test multiplying various (low degree) polynomials together and
// comparing with naive evaluations.
#[cfg(feature = "pairing")]
#[test]
fn polynomial_arith() {
use pairing::bls12_381::Bls12;
use rand::{self, Rand};

fn test_mul<E: Engine, R: rand::Rng>(rng: &mut R)
fn test_mul<E: ScalarEngine, R: rand::Rng>(rng: &mut R)
{
let worker = Worker::new();

Expand Down Expand Up @@ -422,12 +419,13 @@ fn polynomial_arith() {
test_mul::<Bls12, _>(rng);
}

#[cfg(feature = "pairing")]
#[test]
fn fft_composition() {
use pairing::bls12_381::Bls12;
use rand;

fn test_comp<E: Engine, R: rand::Rng>(rng: &mut R)
fn test_comp<E: ScalarEngine, R: rand::Rng>(rng: &mut R)
{
let worker = Worker::new();

Expand Down Expand Up @@ -460,13 +458,14 @@ fn fft_composition() {
test_comp::<Bls12, _>(rng);
}

#[cfg(feature = "pairing")]
#[test]
fn parallel_fft_consistency() {
use pairing::bls12_381::Bls12;
use rand::{self, Rand};
use std::cmp::min;

fn test_consistency<E: Engine, R: rand::Rng>(rng: &mut R)
fn test_consistency<E: ScalarEngine, R: rand::Rng>(rng: &mut R)
{
let worker = Worker::new();

Expand Down
11 changes: 3 additions & 8 deletions bellman/src/groth16/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ use rand::Rng;

use std::sync::Arc;

use pairing::{
Engine,
PrimeField,
Field,
Wnaf,
CurveProjective,
CurveAffine
};
use ff::{Field, PrimeField};
use group::{CurveAffine, CurveProjective, Wnaf};
use pairing::Engine;

use super::{
Parameters,
Expand Down
10 changes: 5 additions & 5 deletions bellman/src/groth16/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use group::{CurveAffine, EncodedPoint};
use pairing::{
Engine,
CurveAffine,
EncodedPoint
PairingCurveAffine,
};

use ::{
Expand Down Expand Up @@ -385,9 +385,9 @@ pub struct PreparedVerifyingKey<E: Engine> {
/// Pairing result of alpha*beta
alpha_g1_beta_g2: E::Fqk,
/// -gamma in G2
neg_gamma_g2: <E::G2Affine as CurveAffine>::Prepared,
neg_gamma_g2: <E::G2Affine as PairingCurveAffine>::Prepared,
/// -delta in G2
neg_delta_g2: <E::G2Affine as CurveAffine>::Prepared,
neg_delta_g2: <E::G2Affine as PairingCurveAffine>::Prepared,
/// Copy of IC from `VerifiyingKey`.
ic: Vec<E::G1Affine>
}
Expand Down Expand Up @@ -486,8 +486,8 @@ mod test_with_bls12_381 {
use super::*;
use {Circuit, SynthesisError, ConstraintSystem};

use ff::Field;
use rand::{Rand, thread_rng};
use pairing::{Field};
use pairing::bls12_381::{Bls12, Fr};

#[test]
Expand Down
10 changes: 3 additions & 7 deletions bellman/src/groth16/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ use std::sync::Arc;

use futures::Future;

use pairing::{
Engine,
PrimeField,
Field,
CurveProjective,
CurveAffine
};
use ff::{Field, PrimeField};
use group::{CurveAffine, CurveProjective};
use pairing::Engine;

use super::{
ParameterSource,
Expand Down
44 changes: 21 additions & 23 deletions bellman/src/groth16/tests/dummy_engine.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
use pairing::{
Engine,
PrimeField,
PrimeFieldRepr,
Field,
SqrtField,
LegendreSymbol,
CurveProjective,
CurveAffine,
PrimeFieldDecodingError,
GroupDecodingError,
EncodedPoint
};
use ff::{
Field, LegendreSymbol, PrimeField, PrimeFieldDecodingError,
PrimeFieldRepr, ScalarEngine, SqrtField};
use group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError};
use pairing::{Engine, PairingCurveAffine};

use std::cmp::Ordering;
use std::fmt;
Expand Down Expand Up @@ -263,8 +255,11 @@ impl PrimeField for Fr {
#[derive(Clone)]
pub struct DummyEngine;

impl Engine for DummyEngine {
impl ScalarEngine for DummyEngine {
type Fr = Fr;
}

impl Engine for DummyEngine {
type G1 = Fr;
type G1Affine = Fr;
type G2 = Fr;
Expand All @@ -277,8 +272,8 @@ impl Engine for DummyEngine {

fn miller_loop<'a, I>(i: I) -> Self::Fqk
where I: IntoIterator<Item=&'a (
&'a <Self::G1Affine as CurveAffine>::Prepared,
&'a <Self::G2Affine as CurveAffine>::Prepared
&'a <Self::G1Affine as PairingCurveAffine>::Prepared,
&'a <Self::G2Affine as PairingCurveAffine>::Prepared
)>
{
let mut acc = <Fr as Field>::zero();
Expand Down Expand Up @@ -401,11 +396,8 @@ impl EncodedPoint for FakePoint {
}

impl CurveAffine for Fr {
type Pair = Fr;
type PairingResult = Fr;
type Compressed = FakePoint;
type Uncompressed = FakePoint;
type Prepared = Fr;
type Projective = Fr;
type Base = Fr;
type Scalar = Fr;
Expand Down Expand Up @@ -437,15 +429,21 @@ impl CurveAffine for Fr {
res
}

fn into_projective(&self) -> Self::Projective {
*self
}
}

impl PairingCurveAffine for Fr {
type Prepared = Fr;
type Pair = Fr;
type PairingResult = Fr;

fn prepare(&self) -> Self::Prepared {
*self
}

fn pairing_with(&self, other: &Self::Pair) -> Self::PairingResult {
self.mul(*other)
}

fn into_projective(&self) -> Self::Projective {
*self
}
}
7 changes: 2 additions & 5 deletions bellman/src/groth16/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use pairing::{
Engine,
Field,
PrimeField
};
use ff::{Field, PrimeField};
use pairing::Engine;

mod dummy_engine;
use self::dummy_engine::*;
Expand Down
9 changes: 3 additions & 6 deletions bellman/src/groth16/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use pairing::{
Engine,
CurveProjective,
CurveAffine,
PrimeField
};
use ff::PrimeField;
use group::{CurveAffine, CurveProjective};
use pairing::{Engine, PairingCurveAffine};

use super::{
Proof,
Expand Down
Loading