Add 'sapling-crypto/' from commit '21084bde2019c04bd34208e63c3560fe2c02fb0e'
git-subtree-dir: sapling-crypto git-subtree-mainline:9f748554d0git-subtree-split:21084bde20
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
use pairing::{Engine};
|
||||
use bellman::{ConstraintSystem, SynthesisError};
|
||||
use circuit::sha256::{
|
||||
sha256
|
||||
};
|
||||
use circuit::boolean::{
|
||||
Boolean
|
||||
};
|
||||
|
||||
pub fn note_comm<E, CS>(
|
||||
cs: CS,
|
||||
a_pk: &[Boolean],
|
||||
value: &[Boolean],
|
||||
rho: &[Boolean],
|
||||
r: &[Boolean]
|
||||
) -> Result<Vec<Boolean>, SynthesisError>
|
||||
where E: Engine, CS: ConstraintSystem<E>
|
||||
{
|
||||
assert_eq!(a_pk.len(), 256);
|
||||
assert_eq!(value.len(), 64);
|
||||
assert_eq!(rho.len(), 256);
|
||||
assert_eq!(r.len(), 256);
|
||||
|
||||
let mut image = vec![];
|
||||
image.push(Boolean::constant(true));
|
||||
image.push(Boolean::constant(false));
|
||||
image.push(Boolean::constant(true));
|
||||
image.push(Boolean::constant(true));
|
||||
image.push(Boolean::constant(false));
|
||||
image.push(Boolean::constant(false));
|
||||
image.push(Boolean::constant(false));
|
||||
image.push(Boolean::constant(false));
|
||||
image.extend(a_pk.iter().cloned());
|
||||
image.extend(value.iter().cloned());
|
||||
image.extend(rho.iter().cloned());
|
||||
image.extend(r.iter().cloned());
|
||||
|
||||
sha256(
|
||||
cs,
|
||||
&image
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user