Move generic circuit gadgets into bellman
This commit is contained in:
33
bellman/src/gadgets.rs
Normal file
33
bellman/src/gadgets.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user