diff --git a/authwit/src/auth.nr b/authwit/src/auth.nr index 90972c94..f1e12f7b 100644 --- a/authwit/src/auth.nr +++ b/authwit/src/auth.nr @@ -1,7 +1,7 @@ use dep::aztec::protocol_types::{ abis::function_selector::FunctionSelector, address::AztecAddress, constants::{GENERATOR_INDEX__AUTHWIT_INNER, GENERATOR_INDEX__AUTHWIT_OUTER}, - hash::{hash_args, pedersen_hash} + hash::{hash_args_array, pedersen_hash} }; use dep::aztec::context::{PrivateContext, PublicContext, Context}; @@ -37,7 +37,7 @@ pub fn compute_call_authwit_hash( selector: FunctionSelector, args: [Field; N] ) -> Field { - let args_hash = hash_args(args); + let args_hash = hash_args_array(args); let inner_hash = compute_inner_authwit_hash([caller.to_field(), selector.to_field(), args_hash]); compute_outer_authwit_hash(consumer, chain_id, version, inner_hash) } diff --git a/authwit/src/entrypoint/app.nr b/authwit/src/entrypoint/app.nr index 529b5e78..33e1c7c2 100644 --- a/authwit/src/entrypoint/app.nr +++ b/authwit/src/entrypoint/app.nr @@ -47,7 +47,7 @@ impl AppPayload { for i in 0..ACCOUNT_MAX_CALLS { bytes.extend_from_array(self.function_calls[i].to_be_bytes()); } - bytes.extend_from_array(self.nonce.to_be_bytes(32)); + bytes.extend_from_slice(self.nonce.to_be_bytes(32)); bytes.storage } diff --git a/authwit/src/entrypoint/fee.nr b/authwit/src/entrypoint/fee.nr index 89616efa..827dcc69 100644 --- a/authwit/src/entrypoint/fee.nr +++ b/authwit/src/entrypoint/fee.nr @@ -45,7 +45,7 @@ impl FeePayload { for i in 0..MAX_FEE_FUNCTION_CALLS { bytes.extend_from_array(self.function_calls[i].to_be_bytes()); } - bytes.extend_from_array(self.nonce.to_be_bytes(32)); + bytes.extend_from_slice(self.nonce.to_be_bytes(32)); bytes.storage } diff --git a/aztec/src/context/private_context.nr b/aztec/src/context/private_context.nr index d8e32b56..c556c184 100644 --- a/aztec/src/context/private_context.nr +++ b/aztec/src/context/private_context.nr @@ -24,10 +24,11 @@ use dep::protocol_types::{ MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, MAX_PUBLIC_DATA_READS_PER_CALL, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, - MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL, RETURN_VALUES_LENGTH + MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL, + RETURN_VALUES_LENGTH }, contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest}, - grumpkin_private_key::GrumpkinPrivateKey, hash::hash_args, header::Header, + grumpkin_private_key::GrumpkinPrivateKey, hash::hash_args_array, header::Header, messaging::l2_to_l1_message::L2ToL1Message, utils::reader::Reader, traits::is_empty }; @@ -273,7 +274,7 @@ impl PrivateContext { function_selector: FunctionSelector, args: [Field; ARGS_COUNT] ) -> [Field; RETURN_VALUES_LENGTH] { - let args_hash = hash_args(args); + let args_hash = hash_args_array(args); assert(args_hash == arguments::pack_arguments(args)); self.call_private_function_with_packed_args(contract_address, function_selector, args_hash, false, false) } @@ -284,7 +285,7 @@ impl PrivateContext { function_selector: FunctionSelector, args: [Field; ARGS_COUNT] ) -> [Field; RETURN_VALUES_LENGTH] { - let args_hash = hash_args(args); + let args_hash = hash_args_array(args); assert(args_hash == arguments::pack_arguments(args)); self.call_private_function_with_packed_args(contract_address, function_selector, args_hash, true, false) } @@ -295,7 +296,7 @@ impl PrivateContext { function_selector: FunctionSelector, args: [Field; ARGS_COUNT] ) -> [Field; RETURN_VALUES_LENGTH] { - let args_hash = hash_args(args); + let args_hash = hash_args_array(args); assert(args_hash == arguments::pack_arguments(args)); self.call_private_function_with_packed_args(contract_address, function_selector, args_hash, false, true) } @@ -380,7 +381,7 @@ impl PrivateContext { function_selector: FunctionSelector, args: [Field; ARGS_COUNT] ) { - let args_hash = hash_args(args); + let args_hash = hash_args_array(args); assert(args_hash == arguments::pack_arguments(args)); self.call_public_function_with_packed_args(contract_address, function_selector, args_hash, false, false) } @@ -391,7 +392,7 @@ impl PrivateContext { function_selector: FunctionSelector, args: [Field; ARGS_COUNT] ) { - let args_hash = hash_args(args); + let args_hash = hash_args_array(args); assert(args_hash == arguments::pack_arguments(args)); self.call_public_function_with_packed_args(contract_address, function_selector, args_hash, true, false) } @@ -402,7 +403,7 @@ impl PrivateContext { function_selector: FunctionSelector, args: [Field; ARGS_COUNT] ) { - let args_hash = hash_args(args); + let args_hash = hash_args_array(args); assert(args_hash == arguments::pack_arguments(args)); self.call_public_function_with_packed_args(contract_address, function_selector, args_hash, false, true) } diff --git a/aztec/src/context/public_context.nr b/aztec/src/context/public_context.nr index 42a9ed90..38b9b17e 100644 --- a/aztec/src/context/public_context.nr +++ b/aztec/src/context/public_context.nr @@ -18,7 +18,8 @@ use dep::protocol_types::{ MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL, RETURN_VALUES_LENGTH }, contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest}, - hash::hash_args, header::Header, messaging::l2_to_l1_message::L2ToL1Message, utils::reader::Reader + hash::hash_args_array, header::Header, messaging::l2_to_l1_message::L2ToL1Message, + utils::reader::Reader }; struct PublicContext { @@ -266,7 +267,7 @@ impl PublicContextInterface for PublicContext { function_selector: FunctionSelector, args: [Field; ARGS_COUNT] ) -> [Field; RETURN_VALUES_LENGTH] { - let args_hash = hash_args(args); + let args_hash = hash_args_array(args); assert(args_hash == arguments::pack_arguments(args)); self.call_public_function_with_packed_args(contract_address, function_selector, args_hash, false, false) } @@ -277,7 +278,7 @@ impl PublicContextInterface for PublicContext { function_selector: FunctionSelector, args: [Field; ARGS_COUNT] ) -> [Field; RETURN_VALUES_LENGTH] { - let args_hash = hash_args(args); + let args_hash = hash_args_array(args); assert(args_hash == arguments::pack_arguments(args)); self.call_public_function_with_packed_args(contract_address, function_selector, args_hash, true, false) } @@ -288,7 +289,7 @@ impl PublicContextInterface for PublicContext { function_selector: FunctionSelector, args: [Field; ARGS_COUNT] ) -> [Field; RETURN_VALUES_LENGTH] { - let args_hash = hash_args(args); + let args_hash = hash_args_array(args); assert(args_hash == arguments::pack_arguments(args)); self.call_public_function_with_packed_args(contract_address, function_selector, args_hash, false, true) } diff --git a/aztec/src/hash.nr b/aztec/src/hash.nr index 05234149..7c5623cf 100644 --- a/aztec/src/hash.nr +++ b/aztec/src/hash.nr @@ -3,6 +3,8 @@ use dep::protocol_types::{ constants::GENERATOR_INDEX__L1_TO_L2_MESSAGE_SECRET, hash::{pedersen_hash, silo_nullifier}}; +use dep::protocol_types::hash::{hash_args, hash_args_array}; + pub fn compute_secret_hash(secret: Field) -> Field { // TODO(#1205) This is probably not the right index to use pedersen_hash([secret], GENERATOR_INDEX__L1_TO_L2_MESSAGE_SECRET) diff --git a/aztec/src/hasher.nr b/aztec/src/hasher.nr deleted file mode 100644 index b1f15441..00000000 --- a/aztec/src/hasher.nr +++ /dev/null @@ -1,27 +0,0 @@ -use dep::protocol_types::{hash::hash_args, traits::Hash}; - -struct Hasher { - fields: [Field], -} - -impl Hash for Hasher { - fn hash(self) -> Field { - hash_args(self.fields) - } -} - -impl Hasher { - pub fn new() -> Self { - Self { fields: [] } - } - - pub fn add(&mut self, field: Field) { - self.fields = self.fields.push_back(field); - } - - pub fn add_multiple(&mut self, fields: [Field; N]) { - for i in 0..N { - self.fields = self.fields.push_back(fields[i]); - } - } -} diff --git a/aztec/src/lib.nr b/aztec/src/lib.nr index a57f6c01..e7554afb 100644 --- a/aztec/src/lib.nr +++ b/aztec/src/lib.nr @@ -2,7 +2,6 @@ mod avm; mod context; mod deploy; mod hash; -mod hasher; mod history; mod initializer; mod key;