Skip to content

Commit

Permalink
Use bellpepper.
Browse files Browse the repository at this point in the history
  • Loading branch information
porcuquine committed Jul 14, 2023
1 parent e51b866 commit f6b195f
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 31 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ repository = "https://github.com/lurk-lab/neptune"
rust-version = "1.64.0"

[dependencies]
bellpepper = { workspace = true }
bellperson = { workspace = true }
blake2s_simd = { workspace = true }
blstrs = { workspace = true, optional = true }
Expand Down Expand Up @@ -51,7 +52,7 @@ incremental = false
codegen-units = 1

[features]
default = ["bellperson/default"]
default = ["bellpepper/default"]
cuda = ["ec-gpu-gen/cuda", "ec-gpu", "pasta_curves/gpu"]
opencl = ["ec-gpu-gen/opencl", "ec-gpu", "pasta_curves/gpu"]
# The supported arities for Poseidon running on the GPU are specified at compile-time.
Expand All @@ -67,6 +68,8 @@ strengthened = []
# The supported fields for Poseidon running on the GPU are specified at compile-time.
bls = ["blstrs/gpu"]
pasta = ["pasta_curves/gpu"]
# Use bellperson instead of bellpepper.
bellperson = []

[workspace]
resolver = "2"
Expand All @@ -76,6 +79,7 @@ members = [

# Dependencies that should be kept in sync through the whole workspace
[workspace.dependencies]
bellpepper = "0.1.2"
bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "master" }
blake2s_simd = "0.5"
blstrs = { version = "0.7.0" }
Expand Down
8 changes: 4 additions & 4 deletions benches/synthesis.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::poseidon::{Arity, PoseidonConstants};
use bellperson::gadgets::num::AllocatedNum;
use bellperson::util_cs::bench_cs::BenchCS;
use bellperson::util_cs::witness_cs::WitnessCS;
use bellperson::{ConstraintSystem, SynthesisError};
use bellpepper::gadgets::num::AllocatedNum;
use bellpepper::util_cs::bench_cs::BenchCS;
use bellpepper::util_cs::witness_cs::WitnessCS;
use bellpepper::{ConstraintSystem, SynthesisError};
use blstrs::Scalar as Fr;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use ff::Field;
Expand Down
6 changes: 3 additions & 3 deletions gbench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
license = "MIT OR Apache-2.0"

[dependencies]
bellperson = { workspace = true, default-features = false }
bellpepper = { workspace = true, default-features = false }
blake2s_simd = { workspace = true }
blstrs = { workspace = true, features = ["gpu"] }
byteorder = { workspace = true }
Expand All @@ -23,5 +23,5 @@ structopt = { version = "0.3", default-features = false }

[features]
default = ["opencl"]
cuda = ["neptune/cuda", "bellperson/cuda", "ec-gpu-gen/cuda"]
opencl = ["neptune/opencl", "bellperson/opencl", "ec-gpu-gen/opencl"]
cuda = ["neptune/cuda", "ec-gpu-gen/cuda"]
opencl = ["neptune/opencl", "ec-gpu-gen/opencl"]
26 changes: 20 additions & 6 deletions src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@ use crate::hash_type::HashType;
use crate::matrix::Matrix;
use crate::mds::SparseMatrix;
use crate::poseidon::{Arity, PoseidonConstants};
use bellperson::gadgets::boolean::Boolean;
use bellperson::gadgets::num;
use bellperson::gadgets::num::AllocatedNum;
use bellperson::{ConstraintSystem, LinearCombination, SynthesisError};
#[cfg(not(feature = "bellperson"))]
use bellpepper::{
gadgets::{
boolean::Boolean,
num::{self, AllocatedNum},
},
ConstraintSystem, LinearCombination, SynthesisError,
};
#[cfg(feature = "bellperson")]
use bellperson::{
gadgets::{
boolean::Boolean,
num::{self, AllocatedNum},
},
ConstraintSystem, LinearCombination, SynthesisError,
};
use ff::{Field, PrimeField};
use std::marker::PhantomData;

