Skip to content

Commit

Permalink
Merge pull request #15 from ebfull/pedersen-hashes
Browse files Browse the repository at this point in the history
Pedersen hashes inside and outside the circuit
  • Loading branch information
ebfull authored Jan 29, 2018
2 parents 041060e + 42514e7 commit 7d59049
Show file tree
Hide file tree
Showing 11 changed files with 1,161 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ features = ["expose-arith"]
rand = "0.3"
blake2 = "0.7"
digest = "0.7"
bellman = "0.0.6"
bellman = "0.0.7"

[features]
default = ["u128-support"]
Expand Down
19 changes: 19 additions & 0 deletions src/circuit/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,25 @@ impl<Var: Copy> Boolean<Var> {
}
}

pub fn lc<E: Engine>(&self, one: Var, coeff: E::Fr) -> LinearCombination<Var, E>
{
match self {
&Boolean::Constant(c) => {
if c {
LinearCombination::<Var, E>::zero() + (coeff, one)
} else {
LinearCombination::<Var, E>::zero()
}
},
&Boolean::Is(ref v) => {
LinearCombination::<Var, E>::zero() + (coeff, v.get_variable())
},
&Boolean::Not(ref v) => {
LinearCombination::<Var, E>::zero() + (coeff, one) - (coeff, v.get_variable())
}
}
}

/// Construct a boolean from a known constant
pub fn constant(b: bool) -> Self {
Boolean::Constant(b)
Expand Down
1 change: 1 addition & 0 deletions src/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod uint32;
pub mod blake2s;
pub mod num;
pub mod mont;
pub mod pedersen_hash;

use bellman::SynthesisError;

Expand Down
Loading

0 comments on commit 7d59049

Please sign in to comment.