Skip to content

Commit

Permalink
Merge pull request #1146 from filecoin-project/refactor/better-names-…
Browse files Browse the repository at this point in the history
…in-por-circuit

Improve names in PoR circuit.
  • Loading branch information
porcuquine authored Jun 3, 2020
2 parents 3cc8b5a + a649d9c commit 2565745
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions storage-proofs/core/src/gadgets/por.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,17 @@ impl<H: Hasher, Arity: 'static + PoseidonArity> SubPath<H, Arity> {

let mut auth_path_bits = Vec::with_capacity(self.path.len());

for (i, path) in self.path.into_iter().enumerate() {
let elements = path.hashes;
let indexes = path.index;
for (i, path_element) in self.path.into_iter().enumerate() {
let path_hashes = path_element.hashes;
let optional_index = path_element.index; // Optional because of Bellman blank-circuit construction mechanics.

let cs = &mut cs.namespace(|| format!("merkle tree hash {}", i));

let mut index_bits = Vec::with_capacity(index_bit_count);

for i in 0..index_bit_count {
let bit = AllocatedBit::alloc(cs.namespace(|| format!("index bit {}", i)), {
indexes.map(|index| ((index >> i) & 1) == 1)
optional_index.map(|index| ((index >> i) & 1) == 1)
})?;

index_bits.push(Boolean::from(bit));
Expand All @@ -163,7 +163,7 @@ impl<H: Hasher, Arity: 'static + PoseidonArity> SubPath<H, Arity> {
auth_path_bits.extend_from_slice(&index_bits);

// Witness the authentication path elements adjacent at this depth.
let path_elements = elements
let path_hash_nums = path_hashes
.iter()
.enumerate()
.map(|(i, elt)| {
Expand All @@ -173,7 +173,7 @@ impl<H: Hasher, Arity: 'static + PoseidonArity> SubPath<H, Arity> {
})
.collect::<Result<Vec<_>, _>>()?;

let inserted = insert(cs, &cur, &index_bits, &path_elements)?;
let inserted = insert(cs, &cur, &index_bits, &path_hash_nums)?;

// Compute the new subtree value
cur = H::Function::hash_multi_leaf_circuit::<Arity, _>(
Expand Down

0 comments on commit 2565745

Please sign in to comment.