diff --git a/Cargo.toml b/Cargo.toml index 2881b76..e07dd64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 = "*" diff --git a/src/data_structures/alg_binary_tree/dense_tree.rs b/src/data_structures/alg_binary_tree/dense_tree.rs index d70c2b9..9908131 100644 --- a/src/data_structures/alg_binary_tree/dense_tree.rs +++ b/src/data_structures/alg_binary_tree/dense_tree.rs @@ -192,13 +192,13 @@ mod tests { >::new(¶ms); 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::::create_from_leaf_hashes(&leaf_hashes, hasher); assert_eq!( new_tree.get_commitment().to_string().as_str(), - "Fr(0x2a30c843f2912ccc50f7b5baab078e548dd5df3fdb07199d1413c437b0997dee)" + // "Fr(0x2a30c843f2912ccc50f7b5baab078e548dd5df3fdb07199d1413c437b0997dee)" + "Fr(0x113bf1fa2ddb05cf4659651dc6a6c602a8f29dfde19f288e066c97b020fdc9d8)" ); } diff --git a/src/glue/code_unpacker_sha256/mod.rs b/src/glue/code_unpacker_sha256/mod.rs index faefcc0..dcb53b3 100644 --- a/src/glue/code_unpacker_sha256/mod.rs +++ b/src/glue/code_unpacker_sha256/mod.rs @@ -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));