librustzcash/bellman/src/gadgets.rs

34 lines
796 B
Rust
Raw Normal View History

2019-09-24 02:54:15 -07:00
//! Self-contained sub-circuit implementations for various primitives.
pub mod test;
pub mod blake2s;
2019-08-15 09:38:41 -07:00
pub mod boolean;
pub mod lookup;
2019-08-15 09:38:41 -07:00
pub mod multieq;
pub mod multipack;
2019-08-15 09:38:41 -07:00
pub mod num;
2018-03-15 12:08:12 -07:00
pub mod sha256;
2019-08-15 09:38:41 -07:00
pub mod uint32;
2019-08-15 09:38:41 -07:00
use crate::SynthesisError;
2018-03-08 00:16:21 -08:00
2018-03-07 23:41:47 -08:00
// 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),
2019-08-15 09:38:41 -07:00
None => Err(SynthesisError::AssignmentMissing),
}
}
}