Skip to content

Commit f6de81d

Browse files
committed
making it cuter
1 parent 7bbf62d commit f6de81d

File tree

2 files changed

+26
-30
lines changed
  • noir-projects/noir-contracts/contracts
    • fee_juice_contract/src
    • token_portal_content_hash_lib/src

2 files changed

+26
-30
lines changed

noir-projects/noir-contracts/contracts/fee_juice_contract/src/lib.nr

+8-9
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@ pub fn get_bridge_gas_msg_hash(owner: AztecAddress, amount: Field) -> Field {
1111
let recipient_bytes: [u8; 32] = owner.to_field().to_be_bytes();
1212
let amount_bytes: [u8; 32] = amount.to_be_bytes();
1313

14-
for i in 0..32 {
15-
hash_bytes[i + 4] = recipient_bytes[i];
16-
hash_bytes[i + 36] = amount_bytes[i];
17-
}
18-
1914
// The purpose of including the following selector is to make the message unique to that specific call. Note that
2015
// it has nothing to do with calling the function.
2116
let selector = comptime { std::hash::keccak256("claim(bytes32,uint256)".as_bytes(), 22) };
2217

23-
hash_bytes[0] = selector[0];
24-
hash_bytes[1] = selector[1];
25-
hash_bytes[2] = selector[2];
26-
hash_bytes[3] = selector[3];
18+
for i in 0..4 {
19+
hash_bytes[i] = selector[i];
20+
}
21+
22+
for i in 0..32 {
23+
hash_bytes[i + 4] = recipient_bytes[i];
24+
hash_bytes[i + 36] = amount_bytes[i];
25+
}
2726

2827
let content_hash = sha256_to_field(hash_bytes);
2928
content_hash

noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr

+18-21
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@ pub fn get_mint_to_public_content_hash(owner: AztecAddress, amount: Field) -> Fi
99
let recipient_bytes:[u8; 32] = owner.to_field().to_be_bytes();
1010
let amount_bytes:[u8; 32] = amount.to_be_bytes();
1111

12-
for i in 0..32 {
13-
hash_bytes[i + 4] = recipient_bytes[i];
14-
hash_bytes[i + 36] = amount_bytes[i];
15-
}
16-
1712
// The purpose of including the following selector is to make the message unique to that specific call. Note that
1813
// it has nothing to do with calling the function.
1914
let selector = comptime { std::hash::keccak256("mint_to_public(bytes32,uint256)".as_bytes(), 31) };
2015

21-
hash_bytes[0] = selector[0];
22-
hash_bytes[1] = selector[1];
23-
hash_bytes[2] = selector[2];
24-
hash_bytes[3] = selector[3];
16+
for i in 0..4 {
17+
hash_bytes[i] = selector[i];
18+
}
19+
20+
for i in 0..32 {
21+
hash_bytes[i + 4] = recipient_bytes[i];
22+
hash_bytes[i + 36] = amount_bytes[i];
23+
}
2524

2625
let content_hash = sha256_to_field(hash_bytes);
2726
content_hash
@@ -37,18 +36,17 @@ pub fn get_mint_to_private_content_hash(
3736
let mut hash_bytes = [0; 36];
3837
let amount_bytes:[u8; 32] = amount.to_be_bytes();
3938

40-
for i in 0..32 {
41-
hash_bytes[i + 4] = amount_bytes[i];
42-
}
43-
4439
// The purpose of including the following selector is to make the message unique to that specific call. Note that
4540
// it has nothing to do with calling the function.
4641
let selector = comptime { std::hash::keccak256("mint_to_private(uint256)".as_bytes(), 24) };
4742

48-
hash_bytes[0] = selector[0];
49-
hash_bytes[1] = selector[1];
50-
hash_bytes[2] = selector[2];
51-
hash_bytes[3] = selector[3];
43+
for i in 0..4 {
44+
hash_bytes[i] = selector[i];
45+
}
46+
47+
for i in 0..32 {
48+
hash_bytes[i + 4] = amount_bytes[i];
49+
}
5250

5351
let content_hash = sha256_to_field(hash_bytes);
5452
content_hash
@@ -71,10 +69,9 @@ pub fn get_withdraw_content_hash(recipient: EthAddress, amount: Field, caller_on
7169
// it has nothing to do with calling the function.
7270
let selector = comptime { std::hash::keccak256("withdraw(address,uint256,address)".as_bytes(), 33) };
7371

74-
hash_bytes[0] = selector[0];
75-
hash_bytes[1] = selector[1];
76-
hash_bytes[2] = selector[2];
77-
hash_bytes[3] = selector[3];
72+
for i in 0..4 {
73+
hash_bytes[i] = selector[i];
74+
}
7875

7976
for i in 0..32 {
8077
hash_bytes[i + 4] = recipient_bytes[i];

0 commit comments

Comments
 (0)