Skip to content

Commit

Permalink
Fix tests (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
olesHolem authored Oct 18, 2023
1 parent 3a21c8d commit dad50e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ resolver = "2"
# franklin-crypto = {path = "../franklin-crypto", features = ["plonk", "multicore"]}
franklin-crypto = {git = "https://github.com/matter-labs/franklin-crypto", branch = "dev", features = ["multicore"]}
sha2 = "0.10"
sha3 = "0.10"
# sha3 = "0.10"
sha3 = { git = "https://github.com/RustCrypto/hashes.git", rev = "7a187e934c1f6c68e4b4e5cf37541b7a0d64d303" }
hex = "*"
once_cell = "*"
derivative = "*"
Expand Down
6 changes: 3 additions & 3 deletions src/data_structures/alg_binary_tree/dense_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ mod tests {
>::new(&params);

let mut leaf_hashes = vec![Fr::zero(); 8];
let one = Fr::from_str("1").unwrap();
leaf_hashes[0] = one;
leaf_hashes[0] = Fr::one();
let new_tree = BinaryTree::<Bn256, _>::create_from_leaf_hashes(&leaf_hashes, hasher);

assert_eq!(
new_tree.get_commitment().to_string().as_str(),
"Fr(0x2a30c843f2912ccc50f7b5baab078e548dd5df3fdb07199d1413c437b0997dee)"
// "Fr(0x2a30c843f2912ccc50f7b5baab078e548dd5df3fdb07199d1413c437b0997dee)"
"Fr(0x113bf1fa2ddb05cf4659651dc6a6c602a8f29dfde19f288e066c97b020fdc9d8)"
);
}

Expand Down
12 changes: 9 additions & 3 deletions src/glue/code_unpacker_sha256/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,9 +652,15 @@ mod test {
let mut code_hash_in_internal_format = [0u8; 32];
let length_in_words = (input_length / 32) as u16;
let length_in_words_le = length_in_words.to_be_bytes();
code_hash_in_internal_format[0] = length_in_words_le[0];
code_hash_in_internal_format[1] = length_in_words_le[1];
code_hash_in_internal_format[2..].copy_from_slice(&code_hash.as_slice()[2..]);

use zkevm_opcode_defs::versioned_hash::ContractCodeSha256;
use zkevm_opcode_defs::VersionedHashDef;

code_hash_in_internal_format[0] = ContractCodeSha256::VERSION_BYTE;
code_hash_in_internal_format[1] = 0;
code_hash_in_internal_format[2] = length_in_words_le[0];
code_hash_in_internal_format[3] = length_in_words_le[1];
code_hash_in_internal_format[4..].copy_from_slice(&code_hash.as_slice()[4..]);
let code_hash =
UInt256::constant_from_biguint(BigUint::from_bytes_be(&code_hash_in_internal_format));

Expand Down

0 comments on commit dad50e7

Please sign in to comment.