Skip to content

Commit

Permalink
feat: more efficient compute_l2_to_l1_hash (#11036)
Browse files Browse the repository at this point in the history
This avoids unnecessary tracking of the length of the `BoundedVec`.
  • Loading branch information
TomAFrench authored Jan 6, 2025
1 parent e076000 commit 60d43fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions noir-projects/noir-protocol-circuits/crates/types/src/hash.nr
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,19 @@ pub fn compute_l2_to_l1_hash(
rollup_version_id: Field,
chain_id: Field,
) -> Field {
let mut bytes: BoundedVec<u8, 160> = BoundedVec::new();
let mut bytes: [u8; 160] = std::mem::zeroed();

let inputs =
[contract_address.to_field(), rollup_version_id, recipient.to_field(), chain_id, content];
for i in 0..inputs.len() {
for i in 0..5 {
// TODO are bytes be in fr.to_buffer() ?
let item_bytes: [u8; 32] = inputs[i].to_be_bytes();
for j in 0..32 {
bytes.push(item_bytes[j]);
bytes[32 * i + j] = item_bytes[j];
}
}

sha256_to_field(bytes.storage())
sha256_to_field(bytes)
}

pub fn silo_l2_to_l1_message(
Expand Down

0 comments on commit 60d43fd

Please sign in to comment.