Move generic circuit gadgets into bellman

This commit is contained in:
Jack Grigg
2019-08-06 01:13:35 +01:00
parent 61c633db1e
commit b8af749b40
25 changed files with 86 additions and 65 deletions

View File

@@ -6,11 +6,11 @@ use bellman::{
ConstraintSystem
};
use sapling_crypto::circuit::{
use bellman::gadgets::{
Assignment
};
use sapling_crypto::circuit::num::{
use bellman::gadgets::num::{
AllocatedNum,
Num
};
@@ -22,11 +22,11 @@ use sapling_crypto::jubjub::{
FixedGenerators
};
use sapling_crypto::circuit::lookup::{
use bellman::gadgets::lookup::{
lookup3_xy
};
use sapling_crypto::circuit::boolean::Boolean;
use bellman::gadgets::boolean::Boolean;
#[derive(Clone)]
pub struct EdwardsPoint<E: Engine> {
@@ -753,7 +753,7 @@ mod test {
use rand_core::{RngCore, SeedableRng};
use rand_xorshift::XorShiftRng;
use sapling_crypto::circuit::test::*;
use bellman::gadgets::test::*;
use sapling_crypto::jubjub::{
montgomery,
edwards,
@@ -769,7 +769,7 @@ mod test {
AllocatedNum,
fixed_base_multiplication
};
use sapling_crypto::circuit::boolean::{
use bellman::gadgets::boolean::{
Boolean,
AllocatedBit
};

View File

@@ -2,12 +2,12 @@ use super::ecc::{
MontgomeryPoint,
EdwardsPoint
};
use sapling_crypto::circuit::boolean::Boolean;
use bellman::gadgets::boolean::Boolean;
use sapling_crypto::jubjub::*;
use bellman::{
ConstraintSystem, SynthesisError
};
use sapling_crypto::circuit::lookup::*;
use bellman::gadgets::lookup::*;
pub use sapling_crypto::pedersen_hash::Personalization;
fn get_constant_bools(person: &Personalization) -> Vec<Boolean> {
@@ -110,8 +110,8 @@ pub fn pedersen_hash<E: JubjubEngine, CS>(
#[cfg(test)]
mod test {
use super::*;
use sapling_crypto::circuit::test::*;
use sapling_crypto::circuit::boolean::{Boolean, AllocatedBit};
use bellman::gadgets::test::*;
use bellman::gadgets::boolean::{Boolean, AllocatedBit};
use sapling_crypto::pedersen_hash;
use ff::PrimeField;
use pairing::bls12_381::{Bls12, Fr};

View File

@@ -19,13 +19,13 @@ use sapling_crypto::primitives::{
PaymentAddress
};
use sapling_crypto::circuit::Assignment;
use sapling_crypto::circuit::boolean;
use bellman::gadgets::Assignment;
use bellman::gadgets::boolean;
use super::ecc;
use super::pedersen_hash;
use sapling_crypto::circuit::blake2s;
use sapling_crypto::circuit::num;
use sapling_crypto::circuit::multipack;
use bellman::gadgets::blake2s;
use bellman::gadgets::num;
use bellman::gadgets::multipack;
pub const TREE_DEPTH: usize = zcash_primitives::sapling::SAPLING_COMMITMENT_TREE_DEPTH;
@@ -598,12 +598,12 @@ impl<'a, E: JubjubEngine> Circuit<E> for Output<'a, E> {
#[test]
fn test_input_circuit_with_bls12_381() {
use bellman::gadgets::test::*;
use ff::{BitIterator, Field};
use pairing::bls12_381::*;
use rand_core::{RngCore, SeedableRng};
use rand_xorshift::XorShiftRng;
use sapling_crypto::{
circuit::test::*,
jubjub::{JubjubBls12, fs, edwards},
pedersen_hash,
primitives::{Diversifier, Note, ProofGenerationKey},
@@ -742,12 +742,12 @@ fn test_input_circuit_with_bls12_381() {
#[test]
fn test_output_circuit_with_bls12_381() {
use bellman::gadgets::test::*;
use ff::Field;
use pairing::bls12_381::*;
use rand_core::{RngCore, SeedableRng};
use rand_xorshift::XorShiftRng;
use sapling_crypto::{
circuit::test::*,
jubjub::{JubjubBls12, fs, edwards},
primitives::{Diversifier, ProofGenerationKey},
};

View File

@@ -1,9 +1,9 @@
use pairing::{Engine};
use bellman::{ConstraintSystem, SynthesisError};
use sapling_crypto::circuit::sha256::{
use bellman::gadgets::sha256::{
sha256
};
use sapling_crypto::circuit::boolean::{
use bellman::gadgets::boolean::{
Boolean
};

View File

@@ -1,9 +1,9 @@
use pairing::{Engine};
use bellman::{ConstraintSystem, SynthesisError};
use sapling_crypto::circuit::sha256::{
use bellman::gadgets::sha256::{
sha256_block_no_padding
};
use sapling_crypto::circuit::boolean::{
use bellman::gadgets::boolean::{
AllocatedBit,
Boolean
};

View File

@@ -1,11 +1,11 @@
use ff::Field;
use pairing::Engine;
use bellman::{ConstraintSystem, SynthesisError, Circuit, LinearCombination};
use sapling_crypto::circuit::boolean::{
use bellman::gadgets::boolean::{
AllocatedBit,
Boolean
};
use sapling_crypto::circuit::multipack::pack_into_inputs;
use bellman::gadgets::multipack::pack_into_inputs;
mod prfs;
mod commitment;
@@ -355,7 +355,7 @@ fn witness_u252<E, CS>(
#[test]
fn test_sprout_constraints() {
use pairing::bls12_381::{Bls12};
use sapling_crypto::circuit::test::*;
use bellman::gadgets::test::*;
use byteorder::{WriteBytesExt, ReadBytesExt, LittleEndian};
@@ -479,7 +479,7 @@ fn test_sprout_constraints() {
expected_inputs.write_u64::<LittleEndian>(vpub_old.unwrap()).unwrap();
expected_inputs.write_u64::<LittleEndian>(vpub_new.unwrap()).unwrap();
use sapling_crypto::circuit::multipack;
use bellman::gadgets::multipack;
let expected_inputs = multipack::bytes_to_bits(&expected_inputs);
let expected_inputs = multipack::compute_multipacking::<Bls12>(&expected_inputs);

View File

@@ -1,6 +1,6 @@
use pairing::{Engine};
use bellman::{ConstraintSystem, SynthesisError};
use sapling_crypto::circuit::boolean::{Boolean};
use bellman::gadgets::boolean::{Boolean};
use super::*;
use super::prfs::*;

View File

@@ -1,9 +1,9 @@
use pairing::{Engine};
use bellman::{ConstraintSystem, SynthesisError};
use sapling_crypto::circuit::sha256::{
use bellman::gadgets::sha256::{
sha256_block_no_padding
};
use sapling_crypto::circuit::boolean::{
use bellman::gadgets::boolean::{
Boolean
};

View File

@@ -1,11 +1,13 @@
use bellman::groth16::{
create_random_proof, verify_proof, Parameters, PreparedVerifyingKey, Proof,
use bellman::{
gadgets::multipack,
groth16::{
create_random_proof, verify_proof, Parameters, PreparedVerifyingKey, Proof,
},
};
use ff::Field;
use pairing::bls12_381::{Bls12, Fr};
use rand_os::OsRng;
use sapling_crypto::{
circuit::multipack,
jubjub::{edwards, fs::Fs, FixedGenerators, JubjubBls12, Unknown},
primitives::{Diversifier, Note, PaymentAddress, ProofGenerationKey, ValueCommitment},
};

View File

@@ -1,10 +1,10 @@
use bellman::groth16::{verify_proof, PreparedVerifyingKey, Proof};
use bellman::{
gadgets::multipack,
groth16::{verify_proof, PreparedVerifyingKey, Proof},
};
use ff::Field;
use pairing::bls12_381::{Bls12, Fr};
use sapling_crypto::{
circuit::multipack,
jubjub::{edwards, FixedGenerators, JubjubBls12, Unknown},
};
use sapling_crypto::jubjub::{edwards, FixedGenerators, JubjubBls12, Unknown};
use zcash_primitives::{
redjubjub::{PublicKey, Signature},
transaction::components::Amount,