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

33
bellman/src/gadgets.rs Normal file
View File

@@ -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)
}
}
}