Expand Down Expand Up @@ -613,8 +625,10 @@ mod tests {
use super::*;
use crate::poseidon::HashMode;
use crate::{Poseidon, Strength};
use bellperson::util_cs::test_cs::TestConstraintSystem;
use bellperson::ConstraintSystem;
#[cfg(not(feature = "bellperson"))]
use bellpepper::{util_cs::test_cs::TestConstraintSystem, ConstraintSystem};
#[cfg(feature = "bellperson")]
use bellperson::{util_cs::test_cs::TestConstraintSystem, ConstraintSystem};
use blstrs::Scalar as Fr;
use generic_array::typenum;
use rand::SeedableRng;
Expand Down
31 changes: 25 additions & 6 deletions src/circuit2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,27 @@ use crate::hash_type::HashType;
use crate::matrix::Matrix;
use crate::mds::SparseMatrix;
use crate::poseidon::{Arity, PoseidonConstants};
use bellperson::gadgets::boolean::Boolean;
use bellperson::gadgets::num::{self, AllocatedNum};
use bellperson::gadgets::test::TestConstraintSystem;
use bellperson::{ConstraintSystem, LinearCombination, SynthesisError};

#[cfg(feature = "bellperson")]
use bellperson::{
gadgets::{
boolean::Boolean,
num::{self, AllocatedNum},
test::TestConstraintSystem,
},
ConstraintSystem, LinearCombination, SynthesisError,
};

#[cfg(not(feature = "bellperson"))]
use bellpepper::{
gadgets::{
boolean::Boolean,
num::{self, AllocatedNum},
test::TestConstraintSystem,
},
ConstraintSystem, LinearCombination, SynthesisError,
};

use ff::{Field, PrimeField};
use std::marker::PhantomData;

Expand Down Expand Up @@ -699,8 +716,10 @@ mod tests {
use super::*;
use crate::poseidon::HashMode;
use crate::{Poseidon, Strength};
use bellperson::util_cs::test_cs::TestConstraintSystem;
use bellperson::ConstraintSystem;
#[cfg(not(feature = "bellperson"))]
use bellpepper::{util_cs::test_cs::TestConstraintSystem, ConstraintSystem};
#[cfg(feature = "bellperson")]
use bellperson::{util_cs::test_cs::TestConstraintSystem, ConstraintSystem};
use blstrs::Scalar as Fr;
use generic_array::typenum;
use rand::SeedableRng;
Expand Down
37 changes: 30 additions & 7 deletions src/circuit2_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,27 @@ use crate::hash_type::HashType;
use crate::matrix::Matrix;
use crate::mds::SparseMatrix;
use crate::poseidon::{Arity, Poseidon, PoseidonConstants};
use bellperson::util_cs::witness_cs::SizedWitness;
#[cfg(not(feature = "bellperson"))]
use bellpepper::{
gadgets::{
boolean::Boolean,
num::{self, AllocatedNum},
test::TestConstraintSystem,
},
util_cs::witness_cs::SizedWitness,
ConstraintSystem, LinearCombination, SynthesisError,
};
#[cfg(feature = "bellperson")]
use bellperson::{
gadgets::{
boolean::Boolean,
num::{self, AllocatedNum},
test::TestConstraintSystem,
},
util_cs::witness_cs::SizedWitness,
ConstraintSystem, LinearCombination, SynthesisError,
};

use bellperson::gadgets::boolean::Boolean;
use bellperson::gadgets::num::{self, AllocatedNum};
use bellperson::gadgets::test::TestConstraintSystem;
use bellperson::{ConstraintSystem, LinearCombination, SynthesisError};
use ff::{Field, PrimeField};
use generic_array::sequence::GenericSequence;
use generic_array::typenum::Unsigned;
Expand Down Expand Up @@ -324,8 +339,16 @@ mod test {
use crate::circuit2;
use crate::poseidon::HashMode;
use crate::{Poseidon, Strength};
use bellperson::util_cs::{test_cs::TestConstraintSystem, witness_cs::WitnessCS, Comparable};
use bellperson::ConstraintSystem;
#[cfg(not(feature = "bellperson"))]
use bellpepper::{
util_cs::{test_cs::TestConstraintSystem, witness_cs::WitnessCS, Comparable},
ConstraintSystem,
};
#[cfg(feature = "bellperson")]
use bellperson::{
util_cs::{test_cs::TestConstraintSystem, witness_cs::WitnessCS, Comparable},
ConstraintSystem,
};
use blstrs::Scalar as Fr;
use generic_array::typenum;
use rand::SeedableRng;
Expand Down
29 changes: 25 additions & 4 deletions src/sponge/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,25 @@ use crate::sponge::{
vanilla::{Direction, Mode, SpongeTrait},
};
use crate::Strength;
use bellperson::gadgets::boolean::Boolean;
use bellperson::gadgets::num::{self, AllocatedNum};
use bellperson::util_cs::witness_cs::{SizedWitness, WitnessCS};
use bellperson::{ConstraintSystem, LinearCombination, Namespace, SynthesisError};
#[cfg(not(feature = "bellperson"))]
use bellpepper::{
gadgets::{
boolean::Boolean,
num::{self, AllocatedNum},
},
util_cs::witness_cs::{SizedWitness, WitnessCS},
ConstraintSystem, LinearCombination, Namespace, SynthesisError,
};
#[cfg(feature = "bellperson")]
use bellperson::{
gadgets::{
boolean::Boolean,
num::{self, AllocatedNum},
},
util_cs::witness_cs::{SizedWitness, WitnessCS},
ConstraintSystem, LinearCombination, Namespace, SynthesisError,
};

use ff::{Field, PrimeField};
use std::collections::VecDeque;
use std::marker::PhantomData;
Expand Down Expand Up @@ -254,6 +269,12 @@ mod tests {
use super::*;
use crate::sponge::vanilla::Sponge;

#[cfg(not(feature = "bellperson"))]
use bellpepper::{
util_cs::{test_cs::TestConstraintSystem, witness_cs::WitnessCS},
Circuit,
};
#[cfg(feature = "bellperson")]
use bellperson::{
util_cs::{test_cs::TestConstraintSystem, witness_cs::WitnessCS},
Circuit,
Expand Down

0 comments on commit f6b195f

Please sign in to comment.