Skip to content

Commit

Permalink
Move generic circuit gadgets into bellman
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Aug 14, 2019
1 parent 9b3d766 commit dfb86fc
Show file tree
Hide file tree
Showing 12 changed files with 4,963 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ version = "0.1.0"

[dependencies]
bit-vec = "0.4.4"
blake2s_simd = "0.5"
ff = { path = "../ff" }
futures = "0.1"
futures-cpupool = { version = "0.1", optional = true }
Expand All @@ -21,7 +22,10 @@ rand_core = "0.5"
byteorder = "1"

[dev-dependencies]
hex-literal = "0.1"
rand = "0.7"
rand_xorshift = "0.2"
sha2 = "0.8"

[features]
groth16 = ["pairing"]
Expand Down
33 changes: 33 additions & 0 deletions src/gadgets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pub mod test;

pub mod boolean;
pub mod multieq;
pub mod uint32;
pub mod blake2s;
pub mod num;
pub mod lookup;
pub mod multipack;
pub mod sha256;

use crate::{
SynthesisError
};

// TODO: This should probably be removed and we
// should use existing helper methods on `Option`
// for mapping with an error.
/// This basically is just an extension to `Option`
/// which allows for a convenient mapping to an
/// error on `None`.
pub trait Assignment<T> {
fn get(&self) -> Result<&T, SynthesisError>;
}

impl<T> Assignment<T> for Option<T> {
fn get(&self) -> Result<&T, SynthesisError> {
match *self {
Some(ref v) => Ok(v),
None => Err(SynthesisError::AssignmentMissing)
}
}
}
Loading

0 comments on commit dfb86fc

Please sign in to comment.