diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index f297b349161..7712289a790 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -124,15 +124,15 @@ library Constants { uint256 internal constant L2_GAS_PER_NOTE_HASH = 32; uint256 internal constant L2_GAS_PER_NULLIFIER = 64; uint256 internal constant CANONICAL_KEY_REGISTRY_ADDRESS = - 2153455745675440165069577621832684870696142028027528497509357256345838682961; + 1846248480517165521743643626257274710444505994181338106189373716137867887031; uint256 internal constant CANONICAL_AUTH_REGISTRY_ADDRESS = - 18091885756106795278141309801070173692350235742979924147720536894670507925831; + 291851909807592677788453151491906806151300647123080163180507453297558628774; uint256 internal constant DEPLOYER_CONTRACT_ADDRESS = - 19511485909966796736993840362353440247573331327062358513665772226446629198132; + 9256947041321027089533495832830405543710101516429552788062967841445602134030; uint256 internal constant REGISTERER_CONTRACT_ADDRESS = - 13402924717071282069537366635406026232165444473509746327951838324587448220160; + 867409746588255642605883457564767101821478729272763062990600291025697803994; uint256 internal constant GAS_TOKEN_ADDRESS = - 3159976153131520272419617514531889581796079438158800470341967144801191524489; + 8777298866013239306861859762114222884687709421566494727011568767822269644915; uint256 internal constant AZTEC_ADDRESS_LENGTH = 1; uint256 internal constant GAS_FEES_LENGTH = 2; uint256 internal constant GAS_LENGTH = 2; diff --git a/noir-projects/aztec-nr/address-note/src/address_note.nr b/noir-projects/aztec-nr/address-note/src/address_note.nr index ef6628da9d5..9cfbdc36fe3 100644 --- a/noir-projects/aztec-nr/address-note/src/address_note.nr +++ b/noir-projects/aztec-nr/address-note/src/address_note.nr @@ -1,5 +1,8 @@ use dep::aztec::{ - protocol_types::{address::AztecAddress, traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash}, + protocol_types::{ + address::AztecAddress, traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER, + hash::poseidon2_hash_with_separator +}, note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, oracle::unsafe_rand::unsafe_rand, keys::getters::get_nsk_app, context::PrivateContext }; @@ -23,22 +26,24 @@ impl NoteInterface for AddressNote { fn compute_note_hash_and_nullifier(self, context: &mut PrivateContext) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = context.request_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, - secret, + secret + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } fn compute_note_hash_and_nullifier_without_context(self) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = get_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, - secret, + secret + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } } diff --git a/noir-projects/aztec-nr/authwit/src/auth.nr b/noir-projects/aztec-nr/authwit/src/auth.nr index b6343f2c94e..a6c2d91f9cb 100644 --- a/noir-projects/aztec-nr/authwit/src/auth.nr +++ b/noir-projects/aztec-nr/authwit/src/auth.nr @@ -4,7 +4,7 @@ use dep::aztec::protocol_types::{ GENERATOR_INDEX__AUTHWIT_INNER, GENERATOR_INDEX__AUTHWIT_OUTER, GENERATOR_INDEX__AUTHWIT_NULLIFIER, CANONICAL_AUTH_REGISTRY_ADDRESS }, - hash::pedersen_hash + hash::poseidon2_hash_with_separator }; use dep::aztec::{prelude::Deserialize, context::{PrivateContext, PublicContext, gas::GasOpts}, hash::hash_args_array}; @@ -308,7 +308,7 @@ pub fn compute_authwit_message_hash_from_call( * @param args The arguments to hash */ pub fn compute_inner_authwit_hash(args: [Field; N]) -> Field { - pedersen_hash(args, GENERATOR_INDEX__AUTHWIT_INNER) + poseidon2_hash_with_separator(args, GENERATOR_INDEX__AUTHWIT_INNER) } /** @@ -320,7 +320,7 @@ pub fn compute_inner_authwit_hash(args: [Field; N]) -> Field { * @param inner_hash The hash of the message to authorize */ pub fn compute_authwit_nullifier(on_behalf_of: AztecAddress, inner_hash: Field) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( [on_behalf_of.to_field(), inner_hash], GENERATOR_INDEX__AUTHWIT_NULLIFIER ) @@ -335,7 +335,7 @@ pub fn compute_authwit_nullifier(on_behalf_of: AztecAddress, inner_hash: Field) * @param inner_hash The hash of the "inner" message that is being consumed */ pub fn compute_authwit_message_hash(consumer: AztecAddress, chain_id: Field, version: Field, inner_hash: Field) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( [ consumer.to_field(), chain_id, diff --git a/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr b/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr index 349bd127be8..4c2aaf8fb39 100644 --- a/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr +++ b/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr @@ -1,5 +1,8 @@ use dep::aztec::prelude::PrivateContext; -use dep::aztec::protocol_types::{constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, hash::pedersen_hash, traits::{Hash, Serialize}}; +use dep::aztec::protocol_types::{ + constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, hash::poseidon2_hash_with_separator, + traits::{Hash, Serialize} +}; use crate::entrypoint::function_call::{FunctionCall, FUNCTION_CALL_SIZE_IN_BYTES}; @@ -32,7 +35,7 @@ impl Serialize for AppPayload { impl Hash for AppPayload { fn hash(self) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( self.serialize(), GENERATOR_INDEX__SIGNATURE_PAYLOAD ) diff --git a/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr b/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr index 8a0ffbb01a8..0d302d0fcbc 100644 --- a/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr +++ b/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr @@ -1,5 +1,8 @@ use dep::aztec::prelude::PrivateContext; -use dep::aztec::protocol_types::{constants::GENERATOR_INDEX__FEE_PAYLOAD, hash::pedersen_hash, traits::{Hash, Serialize}}; +use dep::aztec::protocol_types::{ + constants::GENERATOR_INDEX__FEE_PAYLOAD, hash::poseidon2_hash_with_separator, + traits::{Hash, Serialize} +}; use crate::entrypoint::function_call::FunctionCall; // 2 * 5 (FUNCTION_CALL_SIZE) + 2 @@ -33,7 +36,7 @@ impl Serialize for FeePayload { impl Hash for FeePayload { fn hash(self) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( self.serialize(), GENERATOR_INDEX__FEE_PAYLOAD ) diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr index 06de95353a4..e396c4a3d38 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ address::AztecAddress, scalar::Scalar, point::Point, constants::GENERATOR_INDEX__SYMMETRIC_KEY, - hash::poseidon2_hash + hash::poseidon2_hash_with_separator }; use std::aes128::aes128_encrypt; @@ -41,11 +41,9 @@ impl EncryptedLogOutgoingBody { } // We compute the symmetric key using poseidon. - let full_key: [u8; 32] = poseidon2_hash( - [ - ovsk_app.hi, ovsk_app.lo, eph_pk.x, eph_pk.y, + let full_key: [u8; 32] = poseidon2_hash_with_separator( + [ovsk_app.hi, ovsk_app.lo, eph_pk.x, eph_pk.y], GENERATOR_INDEX__SYMMETRIC_KEY as Field - ] ).to_be_bytes(32).as_array(); let mut sym_key = [0; 16]; @@ -63,7 +61,7 @@ mod test { use crate::encrypted_logs::outgoing_body::EncryptedLogOutgoingBody; use dep::protocol_types::{ address::AztecAddress, traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER, - scalar::Scalar, point::Point, hash::poseidon2_hash + scalar::Scalar, point::Point, hash::poseidon2_hash_with_separator }; use std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key; @@ -96,7 +94,7 @@ mod test { // The following value was generated by `encrypted_log_outgoing_body.test.ts` // --> Run the test with AZTEC_GENERATE_TEST_DATA=1 flag to update test data. let outgoing_body_ciphertext_from_typescript = [ - 126, 10, 214, 39, 130, 143, 96, 143, 79, 143, 22, 36, 55, 41, 234, 255, 226, 26, 138, 236, 91, 188, 204, 216, 172, 133, 134, 69, 161, 237, 134, 5, 75, 192, 10, 6, 229, 54, 194, 56, 103, 243, 57, 248, 147, 237, 4, 3, 39, 28, 226, 30, 237, 228, 212, 115, 246, 244, 105, 39, 129, 119, 126, 207, 176, 14, 75, 134, 241, 23, 2, 187, 239, 86, 47, 56, 239, 20, 92, 176, 70, 12, 219, 226, 150, 70, 192, 43, 125, 53, 230, 153, 135, 228, 210, 197, 227, 106, 242, 138, 119, 83, 182, 150, 233, 111, 9, 104, 128, 222, 85, 136, 205, 244, 77, 230, 210, 217, 223, 106, 220, 4, 115, 33, 157, 212, 217, 133, 87, 179, 67, 158, 81, 85, 226, 105, 22, 8, 154, 130, 193, 214, 144, 212 + 127, 182, 227, 75, 192, 197, 54, 47, 168, 134, 233, 148, 251, 46, 86, 12, 73, 50, 238, 50, 31, 174, 27, 202, 110, 77, 161, 197, 244, 124, 17, 100, 143, 150, 232, 14, 156, 248, 43, 177, 16, 82, 244, 103, 88, 74, 84, 200, 15, 65, 187, 14, 163, 60, 91, 22, 104, 31, 211, 190, 124, 121, 79, 92, 239, 65, 185, 106, 51, 178, 168, 137, 84, 43, 79, 158, 151, 152, 83, 42, 170, 13, 106, 209, 254, 74, 39, 145, 73, 215, 17, 234, 196, 89, 30, 58, 120, 127, 88, 69, 121, 61, 18, 206, 89, 118, 243, 238, 177, 71, 73, 47, 147, 4, 155, 25, 173, 248, 206, 52, 17, 180, 122, 186, 106, 191, 252, 102, 197, 91, 16, 39, 94, 91, 224, 30, 168, 177, 26, 144, 5, 124, 128, 6 ]; for i in 0..outgoing_body_ciphertext_from_typescript.len() { diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr index 5b3583b7fbd..8418d3c6b69 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr @@ -143,7 +143,7 @@ mod test { // All the values in this test were copied over from `tagged_log.test.ts` let contract_address = AztecAddress::from_field(0x10f48cd9eff7ae5b209c557c70de2e657ee79166868676b787e9417e19260e04); let storage_slot = 0x0fe46be583b71f4ab5b70c2657ff1d05cccf1d292a9369628d1a194f944e6599; - let ovsk_app = 0x1b99ba138fa7ef8a2f122a98dd80c8ee70d447218dd780f45e165ac17ca38a5e; + let ovsk_app = 0x03a6513d6def49f41d20373d2cec894c23e7492794b08fc50c0e8a1bd2512612; let ovpk_m = Point { x: 0x1961448682803198631f299340e4206bb12809d4bebbf012b30f59af73ba1a15, y: 0x133674060c3925142aceb4f1dcd9f9137d0217d37ff8729ee5ceaa6e2790353d, @@ -176,7 +176,7 @@ mod test { // The following value was generated by `tagged_log.test.ts` // --> Run the test with AZTEC_GENERATE_TEST_DATA=1 flag to update test data. let encrypted_note_log_from_typescript = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 70, 12, 14, 67, 77, 132, 110, 193, 234, 40, 110, 64, 144, 235, 86, 55, 111, 242, 123, 221, 193, 170, 202, 225, 216, 86, 84, 159, 112, 31, 167, 126, 79, 51, 186, 47, 71, 253, 172, 99, 112, 241, 59, 197, 241, 107, 186, 232, 87, 187, 230, 171, 62, 228, 234, 42, 51, 145, 146, 238, 242, 42, 71, 206, 13, 244, 66, 111, 195, 20, 203, 98, 148, 204, 242, 145, 183, 156, 29, 141, 54, 44, 220, 194, 35, 229, 16, 32, 204, 211, 49, 142, 112, 82, 202, 116, 241, 254, 146, 42, 217, 20, 189, 70, 228, 182, 171, 205, 104, 27, 99, 171, 28, 91, 244, 21, 30, 130, 240, 5, 72, 174, 124, 97, 197, 157, 248, 204, 203, 140, 171, 181, 152, 130, 169, 179, 41, 52, 173, 45, 43, 198, 1, 152, 72, 158, 249, 11, 41, 9, 160, 48, 78, 123, 132, 203, 140, 215, 13, 22, 201, 88, 255, 139, 154, 76, 20, 63, 134, 125, 108, 239, 208, 63, 59, 33, 117, 139, 225, 184, 0, 64, 153, 21, 131, 204, 111, 41, 84, 23, 144, 222, 245, 200, 12, 234, 11, 48, 10, 221, 20, 252, 38, 122, 40, 249, 66, 248, 197, 198, 209, 79, 20, 59, 66, 197, 215, 16, 18, 145, 228, 239, 124, 81, 67, 103, 49, 196, 58, 228, 195, 64, 199, 243, 184, 112, 173, 29, 196, 215, 77, 217, 85, 82, 149, 113, 76, 201, 93, 95, 148, 37, 95, 222, 233, 210, 150, 1, 182, 28, 132, 59, 148, 156, 129, 36, 230, 55, 199, 149, 36, 205, 103, 212, 60, 151, 141, 10, 151, 222, 151, 180, 43, 91, 148, 201, 110, 165, 10, 238, 32, 134, 235, 99, 216, 200, 182, 31, 22, 156, 18, 209, 222, 172, 239, 193, 212, 86, 99, 62, 70, 182, 45, 175, 241, 91, 202, 179, 225, 99, 1, 150, 232, 2, 252, 20, 83, 49, 132, 162, 93, 116, 212, 87, 71, 211, 58, 159, 163, 40, 253, 31, 3, 192, 48, 14, 201, 80, 24, 135, 154, 207, 58, 140, 128, 29, 101, 207, 189, 182, 191, 71, 210, 64, 172, 131, 83, 46, 232, 19, 216, 183, 108, 234, 17, 104, 60, 113, 231, 145, 195, 157, 24 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 70, 12, 14, 67, 77, 132, 110, 193, 234, 40, 110, 64, 144, 235, 86, 55, 111, 242, 123, 221, 193, 170, 202, 225, 216, 86, 84, 159, 112, 31, 167, 126, 79, 51, 186, 47, 71, 253, 172, 99, 112, 241, 59, 197, 241, 107, 186, 232, 87, 187, 230, 171, 62, 228, 234, 42, 51, 145, 146, 238, 242, 42, 71, 206, 13, 244, 66, 111, 195, 20, 203, 98, 148, 204, 242, 145, 183, 156, 29, 141, 54, 44, 220, 194, 35, 229, 16, 32, 204, 211, 49, 142, 112, 82, 202, 116, 241, 254, 146, 42, 217, 20, 189, 70, 228, 182, 171, 205, 104, 27, 99, 171, 28, 91, 244, 21, 30, 130, 240, 5, 72, 174, 124, 97, 197, 157, 248, 193, 23, 193, 76, 46, 141, 144, 70, 211, 45, 67, 167, 218, 129, 140, 104, 190, 41, 110, 249, 209, 68, 106, 135, 164, 80, 235, 63, 101, 80, 32, 13, 38, 99, 145, 91, 11, 173, 151, 231, 247, 65, 153, 117, 229, 167, 64, 239, 182, 126, 235, 83, 4, 169, 8, 8, 160, 4, 235, 252, 21, 96, 84, 161, 69, 145, 145, 215, 254, 161, 117, 246, 198, 65, 89, 179, 194, 90, 19, 121, 12, 202, 114, 80, 195, 14, 60, 128, 105, 142, 100, 86, 90, 108, 157, 219, 22, 172, 20, 121, 195, 25, 159, 236, 2, 70, 75, 42, 37, 34, 2, 17, 149, 20, 176, 32, 18, 204, 56, 117, 121, 34, 15, 3, 88, 123, 64, 68, 74, 233, 63, 59, 131, 222, 194, 192, 167, 110, 217, 10, 128, 73, 129, 172, 205, 103, 212, 60, 151, 141, 10, 151, 222, 151, 180, 43, 91, 148, 201, 110, 165, 10, 238, 32, 134, 235, 99, 216, 200, 182, 31, 22, 156, 18, 209, 222, 172, 239, 193, 212, 86, 99, 62, 70, 182, 45, 175, 241, 91, 202, 179, 225, 99, 1, 150, 232, 2, 252, 20, 83, 49, 132, 162, 93, 116, 212, 87, 71, 211, 58, 159, 163, 40, 253, 31, 3, 192, 48, 14, 201, 80, 24, 135, 154, 207, 58, 140, 128, 29, 101, 207, 189, 182, 191, 71, 210, 64, 172, 131, 83, 46, 232, 19, 216, 183, 108, 234, 17, 104, 60, 113, 231, 145, 195, 157, 24 ]; for i in 0..encrypted_note_log_from_typescript.len() { assert_eq(log[i], encrypted_note_log_from_typescript[i]); diff --git a/noir-projects/aztec-nr/aztec/src/hash.nr b/noir-projects/aztec-nr/aztec/src/hash.nr index a8fc10bbdd1..64254a6a855 100644 --- a/noir-projects/aztec-nr/aztec/src/hash.nr +++ b/noir-projects/aztec-nr/aztec/src/hash.nr @@ -14,7 +14,7 @@ use dep::protocol_types::{ use crate::oracle::logs_traits::{LensForEncryptedLog, ToBytesForUnencryptedLog}; pub fn compute_secret_hash(secret: Field) -> Field { - pedersen_hash([secret], GENERATOR_INDEX__SECRET_HASH) + poseidon2_hash_with_separator([secret], GENERATOR_INDEX__SECRET_HASH) } pub fn compute_unencrypted_log_hash( @@ -72,7 +72,7 @@ pub fn compute_message_hash( // The nullifier of a l1 to l2 message is the hash of the message salted with the secret and index of the message hash // in the L1 to L2 message tree pub fn compute_message_nullifier(message_hash: Field, secret: Field, leaf_index: Field) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( [message_hash, secret, leaf_index], GENERATOR_INDEX__MESSAGE_NULLIFIER ) diff --git a/noir-projects/aztec-nr/aztec/src/history/public_storage.nr b/noir-projects/aztec-nr/aztec/src/history/public_storage.nr index c07c3d15804..dcfadd1c551 100644 --- a/noir-projects/aztec-nr/aztec/src/history/public_storage.nr +++ b/noir-projects/aztec-nr/aztec/src/history/public_storage.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ - constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX, hash::pedersen_hash, address::AztecAddress, - header::Header, utils::field::full_field_less_than + constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX, hash::poseidon2_hash_with_separator, + address::AztecAddress, header::Header, utils::field::full_field_less_than }; use std::merkle::compute_merkle_root; @@ -13,7 +13,7 @@ trait PublicStorageHistoricalRead { impl PublicStorageHistoricalRead for Header { fn public_storage_historical_read(self, storage_slot: Field, contract_address: AztecAddress) -> Field { // 1) Compute the leaf slot by siloing the storage slot with the contract address - let public_data_tree_index = pedersen_hash( + let public_data_tree_index = poseidon2_hash_with_separator( [contract_address.to_field(), storage_slot], GENERATOR_INDEX__PUBLIC_LEAF_INDEX ); diff --git a/noir-projects/aztec-nr/aztec/src/initializer.nr b/noir-projects/aztec-nr/aztec/src/initializer.nr index b5f88d9399b..039abcec656 100644 --- a/noir-projects/aztec-nr/aztec/src/initializer.nr +++ b/noir-projects/aztec-nr/aztec/src/initializer.nr @@ -1,5 +1,5 @@ use dep::protocol_types::{ - address::AztecAddress, hash::{compute_siloed_nullifier, pedersen_hash}, + address::AztecAddress, hash::{compute_siloed_nullifier, poseidon2_hash_with_separator}, constants::GENERATOR_INDEX__CONSTRUCTOR, abis::function_selector::FunctionSelector }; @@ -61,7 +61,7 @@ pub fn assert_initialization_matches_address_preimage_private(context: PrivateCo } pub fn compute_initialization_hash(init_selector: FunctionSelector, init_args_hash: Field) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( [init_selector.to_field(), init_args_hash], GENERATOR_INDEX__CONSTRUCTOR ) diff --git a/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr b/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr index 6e46ea2d989..826029605a5 100644 --- a/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr +++ b/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ - address::PublicKeysHash, constants::GENERATOR_INDEX__PUBLIC_KEYS_HASH, hash::poseidon2_hash, - point::Point, traits::{Deserialize, Serialize, Empty, is_empty} + address::PublicKeysHash, constants::GENERATOR_INDEX__PUBLIC_KEYS_HASH, + hash::poseidon2_hash_with_separator, point::Point, traits::{Deserialize, Serialize, Empty, is_empty} }; use crate::keys::constants::{NUM_KEY_TYPES, NULLIFIER_INDEX, INCOMING_INDEX, OUTGOING_INDEX}; @@ -39,7 +39,7 @@ impl PublicKeys { if is_empty(self) { 0 } else { - poseidon2_hash( + poseidon2_hash_with_separator( [ self.npk_m.x, self.npk_m.y, @@ -52,9 +52,9 @@ impl PublicKeys { self.ovpk_m.is_infinite as Field, self.tpk_m.x, self.tpk_m.y, - self.tpk_m.is_infinite as Field, + self.tpk_m.is_infinite as Field + ], GENERATOR_INDEX__PUBLIC_KEYS_HASH as Field - ] ) } ) @@ -114,7 +114,7 @@ fn compute_public_keys_hash() { }; let actual = keys.hash(); - let expected_public_keys_hash = 0x146f68c0e0ba4067d61a3304bbfdec0797d5df1357db6c01247c48bfb345c7d7; + let expected_public_keys_hash = 0x0fecd9a32db731fec1fded1b9ff957a1625c069245a3613a2538bd527068b0ad; assert(actual.to_field() == expected_public_keys_hash); } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr index bc95a67be66..501d9cb100e 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr @@ -1,4 +1,7 @@ -use dep::protocol_types::{address::AztecAddress, constants::GENERATOR_INDEX__INITIALIZATION_NULLIFIER, hash::pedersen_hash}; +use dep::protocol_types::{ + address::AztecAddress, constants::GENERATOR_INDEX__INITIALIZATION_NULLIFIER, + hash::poseidon2_hash_with_separator +}; use crate::context::{PrivateContext, UnconstrainedContext}; use crate::note::{ @@ -32,7 +35,7 @@ impl PrivateImmutable { // This is especially dangerous for initial assignment to elements of a `Map` type (for example), because the storage slot often also identifies an actor. // e.g. the initial assignment to `my_map.at(msg.sender)` will leak: `msg.sender`, the fact that an element of `my_map` was assigned-to for the first time, and the contract_address. pub fn compute_initialization_nullifier(self) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( [self.storage_slot], GENERATOR_INDEX__INITIALIZATION_NULLIFIER ) diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr index 85bc5319678..2a4ba83e383 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr @@ -1,4 +1,7 @@ -use dep::protocol_types::{address::AztecAddress, constants::GENERATOR_INDEX__INITIALIZATION_NULLIFIER, hash::pedersen_hash}; +use dep::protocol_types::{ + address::AztecAddress, constants::GENERATOR_INDEX__INITIALIZATION_NULLIFIER, + hash::poseidon2_hash_with_separator +}; use crate::context::{PrivateContext, UnconstrainedContext}; use crate::note::{ @@ -36,7 +39,7 @@ impl PrivateMutable { // Note: subsequent nullification of this state variable, via the `replace` method will not be leaky, if the `compute_note_hash_and_nullifier()` method of the underlying note is designed to ensure privacy. // For example, if the `compute_note_hash_and_nullifier()` method injects the secret key of a note owner into the computed nullifier's preimage. pub fn compute_initialization_nullifier(self) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( [self.storage_slot], GENERATOR_INDEX__INITIALIZATION_NULLIFIER ) diff --git a/noir-projects/aztec-nr/value-note/src/value_note.nr b/noir-projects/aztec-nr/value-note/src/value_note.nr index 5b97967aae1..df953c5d9d6 100644 --- a/noir-projects/aztec-nr/value-note/src/value_note.nr +++ b/noir-projects/aztec-nr/value-note/src/value_note.nr @@ -1,7 +1,7 @@ use dep::aztec::{ protocol_types::{ address::AztecAddress, traits::{Deserialize, Serialize}, constants::GENERATOR_INDEX__NOTE_NULLIFIER, - hash::poseidon2_hash + hash::poseidon2_hash_with_separator }, note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, oracle::unsafe_rand::unsafe_rand, keys::getters::get_nsk_app, context::PrivateContext @@ -27,11 +27,12 @@ impl NoteInterface for ValueNote { fn compute_note_hash_and_nullifier(self, context: &mut PrivateContext) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = context.request_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } @@ -40,11 +41,12 @@ impl NoteInterface for ValueNote { fn compute_note_hash_and_nullifier_without_context(self) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = get_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } } diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr index 4b0d7e4af7b..538ea7df988 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr @@ -1,5 +1,8 @@ use dep::aztec::prelude::{PrivateContext, AztecAddress}; -use dep::aztec::protocol_types::{constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, hash::pedersen_hash, traits::{Hash, Serialize}}; +use dep::aztec::protocol_types::{ + constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, hash::poseidon2_hash_with_separator, + traits::{Hash, Serialize} +}; use dep::authwit::entrypoint::function_call::{FunctionCall, FUNCTION_CALL_SIZE_IN_BYTES}; @@ -31,7 +34,7 @@ impl Serialize for DAppPayload { impl Hash for DAppPayload { fn hash(self) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( self.serialize(), GENERATOR_INDEX__SIGNATURE_PAYLOAD ) diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr index 6073d6e9aad..681dabb8760 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr @@ -1,6 +1,6 @@ use dep::aztec::prelude::{AztecAddress, PrivateContext, NoteHeader, NoteInterface}; use dep::aztec::{ - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash}, + protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator}, note::utils::compute_note_hash_for_consumption, keys::getters::get_nsk_app }; @@ -22,22 +22,24 @@ impl NoteInterface for Subsc fn compute_note_hash_and_nullifier(self, context: &mut PrivateContext) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = context.request_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } fn compute_note_hash_and_nullifier_without_context(self) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = get_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } } diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr index f4a2094051f..af52d3ea9f7 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr @@ -1,7 +1,10 @@ use dep::aztec::prelude::{AztecAddress, NoteInterface, NoteHeader, PrivateContext}; use dep::aztec::{ note::{utils::compute_note_hash_for_consumption}, keys::getters::get_nsk_app, - protocol_types::{traits::{Empty, Eq, Serialize}, constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash} + protocol_types::{ + traits::{Empty, Eq, Serialize}, constants::GENERATOR_INDEX__NOTE_NULLIFIER, + hash::poseidon2_hash_with_separator +} }; // Shows how to create a custom note @@ -30,22 +33,24 @@ impl NoteInterface for CardNote { fn compute_note_hash_and_nullifier(self, context: &mut PrivateContext) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = context.request_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } fn compute_note_hash_and_nullifier_without_context(self) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = get_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } } diff --git a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr index f77b83f76f2..4f03f385d0a 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr @@ -2,7 +2,7 @@ use dep::aztec::prelude::{AztecAddress, FunctionSelector, NoteHeader, NoteInterf use dep::aztec::{ note::utils::compute_note_hash_for_consumption, keys::getters::get_nsk_app, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash} + protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator} }; global ECDSA_PUBLIC_KEY_NOTE_LEN: Field = 5; @@ -68,22 +68,24 @@ impl NoteInterface f fn compute_note_hash_and_nullifier(self, context: &mut PrivateContext) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = context.request_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } fn compute_note_hash_and_nullifier_without_context(self) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = get_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } } diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr index 43acb38d757..4e4933afddb 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr @@ -1,7 +1,7 @@ use dep::aztec::prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext}; use dep::aztec::{ note::utils::compute_note_hash_for_consumption, keys::getters::get_nsk_app, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash} + protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator} }; global PUBLIC_KEY_NOTE_LEN: Field = 3; @@ -22,22 +22,24 @@ impl NoteInterface for PublicKey fn compute_note_hash_and_nullifier(self, context: &mut PrivateContext) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = context.request_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } fn compute_note_hash_and_nullifier_without_context(self) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = get_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } } diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr index 6d26cd92158..275c21e141c 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr @@ -1,6 +1,6 @@ use dep::aztec::{ prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext}, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash}, + protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator}, note::utils::compute_note_hash_for_consumption, oracle::unsafe_rand::unsafe_rand, keys::getters::get_nsk_app }; @@ -29,11 +29,12 @@ impl NoteInterface for TokenNote { fn compute_note_hash_and_nullifier(self, context: &mut PrivateContext) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = context.request_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } // docs:end:nullifier @@ -41,11 +42,12 @@ impl NoteInterface for TokenNote { fn compute_note_hash_and_nullifier_without_context(self) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = get_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } } diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr index d992cd57921..a7dbc06c5d1 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr @@ -2,7 +2,7 @@ use dep::aztec::{ note::{note_getter_options::PropertySelector, utils::compute_note_hash_for_consumption}, prelude::{NoteHeader, NoteInterface, PrivateContext}, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash} + protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator} }; global TRANSPARENT_NOTE_LEN: Field = 2; @@ -54,10 +54,11 @@ impl NoteInterface for Transpa // This achieves that the note can only be spent by the party that knows the secret. fn compute_note_hash_and_nullifier_without_context(self) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } } diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr index 20480cf6cb7..caebffbcf75 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr @@ -1,6 +1,6 @@ use dep::aztec::{ prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext}, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash}, + protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator}, note::utils::compute_note_hash_for_consumption, oracle::unsafe_rand::unsafe_rand, keys::getters::get_nsk_app }; @@ -36,11 +36,12 @@ impl NoteInterface for TokenNote { fn compute_note_hash_and_nullifier(self, context: &mut PrivateContext) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = context.request_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } // docs:end:nullifier @@ -48,11 +49,12 @@ impl NoteInterface for TokenNote { fn compute_note_hash_and_nullifier_without_context(self) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = get_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, secret, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr index 21c8bfc6ac1..7a7c6204812 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr @@ -2,7 +2,7 @@ use dep::aztec::{ note::{note_getter_options::PropertySelector, utils::compute_note_hash_for_consumption}, prelude::{NoteHeader, NoteInterface, PrivateContext}, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash} + protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator} }; global TRANSPARENT_NOTE_LEN: Field = 2; @@ -54,10 +54,11 @@ impl NoteInterface for Transpa // This achieves that the note can only be spent by the party that knows the secret. fn compute_note_hash_and_nullifier_without_context(self) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); - let nullifier = poseidon2_hash([ + let nullifier = poseidon2_hash_with_separator([ note_hash_for_nullify, + ], GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + ); (note_hash_for_nullify, nullifier) } } diff --git a/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/token_note.nr index f5b0bc47eea..a15f3653a76 100644 --- a/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/token_note.nr @@ -1,7 +1,10 @@ use dep::aztec::{ generators::{Ga1 as G_amt, Ga2 as G_npk, Ga3 as G_rnd}, prelude::{NoteHeader, NoteInterface, PrivateContext}, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, point::Point, scalar::Scalar, hash::poseidon2_hash}, + protocol_types::{ + constants::GENERATOR_INDEX__NOTE_NULLIFIER, point::Point, scalar::Scalar, + hash::poseidon2_hash_with_separator +}, note::utils::compute_note_hash_for_consumption, oracle::unsafe_rand::unsafe_rand, keys::getters::get_nsk_app, note::note_getter_options::PropertySelector }; @@ -48,11 +51,7 @@ impl NoteInterface for TokenNote { fn compute_note_hash_and_nullifier(self, context: &mut PrivateContext) -> ( Field, Field ) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = context.request_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ - note_hash_for_nullify, - secret, - GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + let nullifier = poseidon2_hash_with_separator([note_hash_for_nullify, secret], GENERATOR_INDEX__NOTE_NULLIFIER); (note_hash_for_nullify, nullifier) } // docs:end:nullifier @@ -60,16 +59,10 @@ impl NoteInterface for TokenNote { fn compute_note_hash_and_nullifier_without_context(self) -> ( Field, Field ) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = get_nsk_app(self.npk_m_hash); - let nullifier = poseidon2_hash([ - note_hash_for_nullify, - secret, - GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + let nullifier = poseidon2_hash_with_separator([note_hash_for_nullify,secret,],GENERATOR_INDEX__NOTE_NULLIFIER); (note_hash_for_nullify, nullifier) } - - fn compute_note_hiding_point(self) -> Point { // We use the unsafe version because the multi_scalar_mul will constrain the scalars. let npk_m_hash_scalar = from_field_unsafe(self.npk_m_hash); diff --git a/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/transparent_note.nr index e3b028c722a..8d0efabe993 100644 --- a/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_with_refunds_contract/src/types/transparent_note.nr @@ -2,7 +2,7 @@ use dep::aztec::{ note::{note_getter_options::PropertySelector, utils::compute_note_hash_for_consumption}, prelude::{NoteHeader, NoteInterface, PrivateContext}, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash} + protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator} }; global TRANSPARENT_NOTE_LEN: Field = 2; @@ -55,10 +55,7 @@ impl NoteInterface for Transpa // This achieves that the note can only be spent by the party that knows the secret. fn compute_note_hash_and_nullifier_without_context(self) -> (Field, Field) { let note_hash_for_nullify = compute_note_hash_for_consumption(self); - let nullifier = poseidon2_hash([ - note_hash_for_nullify, - GENERATOR_INDEX__NOTE_NULLIFIER as Field, - ]); + let nullifier = poseidon2_hash_with_separator([note_hash_for_nullify], GENERATOR_INDEX__NOTE_NULLIFIER); (note_hash_for_nullify, nullifier) } } diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr index dd5cdd193a2..33b92cc2253 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr @@ -1,6 +1,6 @@ use dep::types::{ traits::{Empty, is_empty}, abis::{validation_requests::ScopedKeyValidationRequestAndGenerator}, - constants::MAX_KEY_VALIDATION_REQUESTS_PER_TX, scalar::Scalar, hash::poseidon2_hash, + constants::MAX_KEY_VALIDATION_REQUESTS_PER_TX, scalar::Scalar, hash::poseidon2_hash_with_separator, utils::arrays::filter_array_to_bounded_vec }; use std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key; @@ -52,7 +52,10 @@ pub fn reset_key_validation_requests( // Then we check that siloing the master secret key with the contract address gives the app secret key - let sk_app = poseidon2_hash([sk_m.hi, sk_m.lo, contract_address.to_field(), sk_app_generator]); + let sk_app = poseidon2_hash_with_separator( + [sk_m.hi, sk_m.lo, contract_address.to_field()], + sk_app_generator + ); assert( sk_app.eq(request.sk_app), "Failed to derive matching app secret key from the secret key." ); diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr index 30bce550183..aa6e4b05864 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr @@ -1,6 +1,7 @@ use crate::abis::function_selector::FunctionSelector; use crate::constants::GENERATOR_INDEX__FUNCTION_LEAF; use crate::traits::Hash; +use crate::hash::poseidon2_hash_with_separator; struct ContractClassFunctionLeafPreimage { selector : FunctionSelector, @@ -9,7 +10,7 @@ struct ContractClassFunctionLeafPreimage { impl Hash for ContractClassFunctionLeafPreimage { fn hash(self) -> Field { - std::hash::pedersen_hash_with_separator([ + poseidon2_hash_with_separator([ self.selector.to_field(), self.vk_hash, ], GENERATOR_INDEX__FUNCTION_LEAF) diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr index d41de941d50..94e91d8d2c7 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr @@ -1,7 +1,7 @@ use crate::{ abis::function_selector::FunctionSelector, - constants::{GENERATOR_INDEX__FUNCTION_DATA, FUNCTION_DATA_LENGTH}, hash::pedersen_hash, - traits::{Serialize, Hash, Deserialize, Empty} + constants::{GENERATOR_INDEX__FUNCTION_DATA, FUNCTION_DATA_LENGTH}, + hash::poseidon2_hash_with_separator, traits::{Serialize, Hash, Deserialize, Empty} }; struct FunctionData { @@ -39,7 +39,7 @@ impl Deserialize for FunctionData { impl Hash for FunctionData { fn hash(self) -> Field { - pedersen_hash(self.serialize(), GENERATOR_INDEX__FUNCTION_DATA) + poseidon2_hash_with_separator(self.serialize(), GENERATOR_INDEX__FUNCTION_DATA) } } @@ -67,6 +67,6 @@ fn empty_hash() { let hash = data.hash(); // Value from function_data.test.ts "computes empty function data hash" test - let test_data_empty_hash = 0x27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed; + let test_data_empty_hash = 0x2ee7682681179c2d8290a805cdeb64cc9744167fd5c801c26f1b3f9757c4eebc; assert_eq(hash, test_data_empty_hash); } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_stack_item.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_stack_item.nr index 854ce2d82b5..5cff83418a7 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_stack_item.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_stack_item.nr @@ -1,8 +1,9 @@ use crate::{ abis::{function_data::FunctionData, private_circuit_public_inputs::PrivateCircuitPublicInputs}, address::AztecAddress, - constants::{GENERATOR_INDEX__CALL_STACK_ITEM, PRIVATE_CALL_STACK_ITEM_LENGTH}, hash::pedersen_hash, - traits::{Deserialize, Hash, Serialize, Empty}, utils::reader::Reader + constants::{GENERATOR_INDEX__CALL_STACK_ITEM, PRIVATE_CALL_STACK_ITEM_LENGTH}, + hash::poseidon2_hash_with_separator, traits::{Deserialize, Hash, Serialize, Empty}, + utils::reader::Reader }; struct PrivateCallStackItem { @@ -56,7 +57,7 @@ impl Deserialize for PrivateCallStackItem { impl Hash for PrivateCallStackItem { fn hash(self) -> Field { - pedersen_hash(self.serialize(), GENERATOR_INDEX__CALL_STACK_ITEM) + poseidon2_hash_with_separator(self.serialize(), GENERATOR_INDEX__CALL_STACK_ITEM) } } @@ -85,6 +86,6 @@ fn empty_hash() { let hash = item.hash(); // Value from private_call_stack_item.test.ts "computes empty item hash" test - let test_data_empty_hash = 0x2418613f5080d6d2aa82928b92acbb84f738d69c93635837e379f88fdcc19688; + let test_data_empty_hash = 0x2a254c3fa6968b59e98b456f4353671a4923a4c8280fb6e142ef0071b95466be; assert_eq(hash, test_data_empty_hash); } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr index fd55c562944..6cfad60bd14 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr @@ -13,7 +13,7 @@ use crate::{ GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS, MAX_ENCRYPTED_LOGS_PER_CALL, MAX_UNENCRYPTED_LOGS_PER_CALL, MAX_NOTE_ENCRYPTED_LOGS_PER_CALL }, - header::Header, hash::pedersen_hash, messaging::l2_to_l1_message::L2ToL1Message, + header::Header, hash::poseidon2_hash_with_separator, messaging::l2_to_l1_message::L2ToL1Message, traits::{Deserialize, Hash, Serialize, Empty}, utils::reader::Reader, transaction::tx_context::TxContext, utils::arrays::validate_array }; @@ -206,7 +206,7 @@ impl Deserialize for PrivateCircuitPublicI impl Hash for PrivateCircuitPublicInputs { fn hash(self) -> Field { - pedersen_hash(self.serialize(), GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS) + poseidon2_hash_with_separator(self.serialize(), GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS) } } @@ -253,6 +253,6 @@ fn empty_hash() { let hash = inputs.hash(); // Value from private_circuit_public_inputs.test.ts "computes empty item hash" test - let test_data_empty_hash = 0x0104a7f82b1f6346a5ba95eafd44f2f851097d8abd793d8b16e8744d11a76d03; + let test_data_empty_hash = 0x29f35524edb1bed6c1eded107142d65ca80f46656c1c7ded71c46dbda14feec5; assert_eq(hash, test_data_empty_hash); } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr index 72ccc1c14f0..3d57f18330a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr @@ -14,7 +14,7 @@ use crate::{ PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH, MAX_UNENCRYPTED_LOGS_PER_CALL }, contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest}, - hash::pedersen_hash, header::Header, messaging::l2_to_l1_message::L2ToL1Message, + hash::poseidon2_hash_with_separator, header::Header, messaging::l2_to_l1_message::L2ToL1Message, traits::{Hash, Serialize, Deserialize, Empty}, utils::reader::Reader }; @@ -155,7 +155,7 @@ impl Deserialize for PublicCircuitPublicInp impl Hash for PublicCircuitPublicInputs { fn hash(self) -> Field { - pedersen_hash(self.serialize(), GENERATOR_INDEX__PUBLIC_CIRCUIT_PUBLIC_INPUTS) + poseidon2_hash_with_separator(self.serialize(), GENERATOR_INDEX__PUBLIC_CIRCUIT_PUBLIC_INPUTS) } } @@ -203,6 +203,6 @@ fn empty_hash() { let hash = inputs.hash(); // Value from public_circuit_public_inputs.test.ts "computes empty item hash" test - let test_data_empty_hash = 0x21be4398b9e455b4afd91304dcc40210c2f94477d5f58b32f79fd21bf9008618; + let test_data_empty_hash = 0x0ce92e52cdf4f36c4734556eca0cc66f264ac7548ab7556227bca067fc7b5e84; assert_eq(hash, test_data_empty_hash); } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr index 550669fc8e0..0d12098c4f5 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr @@ -38,7 +38,7 @@ impl Empty for PublicDataRead { impl Hash for PublicDataRead { fn hash(self) -> Field { - std::hash::pedersen_hash_with_separator([ + crate::hash::poseidon2_hash_with_separator([ self.leaf_slot, self.value, ], GENERATOR_INDEX__PUBLIC_DATA_READ) diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr index 4c60e388284..ac0d0738915 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr @@ -56,7 +56,7 @@ impl Empty for PublicDataUpdateRequest { impl Hash for PublicDataUpdateRequest { fn hash(self) -> Field { - std::hash::pedersen_hash_with_separator([ + crate::hash::poseidon2_hash_with_separator([ self.leaf_slot, self.new_value ], GENERATOR_INDEX__PUBLIC_DATA_UPDATE_REQUEST) diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr index 46348c22813..daa30dc0f82 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr @@ -1,7 +1,7 @@ use crate::{ crate::address::{eth_address::EthAddress, partial_address::PartialAddress, public_keys_hash::PublicKeysHash}, constants::{AZTEC_ADDRESS_LENGTH, GENERATOR_INDEX__CONTRACT_ADDRESS_V1}, - contract_class_id::ContractClassId, hash::poseidon2_hash, + contract_class_id::ContractClassId, hash::poseidon2_hash_with_separator, traits::{Empty, FromField, ToField, Serialize, Deserialize}, utils }; @@ -55,10 +55,9 @@ impl AztecAddress { pub fn compute(pub_keys_hash: PublicKeysHash, partial_address: PartialAddress) -> AztecAddress { AztecAddress::from_field( - poseidon2_hash( - [ - pub_keys_hash.to_field(), partial_address.to_field(), GENERATOR_INDEX__CONTRACT_ADDRESS_V1 as Field - ] + poseidon2_hash_with_separator( + [pub_keys_hash.to_field(), partial_address.to_field()], + GENERATOR_INDEX__CONTRACT_ADDRESS_V1 ) ) } @@ -83,7 +82,7 @@ fn compute_address_from_partial_and_pub_keys_hash() { let partial_address = PartialAddress::from_field(2); let address = AztecAddress::compute(pub_keys_hash, partial_address); - let expected_computed_address_from_partial_and_pubkey = 0x1b6ead051e7b42665064ca6cf1ec77da0a36d86e00d1ff6e44077966c0c3a9fa; + let expected_computed_address_from_partial_and_pubkey = 0x23ce9be3fa3c846b0f9245cc796902e731d04f086e8a42473bb29e405fc98075; assert(address.to_field() == expected_computed_address_from_partial_and_pubkey); } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/mod.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/mod.nr index 20594437e86..636a6b26578 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/mod.nr @@ -10,10 +10,10 @@ use crate::address::partial_address::PartialAddress; use crate::address::public_keys_hash::PublicKeysHash; use crate::address::salted_initialization_hash::SaltedInitializationHash; -use crate::{constants::GENERATOR_INDEX__CONSTRUCTOR, hash::pedersen_hash}; +use crate::{constants::GENERATOR_INDEX__CONSTRUCTOR, hash::poseidon2_hash_with_separator}; pub fn compute_initialization_hash(selector: Field, args_hash: Field) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( [ selector, args_hash diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr index 3a802d9f9eb..ae8d8ee73cf 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr @@ -4,7 +4,7 @@ use crate::{ aztec_address::AztecAddress }, constants::GENERATOR_INDEX__PARTIAL_ADDRESS, contract_class_id::ContractClassId, - hash::pedersen_hash, traits::{ToField, FromField, Serialize, Deserialize} + hash::poseidon2_hash_with_separator, traits::{ToField, FromField, Serialize, Deserialize} }; global PARTIAL_ADDRESS_LENGTH = 1; @@ -54,7 +54,7 @@ impl PartialAddress { salted_initialization_hash: SaltedInitializationHash ) -> Self { PartialAddress::from_field( - pedersen_hash( + poseidon2_hash_with_separator( [ contract_class_id.to_field(), salted_initialization_hash.to_field() diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/salted_initialization_hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/salted_initialization_hash.nr index ca916f85ac7..1b04dec19eb 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/salted_initialization_hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/salted_initialization_hash.nr @@ -1,6 +1,6 @@ use crate::{ address::{eth_address::EthAddress, aztec_address::AztecAddress}, - constants::GENERATOR_INDEX__PARTIAL_ADDRESS, hash::pedersen_hash, traits::ToField + constants::GENERATOR_INDEX__PARTIAL_ADDRESS, hash::poseidon2_hash_with_separator, traits::ToField }; // Salted initialization hash. Used in the computation of a partial address. @@ -21,7 +21,7 @@ impl SaltedInitializationHash { pub fn compute(salt: Field, initialization_hash: Field, deployer: AztecAddress) -> Self { SaltedInitializationHash::from_field( - pedersen_hash( + poseidon2_hash_with_separator( [ salt, initialization_hash, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index 64efcf3ac1d..b48992dec4e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -175,11 +175,11 @@ global L2_GAS_PER_NOTE_HASH: u32 = 32; global L2_GAS_PER_NULLIFIER: u32 = 64; // CANONICAL CONTRACT ADDRESSES -global CANONICAL_KEY_REGISTRY_ADDRESS = 0x04c2d010f88e8c238882fbbcbce5c81fdc1dc8ece85e8dbf3f602b4d81ec0351; -global CANONICAL_AUTH_REGISTRY_ADDRESS = 0x27ffa4fb3da8a80b6365315f9798c887474854c71c0720e1c5236861288ce147; -global DEPLOYER_CONTRACT_ADDRESS = 0x2b231c13768709b1ba51c1f86275b47e38dfac16e3d7f242cb578d92a4e2d934; -global REGISTERER_CONTRACT_ADDRESS = 0x1da1c95bfa44d2d94cda61564e0b28a3515f0b2ad4bd8d30d86572f02e2fba00; -global GAS_TOKEN_ADDRESS = 0x06fc7badd50bb8ee32439b52e8874b5a16ddd2aa1d5647ec46b2a0f51356f889; +global CANONICAL_KEY_REGISTRY_ADDRESS = 0x0414f08a3241bff274504c14522869898d5ed3aa6c3d6e20f216953ec98641b7; +global CANONICAL_AUTH_REGISTRY_ADDRESS = 0x00a52eacfd4eb01f233f5f01fce672d8f91295fded9d62ad9f708519df4529a6; +global DEPLOYER_CONTRACT_ADDRESS = 0x14773f1105c64880735d3971d29ae33fda04f8969500501d6eacecad7abc080e; +global REGISTERER_CONTRACT_ADDRESS = 0x01eaefbfac0fa59ec9f018f85809e0bfb0cd391122788c12fb31aab0bf0a8eda; +global GAS_TOKEN_ADDRESS = 0x1367c66d6702663df6aa283bbd675463593376cd09eb310a1a8fe6086dba0073; // LENGTH OF STRUCTS SERIALIZED TO FIELDS global AZTEC_ADDRESS_LENGTH = 1; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr b/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr index 7ae3a07f3d2..32b52180d58 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr @@ -41,7 +41,7 @@ impl ContractClassId { private_functions_root: Field, public_bytecode_commitment: Field ) -> Self { - let hash = std::hash::pedersen_hash_with_separator( + let hash = crate::hash::poseidon2_hash_with_separator( [ artifact_hash, private_functions_root, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_read.nr b/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_read.nr index 1ca110a1b71..6f44e699eea 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_read.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_read.nr @@ -1,6 +1,6 @@ use crate::{ - constants::{CONTRACT_STORAGE_READ_LENGTH, GENERATOR_INDEX__PUBLIC_DATA_READ}, hash::pedersen_hash, - traits::{Deserialize, Hash, Empty, Serialize} + constants::{CONTRACT_STORAGE_READ_LENGTH, GENERATOR_INDEX__PUBLIC_DATA_READ}, + hash::poseidon2_hash_with_separator, traits::{Deserialize, Hash, Empty, Serialize} }; struct StorageRead { @@ -28,7 +28,7 @@ impl Empty for StorageRead { impl Hash for StorageRead { fn hash(self) -> Field { - pedersen_hash(self.serialize(), GENERATOR_INDEX__PUBLIC_DATA_READ) + poseidon2_hash_with_separator(self.serialize(), GENERATOR_INDEX__PUBLIC_DATA_READ) } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr index 5f5cc1ae146..569ff8f03e9 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr @@ -1,6 +1,6 @@ use crate::{ constants::{CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH, GENERATOR_INDEX__PUBLIC_DATA_UPDATE_REQUEST}, - hash::pedersen_hash, traits::{Deserialize, Hash, Empty, Serialize} + hash::poseidon2_hash_with_separator, traits::{Deserialize, Hash, Empty, Serialize} }; struct StorageUpdateRequest { @@ -28,7 +28,7 @@ impl Empty for StorageUpdateRequest { impl Hash for StorageUpdateRequest { fn hash(self) -> Field { - pedersen_hash(self.serialize(), GENERATOR_INDEX__PUBLIC_DATA_UPDATE_REQUEST) + poseidon2_hash_with_separator(self.serialize(), GENERATOR_INDEX__PUBLIC_DATA_UPDATE_REQUEST) } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/data/hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/data/hash.nr index c10db9c2009..da59417bbc6 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/data/hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/data/hash.nr @@ -1,7 +1,7 @@ use crate::{address::AztecAddress, constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX}; pub fn compute_public_data_tree_index(contract_address: AztecAddress, storage_slot: Field) -> Field { - std::hash::pedersen_hash_with_separator( + crate::hash::poseidon2_hash_with_separator( [ contract_address.to_field(), storage_slot diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr index c98658570af..a1b76feb3a6 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr @@ -35,7 +35,7 @@ pub fn private_functions_root_from_siblings( fn compute_note_hash_nonce(tx_hash: Field, note_index_in_tx: u32) -> Field { // Hashing tx hash with note index in tx is guaranteed to be unique - pedersen_hash( + poseidon2_hash_with_separator( [ tx_hash, note_index_in_tx as Field @@ -46,11 +46,11 @@ fn compute_note_hash_nonce(tx_hash: Field, note_index_in_tx: u32) -> Field { pub fn compute_unique_note_hash(nonce: Field, slotted_note_hash: Field) -> Field { let inputs = [nonce, slotted_note_hash]; - pedersen_hash(inputs, GENERATOR_INDEX__UNIQUE_NOTE_HASH) + poseidon2_hash_with_separator(inputs, GENERATOR_INDEX__UNIQUE_NOTE_HASH) } pub fn compute_siloed_note_hash(app: AztecAddress, unique_note_hash: Field) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( [ app.to_field(), unique_note_hash @@ -70,7 +70,7 @@ pub fn silo_note_hash(note_hash: ScopedNoteHash, tx_hash: Field, note_index_in_t } pub fn compute_siloed_nullifier(app: AztecAddress, nullifier: Field) -> Field { - pedersen_hash( + poseidon2_hash_with_separator( [ app.to_field(), nullifier @@ -90,7 +90,7 @@ pub fn silo_nullifier(nullifier: ScopedNullifier) -> Field { pub fn compute_siloed_encrypted_log_hash(address: AztecAddress, randomness: Field, log_hash: Field) -> Field { // TODO: Using 0 GENERATOR_INDEX here as interim before we move to posiedon // NB: A unique separator will be needed for masked_contract_address - let mut masked_contract_address = pedersen_hash([address.to_field(), randomness], 0); + let mut masked_contract_address = poseidon2_hash_with_separator([address.to_field(), randomness], 0); if randomness == 0 { // In some cases, we actually want to reveal the contract address we are siloing with: // e.g. 'handshaking' contract w/ known address diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/header.nr b/noir-projects/noir-protocol-circuits/crates/types/src/header.nr index f72fde346f5..96e7a04ec4a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/header.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/header.nr @@ -4,8 +4,9 @@ use crate::{ global_variables::{GlobalVariables, GLOBAL_VARIABLES_LENGTH} }, constants::{GENERATOR_INDEX__BLOCK_HASH, HEADER_LENGTH, STATE_REFERENCE_LENGTH, CONTENT_COMMITMENT_LENGTH}, - hash::pedersen_hash, state_reference::StateReference, traits::{Deserialize, Empty, Hash, Serialize}, - utils::arr_copy_slice, content_commitment::ContentCommitment + hash::poseidon2_hash_with_separator, state_reference::StateReference, + traits::{Deserialize, Empty, Hash, Serialize}, utils::arr_copy_slice, + content_commitment::ContentCommitment }; // docs:start:header @@ -84,7 +85,7 @@ impl Empty for Header { impl Hash for Header { fn hash(self) -> Field { - pedersen_hash(self.serialize(), GENERATOR_INDEX__BLOCK_HASH) + poseidon2_hash_with_separator(self.serialize(), GENERATOR_INDEX__BLOCK_HASH) } } @@ -108,6 +109,6 @@ fn empty_hash_is_zero() { let hash = header.hash(); // Value from new_contract_data.test.ts "computes empty hash" test - let test_data_empty_hash = 0x2080fad33d703007c3c08f3c0b17cda1550e9d706cb4fdb031f2312d8a50fa8b; + let test_data_empty_hash = 0x1c97ed6fbc35f8b400d31bd38ce5cc938921e0cf2e20159d316f8c7011f9f42c; assert_eq(hash, test_data_empty_hash); } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr index 836e673b5e1..2ac2477daeb 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr @@ -20,7 +20,7 @@ global default_private_function = ContractFunction { membership_witness: MembershipWitness { leaf_index: 0, sibling_path: [ - 0x1e5cebe7a50c5c8fd1ebe19ed6bbf80f77819b12a2a28f334e895501e1cda574, + 0x1eca11cd2abe68905eab86bc4f207cde29eb7c2b4c2c9b27e3d8c2f8b8234c87, 0x21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550, 0x0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb, 0x06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d, @@ -40,7 +40,7 @@ global default_public_function = ContractFunction { leaf_index: 2, sibling_path: [ 0x2d72ef5ebb7c974e1f5a8bed092f1cf1bf0a0cb1eda28516221ca7e5811ecf15, - 0x1bed44f12632c0a6343cd886bd3e548bb5e8d2fd35fe9bc81f28defd4ed885b0, + 0x0d18bf69ba03cceb5b3ad320c0439559ae10eabd18dea07ea239c8eb2a96c3f8, 0x0837a67313f4dbbd8d6971c0672f961f0a3b9e218c1395d327915209292acbbf, 0x2e0ef36ddc5db29acb6ef904999046f835ce7c78a40c3f7a0edb03b2f917a765, 0x1a9fdb505152f9c2baaffe4a30ee80775b58ebf8c2dde76435835b085c6f70ca, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr index 1ca20064484..f3bd812b1bb 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr @@ -20,12 +20,12 @@ global default_contract = ContractData { contract_address_salt: 0x000000000000000000000000000000000000000000000000000000000000ddd5, artifact_hash: 0x0000000000000000000000000000000000000000000000000000000000003039, public_bytecode_commitment: 0x0000000000000000000000000000000000000000000000000000000000000005, - private_functions_root: 0x19a3cc0b714976fb35d58b684ba36e86f82bac8b87517904a2727e5113fb4cba, - address: AztecAddress { inner: 0x24e2561e4216c843ff11bf77d4f8a68247e537980273ce54b09b505f7352f6bb }, - partial_address: PartialAddress { inner: 0x27ab8475fe4647b48ffc4df7a6cc42bf1125f000ff113d9a0d6a11b952626761 }, - contract_class_id: ContractClassId { inner: 0x29f4bda24f38507064a90f7505dc0381c9d83c97271c5c2e92a4261d300861bf }, + private_functions_root: 0x04c207a8a83f20ee6c6dbeb40636e8132bc18e971927f7d81f18cb92705ee817, + address: AztecAddress { inner: 0x10f0c308adf33bceef3ed638bf8a5b403691eefc4ee7a0c20f0438c8a7096226 }, + partial_address: PartialAddress { inner: 0x08e858be915646809621b06c4fcea0bfcf2817b07c1885e9a0497554638be93f }, + contract_class_id: ContractClassId { inner: 0x227e7a3a22b2a95ce3b91fbb47a80669d7d68ee34db7bf998cb9457ee59f3179 }, public_keys_hash: PublicKeysHash { inner: 0x000000000000000000000000000000000000000000000000000000000000b26e }, - salted_initialization_hash: SaltedInitializationHash { inner: 0x25765504545d2cdaaa6544eb24bc78a3e20384452f2525669f196a1a42f45906 }, + salted_initialization_hash: SaltedInitializationHash { inner: 0x13a939daa511233e5446905ed2cadbee14948fa75df183b53b5c14b612bffe88 }, deployer: AztecAddress { inner: 0x0000000000000000000000000000000000000000000000000000000000000000 } }; @@ -34,11 +34,11 @@ global parent_contract = ContractData { contract_address_salt: 0x0000000000000000000000000000000000000000000000000000000000001618, artifact_hash: 0x00000000000000000000000000000000000000000000000000000000000004bc, public_bytecode_commitment: 0x0000000000000000000000000000000000000000000000000000000000000005, - private_functions_root: 0x2c1c949cb226995de94b7b8b5aeaab440739f2dfeb06d358441f60932cf243a7, - address: AztecAddress { inner: 0x24692d7dbb532557c7466e8782d1fe99077e4787570414bd1a5e8fa5300caad8 }, - partial_address: PartialAddress { inner: 0x127bbd73a3cf497fb2d85342571695d894985b449a9343eec55485e9cbc514f8 }, - contract_class_id: ContractClassId { inner: 0x037a09515a79a2b8ebe5139dae1ab7c433523ac1fd5631836890df2148df51c7 }, + private_functions_root: 0x13911dea3b1d55fe459c95739f42df2cd7c2c610ab16a5632ab649760f3d0522, + address: AztecAddress { inner: 0x0df89b4b442718bc22a06f5ac353e83562adb5c48465dd2663e90648067ab87b }, + partial_address: PartialAddress { inner: 0x2e150667b5cd21814d880d7c853a637d3818fc545209a8a90521079351e836c7 }, + contract_class_id: ContractClassId { inner: 0x198333ba87796984608fe55a13c975fd3fa8ce721ee4d4b97b6886818a1d8fdb }, public_keys_hash: PublicKeysHash { inner: 0x00000000000000000000000000000000000000000000000000000000000011c1 }, - salted_initialization_hash: SaltedInitializationHash { inner: 0x04643e65513869350552499ed3412df59540dffe3cd698203deee8900b53bcec }, + salted_initialization_hash: SaltedInitializationHash { inner: 0x24bd6ac7a182e2cf25e437c72f53544ef81dfd97d9afee23abb07a638e7be749 }, deployer: AztecAddress { inner: 0x0000000000000000000000000000000000000000000000000000000000000000 } }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr index 1da12afa7bd..3c053162519 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr @@ -1,5 +1,5 @@ use crate::{ - constants::{GENERATOR_INDEX__TX_CONTEXT, TX_CONTEXT_LENGTH}, hash::pedersen_hash, + constants::{GENERATOR_INDEX__TX_CONTEXT, TX_CONTEXT_LENGTH}, hash::poseidon2_hash_with_separator, traits::{Deserialize, Hash, Serialize, Empty}, utils::reader::Reader, abis::gas_settings::GasSettings }; @@ -68,7 +68,7 @@ impl Deserialize for TxContext { impl Hash for TxContext { fn hash(self) -> Field { - pedersen_hash(self.serialize(), GENERATOR_INDEX__TX_CONTEXT) + poseidon2_hash_with_separator(self.serialize(), GENERATOR_INDEX__TX_CONTEXT) } } @@ -86,6 +86,6 @@ fn empty_hash() { let hash = context.hash(); // Value from tx_context.test.ts "computes empty item hash" test - let test_data_empty_hash = 0x17e4357684c5a4349b4587c95b0b6161dcb4a3c5b02d4eb2ecc3b02c80193261; + let test_data_empty_hash = 0x0b81be18198d45a61eba2c59db95ebdac35d57c9d8ab524e52f0f39417aba5fe; assert_eq(hash, test_data_empty_hash); } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr index 691c7091e24..45225d1c80e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr @@ -1,6 +1,6 @@ use crate::{ address::AztecAddress, abis::function_data::FunctionData, abis::gas_settings::GasSettings, - constants::{GENERATOR_INDEX__TX_REQUEST, TX_REQUEST_LENGTH}, hash::pedersen_hash, + constants::{GENERATOR_INDEX__TX_REQUEST, TX_REQUEST_LENGTH}, hash::poseidon2_hash_with_separator, traits::{Hash, Serialize, Deserialize, Empty}, transaction::tx_context::TxContext, utils::reader::Reader }; @@ -34,7 +34,7 @@ impl Eq for TxRequest { impl Hash for TxRequest { fn hash(self) -> Field { - pedersen_hash(self.serialize(), GENERATOR_INDEX__TX_REQUEST) + poseidon2_hash_with_separator(self.serialize(), GENERATOR_INDEX__TX_REQUEST) } } @@ -98,7 +98,7 @@ mod tests { function_data: FunctionData { selector: FunctionSelector::from_u32(2), is_private: true } }; // Value from tx_request.test.ts "compute hash" test - let test_data_tx_request_hash = 0x0d982a1c7a65919b2bcacbf5660f5b861132072a8190d97c82b1591da402f5ea; + let test_data_tx_request_hash = 0x289d3f85f463f3449e2204433b860574d351e9fbd97a01a722239fdd9ce3ce9b; assert(tx_request.hash() == test_data_tx_request_hash); } } diff --git a/yarn-project/aztec.js/src/entrypoint/payload.ts b/yarn-project/aztec.js/src/entrypoint/payload.ts index 2d246f21411..bb849489f3d 100644 --- a/yarn-project/aztec.js/src/entrypoint/payload.ts +++ b/yarn-project/aztec.js/src/entrypoint/payload.ts @@ -2,7 +2,7 @@ import { FunctionCall, PackedValues } from '@aztec/circuit-types'; import { type AztecAddress, Fr, type GasSettings, GeneratorIndex } from '@aztec/circuits.js'; import { FunctionType } from '@aztec/foundation/abi'; import { padArrayEnd } from '@aztec/foundation/collection'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { type Tuple } from '@aztec/foundation/serialize'; import { type FeePaymentMethod } from '../fee/fee_payment_method.js'; @@ -100,7 +100,7 @@ export abstract class EntrypointPayload { * @returns The hash of the payload */ hash() { - return pedersenHash(this.toFields(), this.#generatorIndex); + return poseidon2HashWithSeparator(this.toFields(), this.#generatorIndex); } /** Serializes the function calls to an array of fields. */ diff --git a/yarn-project/aztec.js/src/utils/authwit.ts b/yarn-project/aztec.js/src/utils/authwit.ts index e3df2b9a527..d59ef37e3d0 100644 --- a/yarn-project/aztec.js/src/utils/authwit.ts +++ b/yarn-project/aztec.js/src/utils/authwit.ts @@ -1,6 +1,6 @@ import { type FunctionCall, PackedValues } from '@aztec/circuit-types'; import { type AztecAddress, Fr, GeneratorIndex } from '@aztec/circuits.js'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js'; @@ -81,7 +81,7 @@ export const computeInnerAuthWitHashFromAction = (caller: AztecAddress, action: * @returns The inner hash for the witness */ export const computeInnerAuthWitHash = (args: Fr[]) => { - return pedersenHash(args, GeneratorIndex.AUTHWIT_INNER); + return poseidon2HashWithSeparator(args, GeneratorIndex.AUTHWIT_INNER); }; /** @@ -99,5 +99,5 @@ export const computeInnerAuthWitHash = (args: Fr[]) => { * @returns The outer hash for the witness */ const computeOuterAuthWitHash = (consumer: AztecAddress, chainId: Fr, version: Fr, innerHash: Fr) => { - return pedersenHash([consumer.toField(), chainId, version, innerHash], GeneratorIndex.AUTHWIT_OUTER); + return poseidon2HashWithSeparator([consumer.toField(), chainId, version, innerHash], GeneratorIndex.AUTHWIT_OUTER); }; diff --git a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_outgoing_body.ts b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_outgoing_body.ts index 69f1593d23d..69507f1a9c2 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_outgoing_body.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_outgoing_body.ts @@ -1,6 +1,6 @@ import { AztecAddress, Fr, GeneratorIndex, GrumpkinScalar, Point, type PublicKey } from '@aztec/circuits.js'; import { Aes128 } from '@aztec/circuits.js/barretenberg'; -import { poseidon2Hash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; export class EncryptedLogOutgoingBody { @@ -95,6 +95,9 @@ export class EncryptedLogOutgoingBody { // For performance reasons, we do NOT use the usual `deriveAESSecret` function here and instead we compute it using // poseidon. Note that we can afford to use poseidon here instead of deriving shared secret using Diffie-Hellman // because for outgoing we are encrypting for ourselves and hence we don't need to perform a key exchange. - return poseidon2Hash([ovskApp.hi, ovskApp.lo, ephPk.x, ephPk.y, GeneratorIndex.SYMMETRIC_KEY]).toBuffer(); + return poseidon2HashWithSeparator( + [ovskApp.hi, ovskApp.lo, ephPk.x, ephPk.y], + GeneratorIndex.SYMMETRIC_KEY, + ).toBuffer(); } } diff --git a/yarn-project/circuit-types/src/logs/l1_payload/l1_event_payload.test.ts b/yarn-project/circuit-types/src/logs/l1_payload/l1_event_payload.test.ts index 1598b9c02f1..e92dfb757f8 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/l1_event_payload.test.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/l1_event_payload.test.ts @@ -1,6 +1,6 @@ import { AztecAddress, KeyValidationRequest, computeOvskApp, derivePublicKeyFromSecretKey } from '@aztec/circuits.js'; import { EventSelector } from '@aztec/foundation/abi'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; import { EncryptedL2Log } from '../encrypted_l2_log.js'; @@ -28,7 +28,7 @@ describe('L1 Event Payload', () => { beforeAll(() => { contractAddress = AztecAddress.random(); randomness = Fr.random(); - maskedContractAddress = pedersenHash([contractAddress, randomness], 0); + maskedContractAddress = poseidon2HashWithSeparator([contractAddress, randomness], 0); payload = new L1EventPayload(Event.random(), contractAddress, randomness, EventSelector.random()); diff --git a/yarn-project/circuit-types/src/logs/l1_payload/l1_payload.ts b/yarn-project/circuit-types/src/logs/l1_payload/l1_payload.ts index 758b0379c9c..5531b011675 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/l1_payload.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/l1_payload.ts @@ -6,7 +6,7 @@ import { computeOvskApp, derivePublicKeyFromSecretKey, } from '@aztec/circuits.js'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { type Fr, Point } from '@aztec/foundation/fields'; import { BufferReader } from '@aztec/foundation/serialize'; @@ -155,7 +155,7 @@ export abstract class L1Payload { randomness: Fr, maskedContractAddress: Fr, ) { - if (!pedersenHash([contractAddress, randomness], 0).equals(maskedContractAddress)) { + if (!poseidon2HashWithSeparator([contractAddress, randomness], 0).equals(maskedContractAddress)) { throw new Error( 'The provided masked contract address does not match with the incoming address from header and randomness from body', ); diff --git a/yarn-project/circuit-types/src/logs/l1_payload/tagged_log.test.ts b/yarn-project/circuit-types/src/logs/l1_payload/tagged_log.test.ts index 01000c26e56..2c3a41cc8e7 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/tagged_log.test.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/tagged_log.test.ts @@ -1,6 +1,6 @@ import { AztecAddress, KeyValidationRequest, computeOvskApp, derivePublicKeyFromSecretKey } from '@aztec/circuits.js'; import { EventSelector, NoteSelector } from '@aztec/foundation/abi'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; import { updateInlineTestData } from '@aztec/foundation/testing'; @@ -83,7 +83,7 @@ describe('L1 Note Payload', () => { const encrypted = taggedLog.encrypt(ephSk, recipientAddress, ivpk, ovKeys).toString('hex'); expect(encrypted).toMatchInlineSnapshot( - `"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008d460c0e434d846ec1ea286e4090eb56376ff27bddc1aacae1d856549f701fa77e4f33ba2f47fdac6370f13bc5f16bbae857bbe6ab3ee4ea2a339192eef22a47ce0df4426fc314cb6294ccf291b79c1d8d362cdcc223e51020ccd3318e7052ca74f1fe922ad914bd46e4b6abcd681b63ab1c5bf4151e82f00548ae7c61c59df8cccb8cabb59882a9b32934ad2d2bc60198489ef90b2909a0304e7b84cb8cd70d16c958ff8b9a4c143f867d6cefd03f3b21758be1b80040991583cc6f29541790def5c80cea0b300add14fc267a28f942f8c5c6d14f143b42c5d7101291e4ef7c51436731c43ae4c340c7f3b870ad1dc4d74dd9555295714cc95d5f94255fdee9d29601b61c843b949c8124e637c79524cd67d43c978d0a97de97b42b5b94c96ea50aee2086eb63d8c8b61f169c12d1deacefc1d456633e46b62daff15bcab3e1630196e802fc14533184a25d74d45747d33a9fa328fd1f03c0300ec95018879acf3a8c801d65cfbdb6bf47d240ac83532ee813d8b76cea11683c71e791c39d18"`, + `"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008d460c0e434d846ec1ea286e4090eb56376ff27bddc1aacae1d856549f701fa77e4f33ba2f47fdac6370f13bc5f16bbae857bbe6ab3ee4ea2a339192eef22a47ce0df4426fc314cb6294ccf291b79c1d8d362cdcc223e51020ccd3318e7052ca74f1fe922ad914bd46e4b6abcd681b63ab1c5bf4151e82f00548ae7c61c59df8c117c14c2e8d9046d32d43a7da818c68be296ef9d1446a87a450eb3f6550200d2663915b0bad97e7f7419975e5a740efb67eeb5304a90808a004ebfc156054a1459191d7fea175f6c64159b3c25a13790cca7250c30e3c80698e64565a6c9ddb16ac1479c3199fec02464b2a252202119514b02012cc387579220f03587b40444ae93f3b83dec2c0a76ed90a804981accd67d43c978d0a97de97b42b5b94c96ea50aee2086eb63d8c8b61f169c12d1deacefc1d456633e46b62daff15bcab3e1630196e802fc14533184a25d74d45747d33a9fa328fd1f03c0300ec95018879acf3a8c801d65cfbdb6bf47d240ac83532ee813d8b76cea11683c71e791c39d18"`, ); const byteArrayString = `[${encrypted.match(/.{1,2}/g)!.map(byte => parseInt(byte, 16))}]`; @@ -126,7 +126,7 @@ describe('L1 Event Payload', () => { beforeAll(() => { contractAddress = AztecAddress.random(); randomness = Fr.random(); - maskedContractAddress = pedersenHash([contractAddress, randomness], 0); + maskedContractAddress = poseidon2HashWithSeparator([contractAddress, randomness], 0); const payload = new L1EventPayload(Event.random(), contractAddress, randomness, EventSelector.random()); diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index d6004352663..03852b5c8d1 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -110,13 +110,12 @@ export const L2_GAS_PER_LOG_BYTE = 4; export const L2_GAS_PER_NOTE_HASH = 32; export const L2_GAS_PER_NULLIFIER = 64; export const CANONICAL_KEY_REGISTRY_ADDRESS = - 2153455745675440165069577621832684870696142028027528497509357256345838682961n; + 1846248480517165521743643626257274710444505994181338106189373716137867887031n; export const CANONICAL_AUTH_REGISTRY_ADDRESS = - 18091885756106795278141309801070173692350235742979924147720536894670507925831n; -export const DEPLOYER_CONTRACT_ADDRESS = 19511485909966796736993840362353440247573331327062358513665772226446629198132n; -export const REGISTERER_CONTRACT_ADDRESS = - 13402924717071282069537366635406026232165444473509746327951838324587448220160n; -export const GAS_TOKEN_ADDRESS = 3159976153131520272419617514531889581796079438158800470341967144801191524489n; + 291851909807592677788453151491906806151300647123080163180507453297558628774n; +export const DEPLOYER_CONTRACT_ADDRESS = 9256947041321027089533495832830405543710101516429552788062967841445602134030n; +export const REGISTERER_CONTRACT_ADDRESS = 867409746588255642605883457564767101821478729272763062990600291025697803994n; +export const GAS_TOKEN_ADDRESS = 8777298866013239306861859762114222884687709421566494727011568767822269644915n; export const AZTEC_ADDRESS_LENGTH = 1; export const GAS_FEES_LENGTH = 2; export const GAS_LENGTH = 2; diff --git a/yarn-project/circuits.js/src/contract/__snapshots__/contract_address.test.ts.snap b/yarn-project/circuits.js/src/contract/__snapshots__/contract_address.test.ts.snap index 43efc1e2aea..b0374a11e52 100644 --- a/yarn-project/circuits.js/src/contract/__snapshots__/contract_address.test.ts.snap +++ b/yarn-project/circuits.js/src/contract/__snapshots__/contract_address.test.ts.snap @@ -1,9 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ContractAddress computeContractAddressFromInstance 1`] = `"0x1e7ab8ea46fac7865205e7b5f13761e96a789fda67cdd17c46fb1d259c706902"`; +exports[`ContractAddress computeContractAddressFromInstance 1`] = `"0x0ea56faa48431d99cc2d073463d1b718c11174bb551a3d1d6f296b0096089dbb"`; -exports[`ContractAddress computeInitializationHash 1`] = `Fr<0x2993633b581934f500950764c5be63dde8888791cdaf6b02dbc0f5c31460ca57>`; +exports[`ContractAddress computeInitializationHash 1`] = `Fr<0x2f11768c825fac132c632372d7c6d657fd471a9f9db05a153c6927a24863ec53>`; -exports[`ContractAddress computePartialAddress 1`] = `Fr<0x1923a6246e305720b6aaf751fde0342613e93c82e455c3831e28375c16dd40d8>`; +exports[`ContractAddress computePartialAddress 1`] = `Fr<0x2521255ebd14e8e3e7cd1e8a27d26a902ee9e74905b711950d580e826ba9010d>`; -exports[`ContractAddress computeSaltedInitializationHash 1`] = `Fr<0x15cf30c8f37df5115e0cafbccce8f46a86e5e76487d7d9be48e0fd641c46e77c>`; +exports[`ContractAddress computeSaltedInitializationHash 1`] = `Fr<0x09be38c1a3215e297a222cdf6eae495b509054675826f0976d8db5dde7644885>`; diff --git a/yarn-project/circuits.js/src/contract/__snapshots__/private_function.test.ts.snap b/yarn-project/circuits.js/src/contract/__snapshots__/private_function.test.ts.snap index bdda9d94b62..427bc327baf 100644 Binary files a/yarn-project/circuits.js/src/contract/__snapshots__/private_function.test.ts.snap and b/yarn-project/circuits.js/src/contract/__snapshots__/private_function.test.ts.snap differ diff --git a/yarn-project/circuits.js/src/contract/contract_address.ts b/yarn-project/circuits.js/src/contract/contract_address.ts index 353e3737d90..348b1a2c44b 100644 --- a/yarn-project/circuits.js/src/contract/contract_address.ts +++ b/yarn-project/circuits.js/src/contract/contract_address.ts @@ -1,6 +1,6 @@ import { type FunctionAbi, FunctionSelector, encodeArguments } from '@aztec/foundation/abi'; import { type AztecAddress } from '@aztec/foundation/aztec-address'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { type ContractInstance } from '@aztec/types/contracts'; @@ -43,7 +43,10 @@ export function computePartialAddress( ? instance.saltedInitializationHash : computeSaltedInitializationHash(instance); - return pedersenHash([instance.contractClassId, saltedInitializationHash], GeneratorIndex.PARTIAL_ADDRESS); + return poseidon2HashWithSeparator( + [instance.contractClassId, saltedInitializationHash], + GeneratorIndex.PARTIAL_ADDRESS, + ); } /** @@ -53,7 +56,10 @@ export function computePartialAddress( export function computeSaltedInitializationHash( instance: Pick, ): Fr { - return pedersenHash([instance.salt, instance.initializationHash, instance.deployer], GeneratorIndex.PARTIAL_ADDRESS); + return poseidon2HashWithSeparator( + [instance.salt, instance.initializationHash, instance.deployer], + GeneratorIndex.PARTIAL_ADDRESS, + ); } /** @@ -79,5 +85,5 @@ export function computeInitializationHash(initFn: FunctionAbi | undefined, args: */ export function computeInitializationHashFromEncodedArgs(initFn: FunctionSelector, encodedArgs: Fr[]): Fr { const argsHash = computeVarArgsHash(encodedArgs); - return pedersenHash([initFn, argsHash], GeneratorIndex.CONSTRUCTOR); + return poseidon2HashWithSeparator([initFn, argsHash], GeneratorIndex.CONSTRUCTOR); } diff --git a/yarn-project/circuits.js/src/contract/contract_class_id.test.ts b/yarn-project/circuits.js/src/contract/contract_class_id.test.ts index a0b1e64a421..a0d2e6c5404 100644 --- a/yarn-project/circuits.js/src/contract/contract_class_id.test.ts +++ b/yarn-project/circuits.js/src/contract/contract_class_id.test.ts @@ -25,7 +25,7 @@ describe('ContractClass', () => { }; expect(computeContractClassId(contractClass).toString()).toMatchInlineSnapshot( - `"0x0fd34f4f2d6d6a7fc61d8fb8e0c9a411354856fa86c568e4c9e0935b367dc69d"`, + `"0x2141a9b669d307683e59732203f0b632adb296a0782028eae672fa6f5f44a0dc"`, ); }); }); diff --git a/yarn-project/circuits.js/src/contract/contract_class_id.ts b/yarn-project/circuits.js/src/contract/contract_class_id.ts index 89f4081ae8c..c2ad0f75e93 100644 --- a/yarn-project/circuits.js/src/contract/contract_class_id.ts +++ b/yarn-project/circuits.js/src/contract/contract_class_id.ts @@ -1,4 +1,4 @@ -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { type ContractClass } from '@aztec/types/contracts'; @@ -35,7 +35,7 @@ export function computeContractClassIdWithPreimage( 'publicBytecodeCommitment' in contractClass ? contractClass.publicBytecodeCommitment : computePublicBytecodeCommitment(contractClass.packedBytecode); - const id = pedersenHash( + const id = poseidon2HashWithSeparator( [artifactHash, privateFunctionsRoot, publicBytecodeCommitment], GeneratorIndex.CONTRACT_LEAF, // TODO(@spalladino): Review all generator indices in this file ); diff --git a/yarn-project/circuits.js/src/contract/private_function.ts b/yarn-project/circuits.js/src/contract/private_function.ts index b0395155e1c..60315ce47b8 100644 --- a/yarn-project/circuits.js/src/contract/private_function.ts +++ b/yarn-project/circuits.js/src/contract/private_function.ts @@ -1,4 +1,4 @@ -import { pedersenHash } from '@aztec/foundation/crypto'; +import { pedersenHash, poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { type PrivateFunction } from '@aztec/types/contracts'; @@ -27,7 +27,7 @@ function computePrivateFunctionLeaves(fns: PrivateFunction[]): Buffer[] { /** Returns the leaf for a given private function. */ export function computePrivateFunctionLeaf(fn: PrivateFunction): Buffer { - return pedersenHash([fn.selector, fn.vkHash], GeneratorIndex.FUNCTION_LEAF).toBuffer(); + return poseidon2HashWithSeparator([fn.selector, fn.vkHash], GeneratorIndex.FUNCTION_LEAF).toBuffer(); } function getPrivateFunctionTreeCalculator(): MerkleTreeCalculator { diff --git a/yarn-project/circuits.js/src/hash/__snapshots__/hash.test.ts.snap b/yarn-project/circuits.js/src/hash/__snapshots__/hash.test.ts.snap index 5276911cb3b..4f49be9f7aa 100644 --- a/yarn-project/circuits.js/src/hash/__snapshots__/hash.test.ts.snap +++ b/yarn-project/circuits.js/src/hash/__snapshots__/hash.test.ts.snap @@ -2,19 +2,19 @@ exports[`hash Var args hash matches noir 1`] = `Fr<0x1cce4dbf69f14c44865919991ee1057922e34d7310ba237d71759aa422621ca9>`; -exports[`hash compute secret message hash 1`] = `Fr<0x0dc06f2167e2cd19adf738d1f38469d7f8bff1e26b029816e8230bcd6ab6332e>`; +exports[`hash compute secret message hash 1`] = `Fr<0x211b950e538ee911389e441942d6646d13d725957a49d06500ae9bb673b0fbc2>`; -exports[`hash computes note hash nonce 1`] = `Fr<0x10ebab01bc813263ef92ed71b9c781ad3ef58019b66a8f71304d2f72d7defe4d>`; +exports[`hash computes note hash nonce 1`] = `Fr<0x24cbf5ece05503c37381b5d7dfcaf96fe2aca3749cb1a5d4d2f5264e40872fa2>`; -exports[`hash computes public data tree leaf slot 1`] = `Fr<0x14114ab3dbdd0a1ccc5c4fe68dd576f3c6cd79708770e06ab4086398cdd828f4>`; +exports[`hash computes public data tree leaf slot 1`] = `Fr<0x13c520847ef2069f11086e5085b756d5e03931879b7e6a63eca639e4b5ad4a4a>`; exports[`hash computes public data tree value 1`] = `Fr<0x0000000000000000000000000000000000000000000000000000000000000003>`; -exports[`hash computes siloed note hash 1`] = `Fr<0x100e57c07ab6db86f4ae43f5a7d4355c57c5a1e2523746e0fb16ac29f0dc3bbb>`; +exports[`hash computes siloed note hash 1`] = `Fr<0x12ddf0068d9dba68cb857f9b431064c0c04c06fad060b9df25894ccc4a790066>`; -exports[`hash computes siloed nullifier 1`] = `Fr<0x1743145fde103eaa88af576e0562e61d85eba590fddf01d19550e4f024709373>`; +exports[`hash computes siloed nullifier 1`] = `Fr<0x280270c4a9431f6d4f029f5cd77807c5d797dab9e83181a47a9082ae2c5a3149>`; -exports[`hash computes unique note hash 1`] = `Fr<0x1cbdcecec4fe92f6638eb6a8dade96ca358ecba4954cf597c363199fae3d47e8>`; +exports[`hash computes unique note hash 1`] = `Fr<0x2f9b80d22188c5383a577596538f71f9713dc220bf36b6497ec16ea0f9df2282>`; exports[`hash hashes empty function args 1`] = `Fr<0x0000000000000000000000000000000000000000000000000000000000000000>`; diff --git a/yarn-project/circuits.js/src/hash/hash.ts b/yarn-project/circuits.js/src/hash/hash.ts index 60509797f1a..0c6755adbe9 100644 --- a/yarn-project/circuits.js/src/hash/hash.ts +++ b/yarn-project/circuits.js/src/hash/hash.ts @@ -1,6 +1,6 @@ import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { padArrayEnd } from '@aztec/foundation/collection'; -import { pedersenHash, pedersenHashBuffer, poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; +import { pedersenHashBuffer, poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { numToUInt8, numToUInt16BE, numToUInt32BE } from '@aztec/foundation/serialize'; @@ -37,7 +37,7 @@ export function hashVK(vkBuf: Buffer) { * @returns A note hash nonce. */ export function computeNoteHashNonce(nullifierZero: Fr, noteHashIndex: number): Fr { - return pedersenHash([nullifierZero, noteHashIndex], GeneratorIndex.NOTE_HASH_NONCE); + return poseidon2HashWithSeparator([nullifierZero, noteHashIndex], GeneratorIndex.NOTE_HASH_NONCE); } /** @@ -48,7 +48,7 @@ export function computeNoteHashNonce(nullifierZero: Fr, noteHashIndex: number): * @returns A siloed note hash. */ export function siloNoteHash(contract: AztecAddress, uniqueNoteHash: Fr): Fr { - return pedersenHash([contract, uniqueNoteHash], GeneratorIndex.SILOED_NOTE_HASH); + return poseidon2HashWithSeparator([contract, uniqueNoteHash], GeneratorIndex.SILOED_NOTE_HASH); } /** @@ -59,7 +59,7 @@ export function siloNoteHash(contract: AztecAddress, uniqueNoteHash: Fr): Fr { * @returns A unique note hash. */ export function computeUniqueNoteHash(nonce: Fr, slottedNoteHash: Fr): Fr { - return pedersenHash([nonce, slottedNoteHash], GeneratorIndex.UNIQUE_NOTE_HASH); + return poseidon2HashWithSeparator([nonce, slottedNoteHash], GeneratorIndex.UNIQUE_NOTE_HASH); } /** @@ -70,7 +70,7 @@ export function computeUniqueNoteHash(nonce: Fr, slottedNoteHash: Fr): Fr { * @returns A siloed nullifier. */ export function siloNullifier(contract: AztecAddress, innerNullifier: Fr): Fr { - return pedersenHash([contract, innerNullifier], GeneratorIndex.OUTER_NULLIFIER); + return poseidon2HashWithSeparator([contract, innerNullifier], GeneratorIndex.OUTER_NULLIFIER); } /** @@ -91,7 +91,7 @@ export function computePublicDataTreeValue(value: Fr): Fr { */ export function computePublicDataTreeLeafSlot(contractAddress: AztecAddress, storageSlot: Fr): Fr { - return pedersenHash([contractAddress, storageSlot], GeneratorIndex.PUBLIC_LEAF_INDEX); + return poseidon2HashWithSeparator([contractAddress, storageSlot], GeneratorIndex.PUBLIC_LEAF_INDEX); } /** @@ -128,7 +128,7 @@ export function computeVarArgsHash(args: Fr[]) { * @returns The hash */ export function computeSecretHash(secret: Fr) { - return pedersenHash([secret], GeneratorIndex.SECRET_HASH); + return poseidon2HashWithSeparator([secret], GeneratorIndex.SECRET_HASH); } export function computeL1ToL2MessageNullifier( @@ -137,6 +137,9 @@ export function computeL1ToL2MessageNullifier( secret: Fr, messageIndex: bigint, ) { - const innerMessageNullifier = pedersenHash([messageHash, secret, messageIndex], GeneratorIndex.MESSAGE_NULLIFIER); + const innerMessageNullifier = poseidon2HashWithSeparator( + [messageHash, secret, messageIndex], + GeneratorIndex.MESSAGE_NULLIFIER, + ); return siloNullifier(contract, innerMessageNullifier); } diff --git a/yarn-project/circuits.js/src/keys/__snapshots__/derivation.test.ts.snap b/yarn-project/circuits.js/src/keys/__snapshots__/derivation.test.ts.snap index 1ec1734aed8..54555005a5c 100644 --- a/yarn-project/circuits.js/src/keys/__snapshots__/derivation.test.ts.snap +++ b/yarn-project/circuits.js/src/keys/__snapshots__/derivation.test.ts.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`🔑 Address from partial matches Noir 1`] = `"0x1b6ead051e7b42665064ca6cf1ec77da0a36d86e00d1ff6e44077966c0c3a9fa"`; +exports[`🔑 Address from partial matches Noir 1`] = `"0x23ce9be3fa3c846b0f9245cc796902e731d04f086e8a42473bb29e405fc98075"`; diff --git a/yarn-project/circuits.js/src/keys/derivation.test.ts b/yarn-project/circuits.js/src/keys/derivation.test.ts index 0db0816a4d7..d4999149c5a 100644 --- a/yarn-project/circuits.js/src/keys/derivation.test.ts +++ b/yarn-project/circuits.js/src/keys/derivation.test.ts @@ -11,7 +11,7 @@ describe('🔑', () => { const masterOutgoingViewingPublicKey = new Point(new Fr(5), new Fr(6), false); const masterTaggingPublicKey = new Point(new Fr(7), new Fr(8), false); - const expected = Fr.fromString('0x146f68c0e0ba4067d61a3304bbfdec0797d5df1357db6c01247c48bfb345c7d7'); + const expected = Fr.fromString('0x0fecd9a32db731fec1fded1b9ff957a1625c069245a3613a2538bd527068b0ad'); expect( new PublicKeys( masterNullifierPublicKey, diff --git a/yarn-project/circuits.js/src/keys/derivation.ts b/yarn-project/circuits.js/src/keys/derivation.ts index a0d41dbd2f9..c8eb037c167 100644 --- a/yarn-project/circuits.js/src/keys/derivation.ts +++ b/yarn-project/circuits.js/src/keys/derivation.ts @@ -1,5 +1,5 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { poseidon2Hash, sha512ToGrumpkinScalar } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator, sha512ToGrumpkinScalar } from '@aztec/foundation/crypto'; import { type Fq, type Fr, GrumpkinScalar } from '@aztec/foundation/fields'; import { Grumpkin } from '../barretenberg/crypto/grumpkin/index.js'; @@ -14,7 +14,7 @@ export function computeAppNullifierSecretKey(masterNullifierSecretKey: GrumpkinS export function computeAppSecretKey(skM: GrumpkinScalar, app: AztecAddress, keyPrefix: KeyPrefix): Fr { const generator = getKeyGenerator(keyPrefix); - return poseidon2Hash([skM.hi, skM.lo, app, generator]); + return poseidon2HashWithSeparator([skM.hi, skM.lo, app], generator); } export function computeOvskApp(ovsk: GrumpkinScalar, app: AztecAddress) { @@ -42,7 +42,7 @@ export function deriveSigningKey(secretKey: Fr): GrumpkinScalar { } export function computeAddress(publicKeysHash: Fr, partialAddress: Fr) { - const addressFr = poseidon2Hash([publicKeysHash, partialAddress, GeneratorIndex.CONTRACT_ADDRESS_V1]); + const addressFr = poseidon2HashWithSeparator([publicKeysHash, partialAddress], GeneratorIndex.CONTRACT_ADDRESS_V1); return AztecAddress.fromField(addressFr); } diff --git a/yarn-project/circuits.js/src/structs/__snapshots__/function_data.test.ts.snap b/yarn-project/circuits.js/src/structs/__snapshots__/function_data.test.ts.snap index db45ccb85d2..3415c7cc5f9 100644 --- a/yarn-project/circuits.js/src/structs/__snapshots__/function_data.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/__snapshots__/function_data.test.ts.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`FunctionData computes empty function data hash 1`] = `Fr<0x27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed>`; +exports[`FunctionData computes empty function data hash 1`] = `Fr<0x2ee7682681179c2d8290a805cdeb64cc9744167fd5c801c26f1b3f9757c4eebc>`; diff --git a/yarn-project/circuits.js/src/structs/__snapshots__/header.test.ts.snap b/yarn-project/circuits.js/src/structs/__snapshots__/header.test.ts.snap index 22d8403faf2..b8d2132567f 100644 --- a/yarn-project/circuits.js/src/structs/__snapshots__/header.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/__snapshots__/header.test.ts.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Header computes empty hash 1`] = `Fr<0x2080fad33d703007c3c08f3c0b17cda1550e9d706cb4fdb031f2312d8a50fa8b>`; +exports[`Header computes empty hash 1`] = `Fr<0x1c97ed6fbc35f8b400d31bd38ce5cc938921e0cf2e20159d316f8c7011f9f42c>`; -exports[`Header computes hash 1`] = `Fr<0x01b9c2faee2c7abac8d4284144088ab558c70bcc38d4da90f332d5f2bc2ee502>`; +exports[`Header computes hash 1`] = `Fr<0x305c2bb392f94210b9505dda720c1295cc625634c30f47f2798ccac9985d016e>`; diff --git a/yarn-project/circuits.js/src/structs/__snapshots__/private_call_stack_item.test.ts.snap b/yarn-project/circuits.js/src/structs/__snapshots__/private_call_stack_item.test.ts.snap index 14aa1af6992..23d4b2c253a 100644 --- a/yarn-project/circuits.js/src/structs/__snapshots__/private_call_stack_item.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/__snapshots__/private_call_stack_item.test.ts.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`PrivateCallStackItem computes empty item hash 1`] = `Fr<0x2418613f5080d6d2aa82928b92acbb84f738d69c93635837e379f88fdcc19688>`; +exports[`PrivateCallStackItem computes empty item hash 1`] = `Fr<0x2a254c3fa6968b59e98b456f4353671a4923a4c8280fb6e142ef0071b95466be>`; -exports[`PrivateCallStackItem computes hash 1`] = `Fr<0x0a1e1b5439724b4633aa7c77bb4356455538bfa1b3e34e4b64d7175ca9445c75>`; +exports[`PrivateCallStackItem computes hash 1`] = `Fr<0x03a10b50b4bd17b3bd095a366f4c6cef06ddfed4f67e1e56ba31fda1beb8dd46>`; diff --git a/yarn-project/circuits.js/src/structs/__snapshots__/private_circuit_public_inputs.test.ts.snap b/yarn-project/circuits.js/src/structs/__snapshots__/private_circuit_public_inputs.test.ts.snap index 872eb591c59..fc0e4b83928 100644 --- a/yarn-project/circuits.js/src/structs/__snapshots__/private_circuit_public_inputs.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/__snapshots__/private_circuit_public_inputs.test.ts.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`PrivateCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x0104a7f82b1f6346a5ba95eafd44f2f851097d8abd793d8b16e8744d11a76d03>`; +exports[`PrivateCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x29f35524edb1bed6c1eded107142d65ca80f46656c1c7ded71c46dbda14feec5>`; -exports[`PrivateCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x2fa23731091249167ce178a14a59bfd4331d9c60cd2df7bae53d815e650eb1e0>`; +exports[`PrivateCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x24e806a499332876eebde0557bc01501999ddf645df63c822b10ebba6a2c7665>`; diff --git a/yarn-project/circuits.js/src/structs/__snapshots__/public_circuit_public_inputs.test.ts.snap b/yarn-project/circuits.js/src/structs/__snapshots__/public_circuit_public_inputs.test.ts.snap index c252ef5f068..3ed1233a0dc 100644 --- a/yarn-project/circuits.js/src/structs/__snapshots__/public_circuit_public_inputs.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/__snapshots__/public_circuit_public_inputs.test.ts.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`PublicCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x21be4398b9e455b4afd91304dcc40210c2f94477d5f58b32f79fd21bf9008618>`; +exports[`PublicCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x0ce92e52cdf4f36c4734556eca0cc66f264ac7548ab7556227bca067fc7b5e84>`; -exports[`PublicCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x07f9c71661a38b2c59d29faf585ee7d31b1ab0e0dab7ddb6c4b252123f8c27f1>`; +exports[`PublicCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x006addc726c9ad5a6339456a1345cefb4124c338651ff0dd4c7d50265ea34a2c>`; diff --git a/yarn-project/circuits.js/src/structs/__snapshots__/tx_context.test.ts.snap b/yarn-project/circuits.js/src/structs/__snapshots__/tx_context.test.ts.snap index 6a46b379e5b..944fc3a7610 100644 --- a/yarn-project/circuits.js/src/structs/__snapshots__/tx_context.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/__snapshots__/tx_context.test.ts.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`TxContext computes empty context hash 1`] = `Fr<0x17e4357684c5a4349b4587c95b0b6161dcb4a3c5b02d4eb2ecc3b02c80193261>`; +exports[`TxContext computes empty context hash 1`] = `Fr<0x0b81be18198d45a61eba2c59db95ebdac35d57c9d8ab524e52f0f39417aba5fe>`; diff --git a/yarn-project/circuits.js/src/structs/__snapshots__/tx_request.test.ts.snap b/yarn-project/circuits.js/src/structs/__snapshots__/tx_request.test.ts.snap index fbadc0a1a84..cb781f1df87 100644 --- a/yarn-project/circuits.js/src/structs/__snapshots__/tx_request.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/__snapshots__/tx_request.test.ts.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`TxRequest compute hash 1`] = `"0x0d982a1c7a65919b2bcacbf5660f5b861132072a8190d97c82b1591da402f5ea"`; +exports[`TxRequest compute hash 1`] = `"0x289d3f85f463f3449e2204433b860574d351e9fbd97a01a722239fdd9ce3ce9b"`; diff --git a/yarn-project/circuits.js/src/structs/call_context.ts b/yarn-project/circuits.js/src/structs/call_context.ts index 790c2cfdaf0..e8212315ecd 100644 --- a/yarn-project/circuits.js/src/structs/call_context.ts +++ b/yarn-project/circuits.js/src/structs/call_context.ts @@ -1,6 +1,6 @@ import { FunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { type Fr } from '@aztec/foundation/fields'; import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; @@ -124,6 +124,6 @@ export class CallContext { } hash(): Fr { - return pedersenHash(this.toFields(), GeneratorIndex.CALL_CONTEXT); + return poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.CALL_CONTEXT); } } diff --git a/yarn-project/circuits.js/src/structs/complete_address.test.ts b/yarn-project/circuits.js/src/structs/complete_address.test.ts index e38634c0759..50a7b071c9f 100644 --- a/yarn-project/circuits.js/src/structs/complete_address.test.ts +++ b/yarn-project/circuits.js/src/structs/complete_address.test.ts @@ -38,11 +38,11 @@ describe('CompleteAddress', () => { // docs:start:instantiate-complete-address // Typically a recipient would share their complete address with the sender const completeAddressFromString = CompleteAddress.fromString( - '0x1b554ab89034d16274f0043eb2d4d1104f3d6e2b995a9b8f492dfcd881b8469522f7fcddfa3ce3e8f0cc8e82d7b94cdd740afa3e77f8e4a63ea78a239432dcab0471657de2b6216ade6c506d28fbc22ba8b8ed95c871ad9f3e3984e90d9723a7111223493147f6785514b1c195bb37a2589f22a6596d30bb2bb145fdc9ca8f1e273bbffd678edce8fe30e0deafc4f66d58357c06fd4a820285294b9746c3be9509115c96e962322ffed6522f57194627136b8d03ac7469109707f5e44190c4840c49773308a13d740a7f0d4f0e6163b02c5a408b6f965856b6a491002d073d5b00d3d81beb009873eb7116327cf47c612d5758ef083d4fda78e9b63980b2a7622f567d22d2b02fe1f4ad42db9d58a36afd1983e7e2909d1cab61cafedad6193a0a7c585381b10f4666044266a02405bf6e01fa564c8517d4ad5823493abd31de', + '0x23d95e303879a5d0bbef78ecbc335e559da37431f6dcd11da54ed375c284681322f7fcddfa3ce3e8f0cc8e82d7b94cdd740afa3e77f8e4a63ea78a239432dcab0471657de2b6216ade6c506d28fbc22ba8b8ed95c871ad9f3e3984e90d9723a7111223493147f6785514b1c195bb37a2589f22a6596d30bb2bb145fdc9ca8f1e273bbffd678edce8fe30e0deafc4f66d58357c06fd4a820285294b9746c3be9509115c96e962322ffed6522f57194627136b8d03ac7469109707f5e44190c4840c49773308a13d740a7f0d4f0e6163b02c5a408b6f965856b6a491002d073d5b00d3d81beb009873eb7116327cf47c612d5758ef083d4fda78e9b63980b2a7622f567d22d2b02fe1f4ad42db9d58a36afd1983e7e2909d1cab61cafedad6193a0a7c585381b10f4666044266a02405bf6e01fa564c8517d4ad5823493abd31de', ); // Alternatively, a recipient could share the individual components with the sender - const address = Fr.fromString('0x1b554ab89034d16274f0043eb2d4d1104f3d6e2b995a9b8f492dfcd881b84695'); + const address = Fr.fromString('0x23d95e303879a5d0bbef78ecbc335e559da37431f6dcd11da54ed375c2846813'); const npkM = Point.fromString( '0x22f7fcddfa3ce3e8f0cc8e82d7b94cdd740afa3e77f8e4a63ea78a239432dcab0471657de2b6216ade6c506d28fbc22ba8b8ed95c871ad9f3e3984e90d9723a7', ); diff --git a/yarn-project/circuits.js/src/structs/function_data.ts b/yarn-project/circuits.js/src/structs/function_data.ts index 490636695cf..37429cb4525 100644 --- a/yarn-project/circuits.js/src/structs/function_data.ts +++ b/yarn-project/circuits.js/src/structs/function_data.ts @@ -1,5 +1,5 @@ import { type FunctionAbi, FunctionSelector, FunctionType } from '@aztec/foundation/abi'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize'; @@ -91,6 +91,6 @@ export class FunctionData { } hash(): Fr { - return pedersenHash(this.toFields(), GeneratorIndex.FUNCTION_DATA); + return poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.FUNCTION_DATA); } } diff --git a/yarn-project/circuits.js/src/structs/header.ts b/yarn-project/circuits.js/src/structs/header.ts index b8c1b26293d..dbdb0988198 100644 --- a/yarn-project/circuits.js/src/structs/header.ts +++ b/yarn-project/circuits.js/src/structs/header.ts @@ -1,4 +1,4 @@ -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; @@ -123,6 +123,6 @@ export class Header { } hash(): Fr { - return pedersenHash(this.toFields(), GeneratorIndex.BLOCK_HASH); + return poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.BLOCK_HASH); } } diff --git a/yarn-project/circuits.js/src/structs/private_call_stack_item.ts b/yarn-project/circuits.js/src/structs/private_call_stack_item.ts index bfce7897770..5770f287823 100644 --- a/yarn-project/circuits.js/src/structs/private_call_stack_item.ts +++ b/yarn-project/circuits.js/src/structs/private_call_stack_item.ts @@ -1,5 +1,5 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { type Fr } from '@aztec/foundation/fields'; import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; @@ -89,6 +89,6 @@ export class PrivateCallStackItem { * @returns Hash. */ public hash(): Fr { - return pedersenHash(this.toFields(), GeneratorIndex.CALL_STACK_ITEM); + return poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.CALL_STACK_ITEM); } } diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index 9a1503f630e..12d0f5e8218 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -1,5 +1,5 @@ import { makeTuple } from '@aztec/foundation/array'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, @@ -324,6 +324,6 @@ export class PrivateCircuitPublicInputs { } hash(): Fr { - return pedersenHash(this.toFields(), GeneratorIndex.PRIVATE_CIRCUIT_PUBLIC_INPUTS); + return poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.PRIVATE_CIRCUIT_PUBLIC_INPUTS); } } diff --git a/yarn-project/circuits.js/src/structs/public_call_stack_item_compressed.ts b/yarn-project/circuits.js/src/structs/public_call_stack_item_compressed.ts index 4fa46ed9fca..a4dbb107bc8 100644 --- a/yarn-project/circuits.js/src/structs/public_call_stack_item_compressed.ts +++ b/yarn-project/circuits.js/src/structs/public_call_stack_item_compressed.ts @@ -1,5 +1,5 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; @@ -116,6 +116,6 @@ export class PublicCallStackItemCompressed { * @returns Hash. */ public hash() { - return pedersenHash(this.toFields(), GeneratorIndex.CALL_STACK_ITEM); + return poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.CALL_STACK_ITEM); } } diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index a4c94c07aa8..86ef8e72928 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -1,6 +1,6 @@ import { makeTuple } from '@aztec/foundation/array'; import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, @@ -328,6 +328,6 @@ export class PublicCircuitPublicInputs { } hash(): Fr { - return pedersenHash(this.toFields(), GeneratorIndex.PUBLIC_CIRCUIT_PUBLIC_INPUTS); + return poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.PUBLIC_CIRCUIT_PUBLIC_INPUTS); } } diff --git a/yarn-project/circuits.js/src/structs/tx_context.ts b/yarn-project/circuits.js/src/structs/tx_context.ts index 32ca812373e..8210f20c96a 100644 --- a/yarn-project/circuits.js/src/structs/tx_context.ts +++ b/yarn-project/circuits.js/src/structs/tx_context.ts @@ -1,4 +1,4 @@ -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; @@ -91,6 +91,6 @@ export class TxContext { } hash(): Fr { - return pedersenHash(this.toFields(), GeneratorIndex.TX_CONTEXT); + return poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.TX_CONTEXT); } } diff --git a/yarn-project/circuits.js/src/structs/tx_request.ts b/yarn-project/circuits.js/src/structs/tx_request.ts index 53e30e9e843..7666cb8bada 100644 --- a/yarn-project/circuits.js/src/structs/tx_request.ts +++ b/yarn-project/circuits.js/src/structs/tx_request.ts @@ -1,5 +1,5 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; @@ -63,7 +63,7 @@ export class TxRequest { } hash() { - return pedersenHash(this.toFields(), GeneratorIndex.TX_REQUEST); + return poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.TX_REQUEST); } static empty() { diff --git a/yarn-project/circuits.js/src/types/public_keys.test.ts b/yarn-project/circuits.js/src/types/public_keys.test.ts index 73d6003c11b..51902c7cc1e 100644 --- a/yarn-project/circuits.js/src/types/public_keys.test.ts +++ b/yarn-project/circuits.js/src/types/public_keys.test.ts @@ -13,7 +13,7 @@ describe('PublicKeys', () => { ); const hash = keys.hash().toString(); - expect(hash).toMatchInlineSnapshot(`"0x146f68c0e0ba4067d61a3304bbfdec0797d5df1357db6c01247c48bfb345c7d7"`); + expect(hash).toMatchInlineSnapshot(`"0x0fecd9a32db731fec1fded1b9ff957a1625c069245a3613a2538bd527068b0ad"`); // Run with AZTEC_GENERATE_TEST_DATA=1 to update noir test data updateInlineTestData('noir-projects/aztec-nr/aztec/src/keys/public_keys.nr', 'expected_public_keys_hash', hash); diff --git a/yarn-project/circuits.js/src/types/public_keys.ts b/yarn-project/circuits.js/src/types/public_keys.ts index 3b30b9d8064..1e73fdba099 100644 --- a/yarn-project/circuits.js/src/types/public_keys.ts +++ b/yarn-project/circuits.js/src/types/public_keys.ts @@ -1,4 +1,4 @@ -import { poseidon2Hash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr, Point } from '@aztec/foundation/fields'; import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize'; @@ -21,13 +21,15 @@ export class PublicKeys { hash() { return this.isEmpty() ? Fr.ZERO - : poseidon2Hash([ - this.masterNullifierPublicKey, - this.masterIncomingViewingPublicKey, - this.masterOutgoingViewingPublicKey, - this.masterTaggingPublicKey, + : poseidon2HashWithSeparator( + [ + this.masterNullifierPublicKey, + this.masterIncomingViewingPublicKey, + this.masterOutgoingViewingPublicKey, + this.masterTaggingPublicKey, + ], GeneratorIndex.PUBLIC_KEYS_HASH, - ]); + ); } isEmpty() { diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index b1773d71856..d88811cdb8d 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -12,7 +12,7 @@ import { deriveKeys, } from '@aztec/aztec.js'; import { times } from '@aztec/foundation/collection'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { StatefulTestContractArtifact } from '@aztec/noir-contracts.js'; import { TestContract } from '@aztec/noir-contracts.js/Test'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; @@ -293,8 +293,12 @@ describe('e2e_block_building', () => { // compare logs expect(rct.status).toEqual('success'); const encryptedLogs = tx.encryptedLogs.unrollLogs(); - expect(encryptedLogs[0].maskedContractAddress).toEqual(pedersenHash([testContract.address, new Fr(5)], 0)); - expect(encryptedLogs[1].maskedContractAddress).toEqual(pedersenHash([testContract.address, new Fr(5)], 0)); + expect(encryptedLogs[0].maskedContractAddress).toEqual( + poseidon2HashWithSeparator([testContract.address, new Fr(5)], 0), + ); + expect(encryptedLogs[1].maskedContractAddress).toEqual( + poseidon2HashWithSeparator([testContract.address, new Fr(5)], 0), + ); // Setting randomness = 0 in app means 'do not mask the address' expect(encryptedLogs[2].maskedContractAddress).toEqual(testContract.address.toField()); const expectedEncryptedLogsHash = tx.encryptedLogs.hash(); diff --git a/yarn-project/end-to-end/src/e2e_keys.test.ts b/yarn-project/end-to-end/src/e2e_keys.test.ts index e485431c8ab..d01f5e1bdcb 100644 --- a/yarn-project/end-to-end/src/e2e_keys.test.ts +++ b/yarn-project/end-to-end/src/e2e_keys.test.ts @@ -18,7 +18,7 @@ import { derivePublicKeyFromSecretKey, } from '@aztec/circuits.js'; import { siloNullifier } from '@aztec/circuits.js/hash'; -import { poseidon2Hash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { TestContract } from '@aztec/noir-contracts.js'; import { jest } from '@jest/globals'; @@ -96,7 +96,7 @@ describe('Key Registry', () => { ); // 3. Derive all the possible nullifiers using nskApp const derivedNullifiers = noteHashes.map(noteHash => { - const innerNullifier = poseidon2Hash([noteHash, nskApp, GeneratorIndex.NOTE_NULLIFIER]); + const innerNullifier = poseidon2HashWithSeparator([noteHash, nskApp], GeneratorIndex.NOTE_NULLIFIER); return siloNullifier(contractAddress, innerNullifier); }); // 4. Count the number of derived nullifiers that are in the nullifiers array diff --git a/yarn-project/end-to-end/src/shared/browser.ts b/yarn-project/end-to-end/src/shared/browser.ts index e8a50937c57..abe5aa278e0 100644 --- a/yarn-project/end-to-end/src/shared/browser.ts +++ b/yarn-project/end-to-end/src/shared/browser.ts @@ -145,14 +145,14 @@ export const browserTestSuite = ( it('Can access CompleteAddress class in browser', async () => { const result: string = await page.evaluate(() => { const completeAddress = window.AztecJs.CompleteAddress.fromString( - '0x1b554ab89034d16274f0043eb2d4d1104f3d6e2b995a9b8f492dfcd881b8469522f7fcddfa3ce3e8f0cc8e82d7b94cdd740afa3e77f8e4a63ea78a239432dcab0471657de2b6216ade6c506d28fbc22ba8b8ed95c871ad9f3e3984e90d9723a7111223493147f6785514b1c195bb37a2589f22a6596d30bb2bb145fdc9ca8f1e273bbffd678edce8fe30e0deafc4f66d58357c06fd4a820285294b9746c3be9509115c96e962322ffed6522f57194627136b8d03ac7469109707f5e44190c4840c49773308a13d740a7f0d4f0e6163b02c5a408b6f965856b6a491002d073d5b00d3d81beb009873eb7116327cf47c612d5758ef083d4fda78e9b63980b2a7622f567d22d2b02fe1f4ad42db9d58a36afd1983e7e2909d1cab61cafedad6193a0a7c585381b10f4666044266a02405bf6e01fa564c8517d4ad5823493abd31de', + '0x05eb10b0bda78b5d8dc91de3d62bed7b55d73b5509521a9f8ef7269133e58a8c2c93b9572b35f9c9e07e9003ae1ca444442a165f927bce00e347dab57cc19391148730d0deec722eb6c54747df7345bc2ab3bd8e81f438b17b81ccabd9e6a3ac0708920251ccaf6664d769cbc47c8d767f64912639e13d9f9e441b225066161900c48a65eea83f1dbf217c43daf1be6ba9cefd2754f07e3cc13e81e5432e47f30dfb47c8b1e11368bec638fd9d22c696bf9c323a0fd09050745f4b7cf150bfa529a9f3062ee5f9d0a099ac53b4e1130653fb797ed2b59914a8915951d13ad8252521211957a854707af85ad40e9ab4d474a4fcbdcbe7a47866cae0db4fd86ed2261669d85a9cfbd09365a6db5d7acfe5560104a0cb893a375d6c08ffb9cbb8270be446a16361f271ac11899ee19f990c68035da18703ba00c8e9773dfe6a784a', ); // NOTE: browser does not know how to serialize CompleteAddress for return, so return a string // otherwise returning a CompleteAddress makes result undefined. return completeAddress.toString(); }); expect(result).toBe( - '0x1b554ab89034d16274f0043eb2d4d1104f3d6e2b995a9b8f492dfcd881b8469522f7fcddfa3ce3e8f0cc8e82d7b94cdd740afa3e77f8e4a63ea78a239432dcab0471657de2b6216ade6c506d28fbc22ba8b8ed95c871ad9f3e3984e90d9723a7111223493147f6785514b1c195bb37a2589f22a6596d30bb2bb145fdc9ca8f1e273bbffd678edce8fe30e0deafc4f66d58357c06fd4a820285294b9746c3be9509115c96e962322ffed6522f57194627136b8d03ac7469109707f5e44190c4840c49773308a13d740a7f0d4f0e6163b02c5a408b6f965856b6a491002d073d5b00d3d81beb009873eb7116327cf47c612d5758ef083d4fda78e9b63980b2a7622f567d22d2b02fe1f4ad42db9d58a36afd1983e7e2909d1cab61cafedad6193a0a7c585381b10f4666044266a02405bf6e01fa564c8517d4ad5823493abd31de', + '0x05eb10b0bda78b5d8dc91de3d62bed7b55d73b5509521a9f8ef7269133e58a8c2c93b9572b35f9c9e07e9003ae1ca444442a165f927bce00e347dab57cc19391148730d0deec722eb6c54747df7345bc2ab3bd8e81f438b17b81ccabd9e6a3ac0708920251ccaf6664d769cbc47c8d767f64912639e13d9f9e441b225066161900c48a65eea83f1dbf217c43daf1be6ba9cefd2754f07e3cc13e81e5432e47f30dfb47c8b1e11368bec638fd9d22c696bf9c323a0fd09050745f4b7cf150bfa529a9f3062ee5f9d0a099ac53b4e1130653fb797ed2b59914a8915951d13ad8252521211957a854707af85ad40e9ab4d474a4fcbdcbe7a47866cae0db4fd86ed2261669d85a9cfbd09365a6db5d7acfe5560104a0cb893a375d6c08ffb9cbb8270be446a16361f271ac11899ee19f990c68035da18703ba00c8e9773dfe6a784a', ); }); diff --git a/yarn-project/key-store/src/key_store.test.ts b/yarn-project/key-store/src/key_store.test.ts index d7dd6936007..218da7ff548 100644 --- a/yarn-project/key-store/src/key_store.test.ts +++ b/yarn-project/key-store/src/key_store.test.ts @@ -24,7 +24,7 @@ describe('KeyStore', () => { const { address: accountAddress } = await keyStore.addAccount(sk, partialAddress); expect(accountAddress.toString()).toMatchInlineSnapshot( - `"0x23a1f3daede8d7ff24ccd0354b114c38c11a1512434a2529cf404f74a8f0ab6c"`, + `"0x2321fcb3bd7447b178138746ee78f6fbb1e2a2aa8ff542f51420b884bab641cc"`, ); const { pkM: masterNullifierPublicKey } = await keyStore.getKeyValidationRequest( @@ -56,24 +56,24 @@ describe('KeyStore', () => { const { pkM: obtainedMasterNullifierPublicKey, skApp: appNullifierSecretKey } = await keyStore.getKeyValidationRequest(computedMasterNullifierPublicKeyHash, appAddress); expect(appNullifierSecretKey.toString()).toMatchInlineSnapshot( - `"0x0084c92262407236c992dcea10cf3406a642074cad6c6034d2990ffb073207a7"`, + `"0x0030e54eefa97f61f384e112dcf7859583494e0e1823a272d18ea93eb110c0a7"`, ); expect(obtainedMasterNullifierPublicKey).toEqual(masterNullifierPublicKey); const appIncomingViewingSecretKey = await keyStore.getAppIncomingViewingSecretKey(accountAddress, appAddress); expect(appIncomingViewingSecretKey.toString()).toMatchInlineSnapshot( - `"0x2639b26510f9d30b7e173d301b263b246b7a576186be1f44cd7c86bc06773f8a"`, + `"0x0247d73d16cf0939cc783b3cee140b37b294b6cbc1c0295d530f3f637c9b8034"`, ); const appOutgoingViewingSecretKey = await keyStore.getAppOutgoingViewingSecretKey(accountAddress, appAddress); expect(appOutgoingViewingSecretKey.toString()).toMatchInlineSnapshot( - `"0x13b400d2fccab28a04a4df9fe541d242e6b518d03137ef0ffa57c3d98cc56e67"`, + `"0x296c9931262d8b95b4cbbcc66ac4c97d2cc3fab4da5eedc08fcff80f1ce37e34"`, ); // Returned accounts are as expected const accounts = await keyStore.getAccounts(); expect(accounts.toString()).toMatchInlineSnapshot( - `"0x23a1f3daede8d7ff24ccd0354b114c38c11a1512434a2529cf404f74a8f0ab6c"`, + `"0x2321fcb3bd7447b178138746ee78f6fbb1e2a2aa8ff542f51420b884bab641cc"`, ); // Manages to find master nullifer secret key for pub key @@ -98,7 +98,7 @@ describe('KeyStore', () => { const { address: accountAddress } = await keyStore.addAccount(sk, partialAddress); expect(accountAddress.toString()).toMatchInlineSnapshot( - `"0x23a1f3daede8d7ff24ccd0354b114c38c11a1512434a2529cf404f74a8f0ab6c"`, + `"0x2321fcb3bd7447b178138746ee78f6fbb1e2a2aa8ff542f51420b884bab641cc"`, ); // Arbitrary fixed values @@ -146,21 +146,21 @@ describe('KeyStore', () => { appAddress, ); expect(appNullifierSecretKey0.toString()).toMatchInlineSnapshot( - `"0x21e3ca4bc7ae2b5e9fe343f4eec5c0aa7391857333821a4b0a1c7d4cb0055bf0"`, + `"0x0d03293ba35ee33ac093be75119d9819da11631b3739b0f12788ef66b28834d5"`, ); const { skApp: appNullifierSecretKey1 } = await keyStore.getKeyValidationRequest( newComputedMasterNullifierPublicKeyHashes[1], appAddress, ); expect(appNullifierSecretKey1.toString()).toMatchInlineSnapshot( - `"0x0900aea4825d057e5bc916063a535520a7c6283740eaf218cd6961b10cba46fd"`, + `"0x01baec4d9f3d4b98fa883e256917e91e913490d92cd01763dea49337c9d364af"`, ); const { skApp: appNullifierSecretKey2 } = await keyStore.getKeyValidationRequest( newComputedMasterNullifierPublicKeyHashes[2], appAddress, ); expect(appNullifierSecretKey2.toString()).toMatchInlineSnapshot( - `"0x27ccbe41ff5f33fa78348533da9d4a79e8fea8805771e61748ea42be4202f168"`, + `"0x0d1ff3fde73bc14ea0cfa704aed68d72c27bf58e6159e381f23d2951ce3566ec"`, ); expect(appNullifierSecretKey0).toEqual(computeAppNullifierSecretKey(newMasterNullifierSecretKeys[0], appAddress)); diff --git a/yarn-project/key-store/src/key_store.ts b/yarn-project/key-store/src/key_store.ts index 4df9ce6e3fe..34a54548d27 100644 --- a/yarn-project/key-store/src/key_store.ts +++ b/yarn-project/key-store/src/key_store.ts @@ -16,7 +16,7 @@ import { deriveKeys, derivePublicKeyFromSecretKey, } from '@aztec/circuits.js'; -import { poseidon2Hash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { type Bufferable, serializeToBuffer } from '@aztec/foundation/serialize'; import { type AztecKVStore, type AztecMap } from '@aztec/kv-store'; @@ -231,7 +231,10 @@ export class KeyStore { const masterIncomingViewingSecretKey = GrumpkinScalar.fromBuffer(masterIncomingViewingSecretKeyBuffer); return Promise.resolve( - poseidon2Hash([masterIncomingViewingSecretKey.hi, masterIncomingViewingSecretKey.lo, app, GeneratorIndex.IVSK_M]), + poseidon2HashWithSeparator( + [masterIncomingViewingSecretKey.hi, masterIncomingViewingSecretKey.lo, app], + GeneratorIndex.IVSK_M, + ), ); } @@ -252,7 +255,10 @@ export class KeyStore { const masterOutgoingViewingSecretKey = GrumpkinScalar.fromBuffer(masterOutgoingViewingSecretKeyBuffer); return Promise.resolve( - poseidon2Hash([masterOutgoingViewingSecretKey.hi, masterOutgoingViewingSecretKey.lo, app, GeneratorIndex.OVSK_M]), + poseidon2HashWithSeparator( + [masterOutgoingViewingSecretKey.hi, masterOutgoingViewingSecretKey.lo, app], + GeneratorIndex.OVSK_M, + ), ); } diff --git a/yarn-project/noir-protocol-circuits-types/src/__snapshots__/noir_test_gen.test.ts.snap b/yarn-project/noir-protocol-circuits-types/src/__snapshots__/noir_test_gen.test.ts.snap index b7160fedd4e..591ccd53fb3 100644 --- a/yarn-project/noir-protocol-circuits-types/src/__snapshots__/noir_test_gen.test.ts.snap +++ b/yarn-project/noir-protocol-circuits-types/src/__snapshots__/noir_test_gen.test.ts.snap @@ -5,12 +5,12 @@ exports[`Data generation for noir tests Computes contract info for defaultContra contract_address_salt: 0x000000000000000000000000000000000000000000000000000000000000ddd5, artifact_hash: 0x0000000000000000000000000000000000000000000000000000000000003039, public_bytecode_commitment: 0x0000000000000000000000000000000000000000000000000000000000000005, - private_functions_root: 0x19a3cc0b714976fb35d58b684ba36e86f82bac8b87517904a2727e5113fb4cba, - address: AztecAddress { inner: 0x24e2561e4216c843ff11bf77d4f8a68247e537980273ce54b09b505f7352f6bb }, - partial_address: PartialAddress { inner: 0x27ab8475fe4647b48ffc4df7a6cc42bf1125f000ff113d9a0d6a11b952626761 }, - contract_class_id: ContractClassId { inner: 0x29f4bda24f38507064a90f7505dc0381c9d83c97271c5c2e92a4261d300861bf }, + private_functions_root: 0x04c207a8a83f20ee6c6dbeb40636e8132bc18e971927f7d81f18cb92705ee817, + address: AztecAddress { inner: 0x10f0c308adf33bceef3ed638bf8a5b403691eefc4ee7a0c20f0438c8a7096226 }, + partial_address: PartialAddress { inner: 0x08e858be915646809621b06c4fcea0bfcf2817b07c1885e9a0497554638be93f }, + contract_class_id: ContractClassId { inner: 0x227e7a3a22b2a95ce3b91fbb47a80669d7d68ee34db7bf998cb9457ee59f3179 }, public_keys_hash: PublicKeysHash { inner: 0x000000000000000000000000000000000000000000000000000000000000b26e }, - salted_initialization_hash: SaltedInitializationHash { inner: 0x25765504545d2cdaaa6544eb24bc78a3e20384452f2525669f196a1a42f45906 }, + salted_initialization_hash: SaltedInitializationHash { inner: 0x13a939daa511233e5446905ed2cadbee14948fa75df183b53b5c14b612bffe88 }, deployer: AztecAddress { inner: 0x0000000000000000000000000000000000000000000000000000000000000000 } }" `; @@ -20,12 +20,12 @@ exports[`Data generation for noir tests Computes contract info for parentContrac contract_address_salt: 0x0000000000000000000000000000000000000000000000000000000000001618, artifact_hash: 0x00000000000000000000000000000000000000000000000000000000000004bc, public_bytecode_commitment: 0x0000000000000000000000000000000000000000000000000000000000000005, - private_functions_root: 0x2c1c949cb226995de94b7b8b5aeaab440739f2dfeb06d358441f60932cf243a7, - address: AztecAddress { inner: 0x19343447ef402928668ca94b123ccddc264fbf7528da6d77277af40acd9c43d3 }, - partial_address: PartialAddress { inner: 0x1d6cbda965559d021963e76b1342a879b69c8f29c6b458068ed81a87cbf20181 }, - contract_class_id: ContractClassId { inner: 0x037a09515a79a2b8ebe5139dae1ab7c433523ac1fd5631836890df2148df51c7 }, + private_functions_root: 0x13911dea3b1d55fe459c95739f42df2cd7c2c610ab16a5632ab649760f3d0522, + address: AztecAddress { inner: 0x0df89b4b442718bc22a06f5ac353e83562adb5c48465dd2663e90648067ab87b }, + partial_address: PartialAddress { inner: 0x2e150667b5cd21814d880d7c853a637d3818fc545209a8a90521079351e836c7 }, + contract_class_id: ContractClassId { inner: 0x198333ba87796984608fe55a13c975fd3fa8ce721ee4d4b97b6886818a1d8fdb }, public_keys_hash: PublicKeysHash { inner: 0x00000000000000000000000000000000000000000000000000000000000011c1 }, - salted_initialization_hash: SaltedInitializationHash { inner: 0x0b1d457cdacb66e76eccb29a4e34dff5ae10b9d3d2f0d85b59aa8cf68bd1cf86 }, + salted_initialization_hash: SaltedInitializationHash { inner: 0x24bd6ac7a182e2cf25e437c72f53544ef81dfd97d9afee23abb07a638e7be749 }, deployer: AztecAddress { inner: 0x0000000000000000000000000000000000000000000000000000000000000000 } }" `; @@ -34,9 +34,9 @@ exports[`Data generation for noir tests Computes function tree for defaultContra [ { "index": 0, - "leaf": "1b208d72e8313fab273c9508bb07b497f2b433360250b3db2c9e20e238e2cff0", + "leaf": "0be91a61ae34b803eda7f42a012617acabe2d5442311a009db68ac12db3f4edb", "siblingPath": [ - "1e5cebe7a50c5c8fd1ebe19ed6bbf80f77819b12a2a28f334e895501e1cda574", + "1eca11cd2abe68905eab86bc4f207cde29eb7c2b4c2c9b27e3d8c2f8b8234c87", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", @@ -45,9 +45,9 @@ exports[`Data generation for noir tests Computes function tree for defaultContra }, { "index": 1, - "leaf": "1e5cebe7a50c5c8fd1ebe19ed6bbf80f77819b12a2a28f334e895501e1cda574", + "leaf": "1eca11cd2abe68905eab86bc4f207cde29eb7c2b4c2c9b27e3d8c2f8b8234c87", "siblingPath": [ - "1b208d72e8313fab273c9508bb07b497f2b433360250b3db2c9e20e238e2cff0", + "0be91a61ae34b803eda7f42a012617acabe2d5442311a009db68ac12db3f4edb", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", @@ -59,7 +59,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "leaf": "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", - "02739392b5fc5473be0e69087e89400506d656ecf05f54ad2d7a32f3f7efbfcf", + "0d18bf69ba03cceb5b3ad320c0439559ae10eabd18dea07ea239c8eb2a96c3f8", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", @@ -70,7 +70,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "leaf": "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", - "02739392b5fc5473be0e69087e89400506d656ecf05f54ad2d7a32f3f7efbfcf", + "0d18bf69ba03cceb5b3ad320c0439559ae10eabd18dea07ea239c8eb2a96c3f8", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", @@ -82,7 +82,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", - "0c0ab7b160aea39e6b99fe87099d0e79e6ddbbc70ca9059f34503bbb8143a424", + "2abaec05b9213bcb88a4ce2f2abb5ae729da681ca7f052ed22ea748f06b91669", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], @@ -93,7 +93,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", - "0c0ab7b160aea39e6b99fe87099d0e79e6ddbbc70ca9059f34503bbb8143a424", + "2abaec05b9213bcb88a4ce2f2abb5ae729da681ca7f052ed22ea748f06b91669", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], @@ -104,7 +104,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", - "0c0ab7b160aea39e6b99fe87099d0e79e6ddbbc70ca9059f34503bbb8143a424", + "2abaec05b9213bcb88a4ce2f2abb5ae729da681ca7f052ed22ea748f06b91669", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], @@ -115,7 +115,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", - "0c0ab7b160aea39e6b99fe87099d0e79e6ddbbc70ca9059f34503bbb8143a424", + "2abaec05b9213bcb88a4ce2f2abb5ae729da681ca7f052ed22ea748f06b91669", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], @@ -127,7 +127,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "14c90a3ee34dec5378416eaed337d0ca75e55375a48c1201f7069f5ff4b75472", + "143a68c9a121b174524ae4bac28e8931d8ff97b59158c1576713bda2a2e291ea", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -138,7 +138,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "14c90a3ee34dec5378416eaed337d0ca75e55375a48c1201f7069f5ff4b75472", + "143a68c9a121b174524ae4bac28e8931d8ff97b59158c1576713bda2a2e291ea", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -149,7 +149,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "14c90a3ee34dec5378416eaed337d0ca75e55375a48c1201f7069f5ff4b75472", + "143a68c9a121b174524ae4bac28e8931d8ff97b59158c1576713bda2a2e291ea", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -160,7 +160,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "14c90a3ee34dec5378416eaed337d0ca75e55375a48c1201f7069f5ff4b75472", + "143a68c9a121b174524ae4bac28e8931d8ff97b59158c1576713bda2a2e291ea", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -171,7 +171,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "14c90a3ee34dec5378416eaed337d0ca75e55375a48c1201f7069f5ff4b75472", + "143a68c9a121b174524ae4bac28e8931d8ff97b59158c1576713bda2a2e291ea", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -182,7 +182,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "14c90a3ee34dec5378416eaed337d0ca75e55375a48c1201f7069f5ff4b75472", + "143a68c9a121b174524ae4bac28e8931d8ff97b59158c1576713bda2a2e291ea", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -193,7 +193,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "14c90a3ee34dec5378416eaed337d0ca75e55375a48c1201f7069f5ff4b75472", + "143a68c9a121b174524ae4bac28e8931d8ff97b59158c1576713bda2a2e291ea", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -204,7 +204,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "14c90a3ee34dec5378416eaed337d0ca75e55375a48c1201f7069f5ff4b75472", + "143a68c9a121b174524ae4bac28e8931d8ff97b59158c1576713bda2a2e291ea", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -216,7 +216,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -227,7 +227,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -238,7 +238,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -249,7 +249,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -260,7 +260,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -271,7 +271,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -282,7 +282,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -293,7 +293,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -304,7 +304,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -315,7 +315,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -326,7 +326,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -337,7 +337,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -348,7 +348,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -359,7 +359,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -370,7 +370,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, { @@ -381,7 +381,7 @@ exports[`Data generation for noir tests Computes function tree for defaultContra "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "0bce4eca438f424383ca076405135975c2f59abc9ecca719a1774cfb715f055c", + "2ad0260e195a5c88385538f3b9e0467a60c847b68afe88effff319025795fee6", ], }, ] @@ -391,7 +391,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac [ { "index": 0, - "leaf": "2ee20edbb8d85b024f9c33ed496d58557d450b3b8b3678007ad32814ff2b6194", + "leaf": "1ee8cc7be382b517559b55384a8a19eb75801364df37f14ef21c29f49ee2f018", "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", @@ -404,7 +404,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "index": 1, "leaf": "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "siblingPath": [ - "2ee20edbb8d85b024f9c33ed496d58557d450b3b8b3678007ad32814ff2b6194", + "1ee8cc7be382b517559b55384a8a19eb75801364df37f14ef21c29f49ee2f018", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", @@ -416,7 +416,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "leaf": "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", - "10cbd3449166dc7f8ad4df6fbc80405f2e08ccaf4fbe4f450bc8dfa40e1e4fd5", + "0ccad92cf945fdfa0c63d869356bcc5d1b17432cd95fe1099f4a7bc881a45663", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", @@ -427,7 +427,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "leaf": "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", - "10cbd3449166dc7f8ad4df6fbc80405f2e08ccaf4fbe4f450bc8dfa40e1e4fd5", + "0ccad92cf945fdfa0c63d869356bcc5d1b17432cd95fe1099f4a7bc881a45663", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", @@ -439,7 +439,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", - "05ae88ae680ba4ab3c45258dc675c1fd64192cd35477436298f0a99abf2591be", + "0c7d303627b7dfbf4b090060f56d16e00b5f3a2693bf1bf69e94777e25c11f13", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], @@ -450,7 +450,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", - "05ae88ae680ba4ab3c45258dc675c1fd64192cd35477436298f0a99abf2591be", + "0c7d303627b7dfbf4b090060f56d16e00b5f3a2693bf1bf69e94777e25c11f13", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], @@ -461,7 +461,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", - "05ae88ae680ba4ab3c45258dc675c1fd64192cd35477436298f0a99abf2591be", + "0c7d303627b7dfbf4b090060f56d16e00b5f3a2693bf1bf69e94777e25c11f13", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], @@ -472,7 +472,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "siblingPath": [ "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", - "05ae88ae680ba4ab3c45258dc675c1fd64192cd35477436298f0a99abf2591be", + "0c7d303627b7dfbf4b090060f56d16e00b5f3a2693bf1bf69e94777e25c11f13", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], @@ -484,7 +484,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "2899debba6ec014cd55583750a87aea681a07a85074c74cb5cd54d2fcb24ab3f", + "0fb7be26990bf7a064b03621e3944e043c5d6097efb21cde8a29773c55bd698f", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -495,7 +495,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "2899debba6ec014cd55583750a87aea681a07a85074c74cb5cd54d2fcb24ab3f", + "0fb7be26990bf7a064b03621e3944e043c5d6097efb21cde8a29773c55bd698f", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -506,7 +506,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "2899debba6ec014cd55583750a87aea681a07a85074c74cb5cd54d2fcb24ab3f", + "0fb7be26990bf7a064b03621e3944e043c5d6097efb21cde8a29773c55bd698f", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -517,7 +517,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "2899debba6ec014cd55583750a87aea681a07a85074c74cb5cd54d2fcb24ab3f", + "0fb7be26990bf7a064b03621e3944e043c5d6097efb21cde8a29773c55bd698f", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -528,7 +528,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "2899debba6ec014cd55583750a87aea681a07a85074c74cb5cd54d2fcb24ab3f", + "0fb7be26990bf7a064b03621e3944e043c5d6097efb21cde8a29773c55bd698f", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -539,7 +539,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "2899debba6ec014cd55583750a87aea681a07a85074c74cb5cd54d2fcb24ab3f", + "0fb7be26990bf7a064b03621e3944e043c5d6097efb21cde8a29773c55bd698f", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -550,7 +550,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "2899debba6ec014cd55583750a87aea681a07a85074c74cb5cd54d2fcb24ab3f", + "0fb7be26990bf7a064b03621e3944e043c5d6097efb21cde8a29773c55bd698f", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -561,7 +561,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed", "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", - "2899debba6ec014cd55583750a87aea681a07a85074c74cb5cd54d2fcb24ab3f", + "0fb7be26990bf7a064b03621e3944e043c5d6097efb21cde8a29773c55bd698f", "03c9e2e67178ac638746f068907e6677b4cc7a9592ef234ab6ab518f17efffa0", ], }, @@ -573,7 +573,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -584,7 +584,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -595,7 +595,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -606,7 +606,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -617,7 +617,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -628,7 +628,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -639,7 +639,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -650,7 +650,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -661,7 +661,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -672,7 +672,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -683,7 +683,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -694,7 +694,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -705,7 +705,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -716,7 +716,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -727,7 +727,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, { @@ -738,7 +738,7 @@ exports[`Data generation for noir tests Computes function tree for parentContrac "21dbfd1d029bf447152fcf89e355c334610d1632436ba170f738107266a71550", "0bcd1f91cf7bdd471d0a30c58c4706f3fdab3807a954b8f5b5e3bfec87d001bb", "06e62084ee7b602fe9abc15632dda3269f56fb0c6e12519a2eb2ec897091919d", - "109e7ff8fd7bc4d204cdc1dac1f8188e296e150d57216a27628ea9c47f209bd8", + "2bb6d84ba45de26995a73faf59249b4a3195101ea5b5d89142db16fe5ce6442b", ], }, ] diff --git a/yarn-project/simulator/src/client/client_execution_context.ts b/yarn-project/simulator/src/client/client_execution_context.ts index 76cdade839c..cf6dc0b4a5a 100644 --- a/yarn-project/simulator/src/client/client_execution_context.ts +++ b/yarn-project/simulator/src/client/client_execution_context.ts @@ -30,7 +30,7 @@ import { countArgumentsSize, } from '@aztec/foundation/abi'; import { type AztecAddress } from '@aztec/foundation/aztec-address'; -import { pedersenHash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr, GrumpkinScalar, type Point } from '@aztec/foundation/fields'; import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log'; @@ -357,7 +357,7 @@ export class ClientExecutionContext extends ViewDataOracle { // An app providing randomness = 0 signals to not mask the address. const maskedContractAddress = randomness.isZero() ? contractAddress.toField() - : pedersenHash([contractAddress, randomness], 0); + : poseidon2HashWithSeparator([contractAddress, randomness], 0); const encryptedLog = new CountedLog(new EncryptedL2Log(encryptedEvent, maskedContractAddress), counter); this.encryptedLogs.push(encryptedLog); } diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 0fa47d1f4ae..d6de92443dc 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -49,7 +49,7 @@ import { import { asyncMap } from '@aztec/foundation/async-map'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { times } from '@aztec/foundation/collection'; -import { pedersenHash, poseidon2Hash, randomInt } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator, randomInt } from '@aztec/foundation/crypto'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log'; @@ -297,7 +297,7 @@ describe('Private Execution test suite', () => { expect(encryptedLog.length).toEqual(new Fr(functionLogs.getKernelLength())); // 5 is hardcoded in the test contract expect(encryptedLog.randomness).toEqual(new Fr(5)); - const expectedMaskedAddress = pedersenHash([result.callStackItem.contractAddress, new Fr(5)], 0); + const expectedMaskedAddress = poseidon2HashWithSeparator([result.callStackItem.contractAddress, new Fr(5)], 0); expect(expectedMaskedAddress).toEqual(functionLogs.logs[0].maskedContractAddress); }); }); @@ -995,11 +995,10 @@ describe('Private Execution test suite', () => { expect(result.returnValues).toEqual([new Fr(amountToTransfer)]); const nullifier = result.callStackItem.publicInputs.nullifiers[0]; - const expectedNullifier = poseidon2Hash([ - slottedNoteHash, - computeAppNullifierSecretKey(ownerNskM, contractAddress), + const expectedNullifier = poseidon2HashWithSeparator( + [slottedNoteHash, computeAppNullifierSecretKey(ownerNskM, contractAddress)], GeneratorIndex.NOTE_NULLIFIER, - ]); + ); expect(nullifier.value).toEqual(expectedNullifier); }); @@ -1079,11 +1078,10 @@ describe('Private Execution test suite', () => { expect(execGetThenNullify.returnValues).toEqual([new Fr(amountToTransfer)]); const nullifier = execGetThenNullify.callStackItem.publicInputs.nullifiers[0]; - const expectedNullifier = poseidon2Hash([ - slottedNoteHash, - computeAppNullifierSecretKey(ownerNskM, contractAddress), + const expectedNullifier = poseidon2HashWithSeparator( + [slottedNoteHash, computeAppNullifierSecretKey(ownerNskM, contractAddress)], GeneratorIndex.NOTE_NULLIFIER, - ]); + ); expect(nullifier.value).toEqual(expectedNullifier); }); diff --git a/yarn-project/simulator/src/client/simulator.test.ts b/yarn-project/simulator/src/client/simulator.test.ts index 27e6355367e..53b4ea3b9ee 100644 --- a/yarn-project/simulator/src/client/simulator.test.ts +++ b/yarn-project/simulator/src/client/simulator.test.ts @@ -3,7 +3,7 @@ import { GeneratorIndex, KeyValidationRequest, computeAppNullifierSecretKey, der import { computeUniqueNoteHash, siloNoteHash } from '@aztec/circuits.js/hash'; import { type FunctionArtifact, getFunctionArtifact } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { poseidon2Hash } from '@aztec/foundation/crypto'; +import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr, type Point } from '@aztec/foundation/fields'; import { TokenBlacklistContractArtifact } from '@aztec/noir-contracts.js'; @@ -65,7 +65,10 @@ describe('Simulator', () => { const slottedNoteHash = computeSlottedNoteHash(storageSlot, noteHidingPoint); const uniqueNoteHash = computeUniqueNoteHash(nonce, slottedNoteHash); const siloedNoteHash = siloNoteHash(contractAddress, uniqueNoteHash); - const innerNullifier = poseidon2Hash([siloedNoteHash, appNullifierSecretKey, GeneratorIndex.NOTE_NULLIFIER]); + const innerNullifier = poseidon2HashWithSeparator( + [siloedNoteHash, appNullifierSecretKey], + GeneratorIndex.NOTE_NULLIFIER, + ); const result = await simulator.computeNoteHashAndOptionallyANullifier( contractAddress, diff --git a/yarn-project/simulator/src/public/public_processor.test.ts b/yarn-project/simulator/src/public/public_processor.test.ts index 02f4bf004ad..28157d0ac80 100644 --- a/yarn-project/simulator/src/public/public_processor.test.ts +++ b/yarn-project/simulator/src/public/public_processor.test.ts @@ -389,8 +389,8 @@ describe('public_processor', () => { const txEffect = toTxEffect(processed[0], GasFees.default()); const numPublicDataWrites = 5; - expect(arrayNonEmptyLength(txEffect.publicDataWrites, PublicDataWrite.isEmpty)).toBe(numPublicDataWrites); - expect(txEffect.publicDataWrites.slice(0, numPublicDataWrites)).toEqual([ + expect(arrayNonEmptyLength(txEffect.publicDataWrites, PublicDataWrite.isEmpty)).toEqual(numPublicDataWrites); + const expectedWrites = [ new PublicDataWrite( computePublicDataTreeLeafSlot(nonRevertibleRequests[0].callContext.storageContractAddress, contractSlotA), fr(0x101), @@ -399,7 +399,10 @@ describe('public_processor', () => { new PublicDataWrite(computePublicDataTreeLeafSlot(nestedContractAddress, contractSlotC), fr(0x201)), new PublicDataWrite(computePublicDataTreeLeafSlot(nestedContractAddress, contractSlotF), fr(0x351)), new PublicDataWrite(computePublicDataTreeLeafSlot(nestedContractAddress, contractSlotD), fr(0x251)), - ]); + ]; + // sort increasing by leafIndex + expectedWrites.sort((a, b) => (a.leafIndex.lt(b.leafIndex) ? -1 : 1)); + expect(txEffect.publicDataWrites.slice(0, numPublicDataWrites)).toEqual(expectedWrites); // we keep the non-revertible logs expect(txEffect.encryptedLogs.getTotalLogCount()).toBe(3); @@ -887,9 +890,9 @@ describe('public_processor', () => { const numPublicDataWrites = 3; expect(arrayNonEmptyLength(txEffect.publicDataWrites, PublicDataWrite.isEmpty)).toEqual(numPublicDataWrites); expect(txEffect.publicDataWrites.slice(0, numPublicDataWrites)).toEqual([ - new PublicDataWrite(computePublicDataTreeLeafSlot(nestedContractAddress, contractSlotA), fr(0x103)), new PublicDataWrite(computePublicDataTreeLeafSlot(nestedContractAddress, contractSlotB), fr(0x152)), new PublicDataWrite(computePublicDataTreeLeafSlot(nestedContractAddress, contractSlotC), fr(0x201)), + new PublicDataWrite(computePublicDataTreeLeafSlot(nestedContractAddress, contractSlotA), fr(0x103)), ]); expect(txEffect.encryptedLogs.getTotalLogCount()).toBe(0); expect(txEffect.unencryptedLogs.getTotalLogCount()).toBe(0);