Skip to content

Commit

Permalink
fix: hash inconsistency and in-me-tr-dep
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasti810 committed Jul 14, 2024
1 parent 141cdb3 commit 025156f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ clap = { version = "4.3.2", features = ["derive"] }
config = "0.14.0"
fs2 = "0.4.3"
thiserror = "1.0.50"
indexed-merkle-tree = "0.3.2"
indexed-merkle-tree = "0.3.3"
dotenvy = "0.15.7"
ahash = "0.8.7"
celestia-rpc = "0.2.0"
Expand Down
10 changes: 5 additions & 5 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,19 @@ mod tests {
let ethan = sha256(&"Ethan".to_string());
let triple_zero = sha256(&"000".to_string());

let mut ethans_node =
Node::new_leaf(true, true, ethan, triple_zero, Node::TAIL.to_string());
let mut ryans_node = Node::new_leaf(true, true, ryan, ford, Node::TAIL.to_string());
let mut ryans_node = Node::new_leaf(true, false, ryan, ford, Node::TAIL.to_string());
let mut sebastians_node =
Node::new_leaf(true, true, sebastian.clone(), pusch, Node::TAIL.to_string());
let mut ethans_node =
Node::new_leaf(true, false, ethan, triple_zero, Node::TAIL.to_string());

let first_insert_proof = tree.insert_node(&mut ryans_node).unwrap();
let third_insert_proof = tree.insert_node(&mut ethans_node).unwrap();
let second_insert_proof = tree.insert_node(&mut sebastians_node).unwrap();
let third_insert_proof = tree.insert_node(&mut ethans_node).unwrap();

let first_insert_zk_snark = Proof::Insert(first_insert_proof);
let second_insert_zk_snark = Proof::Insert(second_insert_proof);
let third_insert_zk_snark = Proof::Insert(third_insert_proof.clone());
let third_insert_zk_snark = Proof::Insert(third_insert_proof);

let updated_seb = sha256(&"Sebastian".to_string());
sebastians_node =
Expand Down
4 changes: 2 additions & 2 deletions src/zk_snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ pub fn recalculate_hash_as_scalar(path: &[Node]) -> Result<Scalar, GeneralError>
for i in 1..(path.len()) {
let sibling = &path[i];
if sibling.is_left_sibling() {
current_hash = sha256(&format!("{} || {}", &sibling.get_hash(), current_hash));
current_hash = sha256(&format!("{}{}", &sibling.get_hash(), current_hash));
} else {
current_hash = sha256(&format!("{} || {}", current_hash, &sibling.get_hash()));
current_hash = sha256(&format!("{}{}", current_hash, &sibling.get_hash()));
}
}
hex_to_scalar(&current_hash.as_str())
Expand Down

0 comments on commit 025156f

Please sign in to comment.