@@ -27,11 +27,19 @@ pub fn compute_swap_public_content_hash(
27
27
secret_hash_for_L1_to_l2_message .to_be_bytes ();
28
28
let caller_on_L1_bytes : [u8 ; 32 ] = caller_on_L1 .to_field ().to_be_bytes ();
29
29
30
- // function selector: 0xf18186d8 keccak256("swap_public(address,uint256,uint24,address,uint256,bytes32,bytes32,address)")
31
- hash_bytes [0 ] = 0xf1 ;
32
- hash_bytes [1 ] = 0x81 ;
33
- hash_bytes [2 ] = 0x86 ;
34
- hash_bytes [3 ] = 0xd8 ;
30
+ // The purpose of including the following selector is to make the message unique to that specific call. Note that
31
+ // it has nothing to do with calling the function.
32
+ let selector = comptime {
33
+ std::hash:: keccak256 (
34
+ "swap_public(address,uint256,uint24,address,uint256,bytes32,bytes32,address)" .as_bytes (),
35
+ 75 ,
36
+ )
37
+ };
38
+
39
+ hash_bytes [0 ] = selector [0 ];
40
+ hash_bytes [1 ] = selector [1 ];
41
+ hash_bytes [2 ] = selector [2 ];
42
+ hash_bytes [3 ] = selector [3 ];
35
43
36
44
for i in 0 ..32 {
37
45
hash_bytes [i + 4 ] = input_token_portal_bytes [i ];
@@ -73,11 +81,19 @@ pub fn compute_swap_private_content_hash(
73
81
secret_hash_for_L1_to_l2_message .to_be_bytes ();
74
82
let caller_on_L1_bytes : [u8 ; 32 ] = caller_on_L1 .to_field ().to_be_bytes ();
75
83
76
- // function selector: 0x84e55078 keccak256("swap_private(address,uint256,uint24,address,uint256,bytes32,address)")
77
- hash_bytes [0 ] = 0x84 ;
78
- hash_bytes [1 ] = 0xe5 ;
79
- hash_bytes [2 ] = 0x50 ;
80
- hash_bytes [3 ] = 0x78 ;
84
+ // The purpose of including the following selector is to make the message unique to that specific call. Note that
85
+ // it has nothing to do with calling the function.
86
+ let selector = comptime {
87
+ std::hash:: keccak256 (
88
+ "swap_private(address,uint256,uint24,address,uint256,bytes32,address)" .as_bytes (),
89
+ 68 ,
90
+ )
91
+ };
92
+
93
+ hash_bytes [0 ] = selector [0 ];
94
+ hash_bytes [1 ] = selector [1 ];
95
+ hash_bytes [2 ] = selector [2 ];
96
+ hash_bytes [3 ] = selector [3 ];
81
97
82
98
for i in 0 ..32 {
83
99
hash_bytes [i + 4 ] = input_token_portal_bytes [i ];
0 commit comments