2019-09-24 02:54:15 -07:00
|
|
|
//! Self-contained sub-circuit implementations for various primitives.
|
|
|
|
|
2017-11-22 20:57:00 -08:00
|
|
|
pub mod test;
|
|
|
|
|
|
|
|
pub mod blake2s;
|
2019-08-15 09:38:41 -07:00
|
|
|
pub mod boolean;
|
2018-02-02 08:50:59 -08:00
|
|
|
pub mod lookup;
|
2019-08-15 09:38:41 -07:00
|
|
|
pub mod multieq;
|
2018-03-15 11:36:05 -07:00
|
|
|
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;
|
2017-11-22 20:57:00 -08:00
|
|
|
|
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`.
|
2019-08-05 14:45:12 -07:00
|
|
|
pub trait Assignment<T> {
|
2017-11-22 20:57:00 -08:00
|
|
|
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),
|
2017-11-22 20:57:00 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|