mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-02-12 01:55:48 +00:00
Move generic circuit gadgets into bellman
This commit is contained in:
parent
61c633db1e
commit
b8af749b40
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -57,16 +57,20 @@ name = "bellman"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"blake2s_simd 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ff 0.4.0",
|
"ff 0.4.0",
|
||||||
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"group 0.1.0",
|
"group 0.1.0",
|
||||||
|
"hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pairing 0.14.2",
|
"pairing 0.14.2",
|
||||||
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -10,6 +10,7 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bit-vec = "0.4.4"
|
bit-vec = "0.4.4"
|
||||||
|
blake2s_simd = "0.5"
|
||||||
ff = { path = "../ff" }
|
ff = { path = "../ff" }
|
||||||
futures = "0.1"
|
futures = "0.1"
|
||||||
futures-cpupool = { version = "0.1", optional = true }
|
futures-cpupool = { version = "0.1", optional = true }
|
||||||
@ -21,7 +22,10 @@ rand_core = "0.5"
|
|||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
hex-literal = "0.1"
|
||||||
rand = "0.7"
|
rand = "0.7"
|
||||||
|
rand_xorshift = "0.2"
|
||||||
|
sha2 = "0.8"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
groth16 = ["pairing"]
|
groth16 = ["pairing"]
|
||||||
|
@ -9,7 +9,7 @@ pub mod lookup;
|
|||||||
pub mod multipack;
|
pub mod multipack;
|
||||||
pub mod sha256;
|
pub mod sha256;
|
||||||
|
|
||||||
use bellman::{
|
use crate::{
|
||||||
SynthesisError
|
SynthesisError
|
||||||
};
|
};
|
||||||
|
|
@ -2,7 +2,7 @@ use pairing::{
|
|||||||
Engine,
|
Engine,
|
||||||
};
|
};
|
||||||
|
|
||||||
use bellman::{
|
use crate::{
|
||||||
SynthesisError,
|
SynthesisError,
|
||||||
ConstraintSystem
|
ConstraintSystem
|
||||||
};
|
};
|
||||||
@ -325,10 +325,10 @@ mod test {
|
|||||||
use rand_core::{RngCore, SeedableRng};
|
use rand_core::{RngCore, SeedableRng};
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
||||||
|
|
||||||
use ::circuit::boolean::{Boolean, AllocatedBit};
|
use crate::gadgets::boolean::{Boolean, AllocatedBit};
|
||||||
use ::circuit::test::TestConstraintSystem;
|
use crate::gadgets::test::TestConstraintSystem;
|
||||||
use super::blake2s;
|
use super::blake2s;
|
||||||
use bellman::{ConstraintSystem};
|
use crate::{ConstraintSystem};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_blank_hash() {
|
fn test_blank_hash() {
|
@ -1,7 +1,7 @@
|
|||||||
use ff::{BitIterator, Field, PrimeField};
|
use ff::{BitIterator, Field, PrimeField};
|
||||||
use pairing::Engine;
|
use pairing::Engine;
|
||||||
|
|
||||||
use bellman::{
|
use crate::{
|
||||||
ConstraintSystem,
|
ConstraintSystem,
|
||||||
SynthesisError,
|
SynthesisError,
|
||||||
LinearCombination,
|
LinearCombination,
|
||||||
@ -801,10 +801,10 @@ impl From<AllocatedBit> for Boolean {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use bellman::{ConstraintSystem};
|
use crate::{ConstraintSystem};
|
||||||
use ff::{Field, PrimeField};
|
use ff::{Field, PrimeField};
|
||||||
use pairing::bls12_381::{Bls12, Fr};
|
use pairing::bls12_381::{Bls12, Fr};
|
||||||
use ::circuit::test::*;
|
use crate::gadgets::test::*;
|
||||||
use super::{
|
use super::{
|
||||||
AllocatedBit,
|
AllocatedBit,
|
||||||
Boolean,
|
Boolean,
|
@ -7,7 +7,7 @@ use super::num::{
|
|||||||
Num
|
Num
|
||||||
};
|
};
|
||||||
use super::boolean::Boolean;
|
use super::boolean::Boolean;
|
||||||
use bellman::{
|
use crate::{
|
||||||
ConstraintSystem
|
ConstraintSystem
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -197,8 +197,8 @@ pub fn lookup3_xy_with_conditional_negation<E: Engine, CS>(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use ::circuit::test::*;
|
use crate::gadgets::test::*;
|
||||||
use ::circuit::boolean::{Boolean, AllocatedBit};
|
use crate::gadgets::boolean::{Boolean, AllocatedBit};
|
||||||
use pairing::bls12_381::{Bls12, Fr};
|
use pairing::bls12_381::{Bls12, Fr};
|
||||||
use rand_core::{RngCore, SeedableRng};
|
use rand_core::{RngCore, SeedableRng};
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
@ -1,7 +1,7 @@
|
|||||||
use ff::{Field, PrimeField};
|
use ff::{Field, PrimeField};
|
||||||
use pairing::Engine;
|
use pairing::Engine;
|
||||||
|
|
||||||
use bellman::{
|
use crate::{
|
||||||
SynthesisError,
|
SynthesisError,
|
||||||
ConstraintSystem,
|
ConstraintSystem,
|
||||||
LinearCombination,
|
LinearCombination,
|
@ -1,6 +1,6 @@
|
|||||||
use ff::{Field, PrimeField};
|
use ff::{Field, PrimeField};
|
||||||
use pairing::Engine;
|
use pairing::Engine;
|
||||||
use bellman::{ConstraintSystem, SynthesisError};
|
use crate::{ConstraintSystem, SynthesisError};
|
||||||
use super::boolean::{Boolean};
|
use super::boolean::{Boolean};
|
||||||
use super::num::Num;
|
use super::num::Num;
|
||||||
use super::Assignment;
|
use super::Assignment;
|
||||||
@ -80,12 +80,12 @@ pub fn compute_multipacking<E: Engine>(
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_multipacking() {
|
fn test_multipacking() {
|
||||||
use bellman::{ConstraintSystem};
|
use crate::{ConstraintSystem};
|
||||||
use pairing::bls12_381::{Bls12};
|
use pairing::bls12_381::{Bls12};
|
||||||
use rand_core::{RngCore, SeedableRng};
|
use rand_core::{RngCore, SeedableRng};
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
||||||
|
|
||||||
use ::circuit::test::*;
|
use crate::gadgets::test::*;
|
||||||
use super::boolean::{AllocatedBit, Boolean};
|
use super::boolean::{AllocatedBit, Boolean};
|
||||||
|
|
||||||
let mut rng = XorShiftRng::from_seed([
|
let mut rng = XorShiftRng::from_seed([
|
@ -1,7 +1,7 @@
|
|||||||
use ff::{BitIterator, Field, PrimeField, PrimeFieldRepr};
|
use ff::{BitIterator, Field, PrimeField, PrimeFieldRepr};
|
||||||
use pairing::Engine;
|
use pairing::Engine;
|
||||||
|
|
||||||
use bellman::{
|
use crate::{
|
||||||
SynthesisError,
|
SynthesisError,
|
||||||
ConstraintSystem,
|
ConstraintSystem,
|
||||||
LinearCombination,
|
LinearCombination,
|
||||||
@ -455,13 +455,13 @@ impl<E: Engine> Num<E> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use bellman::{ConstraintSystem};
|
use crate::{ConstraintSystem};
|
||||||
use ff::{BitIterator, Field, PrimeField};
|
use ff::{BitIterator, Field, PrimeField};
|
||||||
use pairing::bls12_381::{Bls12, Fr};
|
use pairing::bls12_381::{Bls12, Fr};
|
||||||
use rand_core::SeedableRng;
|
use rand_core::SeedableRng;
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
||||||
|
|
||||||
use ::circuit::test::*;
|
use crate::gadgets::test::*;
|
||||||
use super::{AllocatedNum, Boolean};
|
use super::{AllocatedNum, Boolean};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
@ -1,7 +1,7 @@
|
|||||||
use super::uint32::UInt32;
|
use super::uint32::UInt32;
|
||||||
use super::multieq::MultiEq;
|
use super::multieq::MultiEq;
|
||||||
use super::boolean::Boolean;
|
use super::boolean::Boolean;
|
||||||
use bellman::{ConstraintSystem, SynthesisError};
|
use crate::{ConstraintSystem, SynthesisError};
|
||||||
use pairing::Engine;
|
use pairing::Engine;
|
||||||
|
|
||||||
const ROUND_CONSTANTS: [u32; 64] = [
|
const ROUND_CONSTANTS: [u32; 64] = [
|
||||||
@ -305,9 +305,9 @@ fn sha256_compression_function<E, CS>(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use circuit::boolean::AllocatedBit;
|
use crate::gadgets::boolean::AllocatedBit;
|
||||||
use pairing::bls12_381::Bls12;
|
use pairing::bls12_381::Bls12;
|
||||||
use circuit::test::TestConstraintSystem;
|
use crate::gadgets::test::TestConstraintSystem;
|
||||||
use rand_core::{RngCore, SeedableRng};
|
use rand_core::{RngCore, SeedableRng};
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
use ff::{Field, PrimeField, PrimeFieldRepr};
|
use ff::{Field, PrimeField, PrimeFieldRepr};
|
||||||
use pairing::Engine;
|
use pairing::Engine;
|
||||||
|
|
||||||
use bellman::{
|
use crate::{
|
||||||
LinearCombination,
|
LinearCombination,
|
||||||
SynthesisError,
|
SynthesisError,
|
||||||
ConstraintSystem,
|
ConstraintSystem,
|
@ -1,7 +1,7 @@
|
|||||||
use ff::{Field, PrimeField};
|
use ff::{Field, PrimeField};
|
||||||
use pairing::Engine;
|
use pairing::Engine;
|
||||||
|
|
||||||
use bellman::{
|
use crate::{
|
||||||
SynthesisError,
|
SynthesisError,
|
||||||
ConstraintSystem,
|
ConstraintSystem,
|
||||||
LinearCombination
|
LinearCombination
|
||||||
@ -409,13 +409,13 @@ impl UInt32 {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use ::circuit::boolean::{Boolean};
|
use crate::gadgets::boolean::{Boolean};
|
||||||
use super::{UInt32};
|
use super::{UInt32};
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
use pairing::bls12_381::{Bls12};
|
use pairing::bls12_381::{Bls12};
|
||||||
use ::circuit::test::*;
|
use crate::gadgets::test::*;
|
||||||
use bellman::{ConstraintSystem};
|
use crate::{ConstraintSystem};
|
||||||
use circuit::multieq::MultiEq;
|
use crate::gadgets::multieq::MultiEq;
|
||||||
use rand_core::{RngCore, SeedableRng};
|
use rand_core::{RngCore, SeedableRng};
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
||||||
|
|
@ -6,6 +6,7 @@ extern crate rand_core;
|
|||||||
|
|
||||||
extern crate futures;
|
extern crate futures;
|
||||||
extern crate bit_vec;
|
extern crate bit_vec;
|
||||||
|
extern crate blake2s_simd;
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
|
|
||||||
#[cfg(feature = "multicore")]
|
#[cfg(feature = "multicore")]
|
||||||
@ -15,9 +16,20 @@ extern crate futures_cpupool;
|
|||||||
#[cfg(feature = "multicore")]
|
#[cfg(feature = "multicore")]
|
||||||
extern crate num_cpus;
|
extern crate num_cpus;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[macro_use]
|
||||||
|
extern crate hex_literal;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
extern crate rand_xorshift;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
extern crate sha2;
|
||||||
|
|
||||||
|
pub mod gadgets;
|
||||||
pub mod multicore;
|
pub mod multicore;
|
||||||
mod multiexp;
|
mod multiexp;
|
||||||
pub mod domain;
|
pub mod domain;
|
||||||
|
@ -17,7 +17,6 @@ use ff::{PrimeField, PrimeFieldRepr};
|
|||||||
use pairing::bls12_381::{Bls12, Fr, FrRepr};
|
use pairing::bls12_381::{Bls12, Fr, FrRepr};
|
||||||
|
|
||||||
use sapling_crypto::{
|
use sapling_crypto::{
|
||||||
circuit::multipack,
|
|
||||||
constants::CRH_IVK_PERSONALIZATION,
|
constants::CRH_IVK_PERSONALIZATION,
|
||||||
jubjub::{
|
jubjub::{
|
||||||
edwards,
|
edwards,
|
||||||
@ -29,6 +28,7 @@ use sapling_crypto::{
|
|||||||
use zcash_proofs::circuit::sapling::TREE_DEPTH as SAPLING_TREE_DEPTH;
|
use zcash_proofs::circuit::sapling::TREE_DEPTH as SAPLING_TREE_DEPTH;
|
||||||
use zcash_proofs::circuit::sprout::{self, TREE_DEPTH as SPROUT_TREE_DEPTH};
|
use zcash_proofs::circuit::sprout::{self, TREE_DEPTH as SPROUT_TREE_DEPTH};
|
||||||
|
|
||||||
|
use bellman::gadgets::multipack;
|
||||||
use bellman::groth16::{
|
use bellman::groth16::{
|
||||||
create_random_proof, verify_proof, Parameters, PreparedVerifyingKey, Proof,
|
create_random_proof, verify_proof, Parameters, PreparedVerifyingKey, Proof,
|
||||||
};
|
};
|
||||||
|
@ -19,7 +19,6 @@ extern crate sha2;
|
|||||||
|
|
||||||
pub mod jubjub;
|
pub mod jubjub;
|
||||||
pub mod group_hash;
|
pub mod group_hash;
|
||||||
pub mod circuit;
|
|
||||||
pub mod pedersen_hash;
|
pub mod pedersen_hash;
|
||||||
pub mod primitives;
|
pub mod primitives;
|
||||||
pub mod constants;
|
pub mod constants;
|
||||||
|
@ -6,11 +6,11 @@ use bellman::{
|
|||||||
ConstraintSystem
|
ConstraintSystem
|
||||||
};
|
};
|
||||||
|
|
||||||
use sapling_crypto::circuit::{
|
use bellman::gadgets::{
|
||||||
Assignment
|
Assignment
|
||||||
};
|
};
|
||||||
|
|
||||||
use sapling_crypto::circuit::num::{
|
use bellman::gadgets::num::{
|
||||||
AllocatedNum,
|
AllocatedNum,
|
||||||
Num
|
Num
|
||||||
};
|
};
|
||||||
@ -22,11 +22,11 @@ use sapling_crypto::jubjub::{
|
|||||||
FixedGenerators
|
FixedGenerators
|
||||||
};
|
};
|
||||||
|
|
||||||
use sapling_crypto::circuit::lookup::{
|
use bellman::gadgets::lookup::{
|
||||||
lookup3_xy
|
lookup3_xy
|
||||||
};
|
};
|
||||||
|
|
||||||
use sapling_crypto::circuit::boolean::Boolean;
|
use bellman::gadgets::boolean::Boolean;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct EdwardsPoint<E: Engine> {
|
pub struct EdwardsPoint<E: Engine> {
|
||||||
@ -753,7 +753,7 @@ mod test {
|
|||||||
use rand_core::{RngCore, SeedableRng};
|
use rand_core::{RngCore, SeedableRng};
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
||||||
|
|
||||||
use sapling_crypto::circuit::test::*;
|
use bellman::gadgets::test::*;
|
||||||
use sapling_crypto::jubjub::{
|
use sapling_crypto::jubjub::{
|
||||||
montgomery,
|
montgomery,
|
||||||
edwards,
|
edwards,
|
||||||
@ -769,7 +769,7 @@ mod test {
|
|||||||
AllocatedNum,
|
AllocatedNum,
|
||||||
fixed_base_multiplication
|
fixed_base_multiplication
|
||||||
};
|
};
|
||||||
use sapling_crypto::circuit::boolean::{
|
use bellman::gadgets::boolean::{
|
||||||
Boolean,
|
Boolean,
|
||||||
AllocatedBit
|
AllocatedBit
|
||||||
};
|
};
|
||||||
|
@ -2,12 +2,12 @@ use super::ecc::{
|
|||||||
MontgomeryPoint,
|
MontgomeryPoint,
|
||||||
EdwardsPoint
|
EdwardsPoint
|
||||||
};
|
};
|
||||||
use sapling_crypto::circuit::boolean::Boolean;
|
use bellman::gadgets::boolean::Boolean;
|
||||||
use sapling_crypto::jubjub::*;
|
use sapling_crypto::jubjub::*;
|
||||||
use bellman::{
|
use bellman::{
|
||||||
ConstraintSystem, SynthesisError
|
ConstraintSystem, SynthesisError
|
||||||
};
|
};
|
||||||
use sapling_crypto::circuit::lookup::*;
|
use bellman::gadgets::lookup::*;
|
||||||
pub use sapling_crypto::pedersen_hash::Personalization;
|
pub use sapling_crypto::pedersen_hash::Personalization;
|
||||||
|
|
||||||
fn get_constant_bools(person: &Personalization) -> Vec<Boolean> {
|
fn get_constant_bools(person: &Personalization) -> Vec<Boolean> {
|
||||||
@ -110,8 +110,8 @@ pub fn pedersen_hash<E: JubjubEngine, CS>(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use sapling_crypto::circuit::test::*;
|
use bellman::gadgets::test::*;
|
||||||
use sapling_crypto::circuit::boolean::{Boolean, AllocatedBit};
|
use bellman::gadgets::boolean::{Boolean, AllocatedBit};
|
||||||
use sapling_crypto::pedersen_hash;
|
use sapling_crypto::pedersen_hash;
|
||||||
use ff::PrimeField;
|
use ff::PrimeField;
|
||||||
use pairing::bls12_381::{Bls12, Fr};
|
use pairing::bls12_381::{Bls12, Fr};
|
||||||
|
@ -19,13 +19,13 @@ use sapling_crypto::primitives::{
|
|||||||
PaymentAddress
|
PaymentAddress
|
||||||
};
|
};
|
||||||
|
|
||||||
use sapling_crypto::circuit::Assignment;
|
use bellman::gadgets::Assignment;
|
||||||
use sapling_crypto::circuit::boolean;
|
use bellman::gadgets::boolean;
|
||||||
use super::ecc;
|
use super::ecc;
|
||||||
use super::pedersen_hash;
|
use super::pedersen_hash;
|
||||||
use sapling_crypto::circuit::blake2s;
|
use bellman::gadgets::blake2s;
|
||||||
use sapling_crypto::circuit::num;
|
use bellman::gadgets::num;
|
||||||
use sapling_crypto::circuit::multipack;
|
use bellman::gadgets::multipack;
|
||||||
|
|
||||||
pub const TREE_DEPTH: usize = zcash_primitives::sapling::SAPLING_COMMITMENT_TREE_DEPTH;
|
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]
|
#[test]
|
||||||
fn test_input_circuit_with_bls12_381() {
|
fn test_input_circuit_with_bls12_381() {
|
||||||
|
use bellman::gadgets::test::*;
|
||||||
use ff::{BitIterator, Field};
|
use ff::{BitIterator, Field};
|
||||||
use pairing::bls12_381::*;
|
use pairing::bls12_381::*;
|
||||||
use rand_core::{RngCore, SeedableRng};
|
use rand_core::{RngCore, SeedableRng};
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
||||||
use sapling_crypto::{
|
use sapling_crypto::{
|
||||||
circuit::test::*,
|
|
||||||
jubjub::{JubjubBls12, fs, edwards},
|
jubjub::{JubjubBls12, fs, edwards},
|
||||||
pedersen_hash,
|
pedersen_hash,
|
||||||
primitives::{Diversifier, Note, ProofGenerationKey},
|
primitives::{Diversifier, Note, ProofGenerationKey},
|
||||||
@ -742,12 +742,12 @@ fn test_input_circuit_with_bls12_381() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_output_circuit_with_bls12_381() {
|
fn test_output_circuit_with_bls12_381() {
|
||||||
|
use bellman::gadgets::test::*;
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
use pairing::bls12_381::*;
|
use pairing::bls12_381::*;
|
||||||
use rand_core::{RngCore, SeedableRng};
|
use rand_core::{RngCore, SeedableRng};
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
||||||
use sapling_crypto::{
|
use sapling_crypto::{
|
||||||
circuit::test::*,
|
|
||||||
jubjub::{JubjubBls12, fs, edwards},
|
jubjub::{JubjubBls12, fs, edwards},
|
||||||
primitives::{Diversifier, ProofGenerationKey},
|
primitives::{Diversifier, ProofGenerationKey},
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use pairing::{Engine};
|
use pairing::{Engine};
|
||||||
use bellman::{ConstraintSystem, SynthesisError};
|
use bellman::{ConstraintSystem, SynthesisError};
|
||||||
use sapling_crypto::circuit::sha256::{
|
use bellman::gadgets::sha256::{
|
||||||
sha256
|
sha256
|
||||||
};
|
};
|
||||||
use sapling_crypto::circuit::boolean::{
|
use bellman::gadgets::boolean::{
|
||||||
Boolean
|
Boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use pairing::{Engine};
|
use pairing::{Engine};
|
||||||
use bellman::{ConstraintSystem, SynthesisError};
|
use bellman::{ConstraintSystem, SynthesisError};
|
||||||
use sapling_crypto::circuit::sha256::{
|
use bellman::gadgets::sha256::{
|
||||||
sha256_block_no_padding
|
sha256_block_no_padding
|
||||||
};
|
};
|
||||||
use sapling_crypto::circuit::boolean::{
|
use bellman::gadgets::boolean::{
|
||||||
AllocatedBit,
|
AllocatedBit,
|
||||||
Boolean
|
Boolean
|
||||||
};
|
};
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use ff::Field;
|
use ff::Field;
|
||||||
use pairing::Engine;
|
use pairing::Engine;
|
||||||
use bellman::{ConstraintSystem, SynthesisError, Circuit, LinearCombination};
|
use bellman::{ConstraintSystem, SynthesisError, Circuit, LinearCombination};
|
||||||
use sapling_crypto::circuit::boolean::{
|
use bellman::gadgets::boolean::{
|
||||||
AllocatedBit,
|
AllocatedBit,
|
||||||
Boolean
|
Boolean
|
||||||
};
|
};
|
||||||
use sapling_crypto::circuit::multipack::pack_into_inputs;
|
use bellman::gadgets::multipack::pack_into_inputs;
|
||||||
|
|
||||||
mod prfs;
|
mod prfs;
|
||||||
mod commitment;
|
mod commitment;
|
||||||
@ -355,7 +355,7 @@ fn witness_u252<E, CS>(
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_sprout_constraints() {
|
fn test_sprout_constraints() {
|
||||||
use pairing::bls12_381::{Bls12};
|
use pairing::bls12_381::{Bls12};
|
||||||
use sapling_crypto::circuit::test::*;
|
use bellman::gadgets::test::*;
|
||||||
|
|
||||||
use byteorder::{WriteBytesExt, ReadBytesExt, LittleEndian};
|
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_old.unwrap()).unwrap();
|
||||||
expected_inputs.write_u64::<LittleEndian>(vpub_new.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::bytes_to_bits(&expected_inputs);
|
||||||
let expected_inputs = multipack::compute_multipacking::<Bls12>(&expected_inputs);
|
let expected_inputs = multipack::compute_multipacking::<Bls12>(&expected_inputs);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use pairing::{Engine};
|
use pairing::{Engine};
|
||||||
use bellman::{ConstraintSystem, SynthesisError};
|
use bellman::{ConstraintSystem, SynthesisError};
|
||||||
use sapling_crypto::circuit::boolean::{Boolean};
|
use bellman::gadgets::boolean::{Boolean};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use super::prfs::*;
|
use super::prfs::*;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use pairing::{Engine};
|
use pairing::{Engine};
|
||||||
use bellman::{ConstraintSystem, SynthesisError};
|
use bellman::{ConstraintSystem, SynthesisError};
|
||||||
use sapling_crypto::circuit::sha256::{
|
use bellman::gadgets::sha256::{
|
||||||
sha256_block_no_padding
|
sha256_block_no_padding
|
||||||
};
|
};
|
||||||
use sapling_crypto::circuit::boolean::{
|
use bellman::gadgets::boolean::{
|
||||||
Boolean
|
Boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
use bellman::groth16::{
|
use bellman::{
|
||||||
create_random_proof, verify_proof, Parameters, PreparedVerifyingKey, Proof,
|
gadgets::multipack,
|
||||||
|
groth16::{
|
||||||
|
create_random_proof, verify_proof, Parameters, PreparedVerifyingKey, Proof,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
use pairing::bls12_381::{Bls12, Fr};
|
use pairing::bls12_381::{Bls12, Fr};
|
||||||
use rand_os::OsRng;
|
use rand_os::OsRng;
|
||||||
use sapling_crypto::{
|
use sapling_crypto::{
|
||||||
circuit::multipack,
|
|
||||||
jubjub::{edwards, fs::Fs, FixedGenerators, JubjubBls12, Unknown},
|
jubjub::{edwards, fs::Fs, FixedGenerators, JubjubBls12, Unknown},
|
||||||
primitives::{Diversifier, Note, PaymentAddress, ProofGenerationKey, ValueCommitment},
|
primitives::{Diversifier, Note, PaymentAddress, ProofGenerationKey, ValueCommitment},
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
use bellman::groth16::{verify_proof, PreparedVerifyingKey, Proof};
|
use bellman::{
|
||||||
|
gadgets::multipack,
|
||||||
|
groth16::{verify_proof, PreparedVerifyingKey, Proof},
|
||||||
|
};
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
use pairing::bls12_381::{Bls12, Fr};
|
use pairing::bls12_381::{Bls12, Fr};
|
||||||
use sapling_crypto::{
|
use sapling_crypto::jubjub::{edwards, FixedGenerators, JubjubBls12, Unknown};
|
||||||
circuit::multipack,
|
|
||||||
jubjub::{edwards, FixedGenerators, JubjubBls12, Unknown},
|
|
||||||
};
|
|
||||||
use zcash_primitives::{
|
use zcash_primitives::{
|
||||||
redjubjub::{PublicKey, Signature},
|
redjubjub::{PublicKey, Signature},
|
||||||
transaction::components::Amount,
|
transaction::components::Amount,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user