@@ -207,7 +207,8 @@ pub fn hash_salt_dg1_private_nullifier<let N: u32>(
207207 for i in 0 ..((N + 30 ) / 31 ) {
208208 result [1 + i ] = packed_dg1 [i ];
209209 }
210- result [1 + ((N + 30 ) / 31 )] = private_nullifier ;
210+ // Store private_nullifier in the last field position
211+ result [1 + ((N + 30 ) / 31 ) - 1 ] = private_nullifier ;
211212 Poseidon2 ::hash (result , 2 + ((N + 30 ) / 31 ))
212213}
213214
@@ -234,6 +235,8 @@ pub fn calculate_private_nullifier<let DG1: u32, let ECONTENT: u32, let SIG: u32
234235 for i in 0 ..((SIG + 30 ) / 31 ) {
235236 result [(DG1 + 30 ) / 31 + ((ECONTENT + 30 ) / 31 ) + i ] = packed_sod_sig [i ];
236237 }
238+ // Store sod_sig in the last field position
239+ result [(DG1 + 30 ) / 31 + ((ECONTENT + 30 ) / 31 ) + ((SIG + 30 ) / 31 ) - 1 ] = sod_sig ;
237240
238241 Poseidon2 ::hash (
239242 result ,
@@ -277,7 +280,8 @@ pub fn hash_salt_country_signed_attr_dg1_e_content_private_nullifier<let SA: u32
277280 for i in 0 ..((ECONTENT + 30 ) / 31 ) {
278281 result [3 + (SA + 30 ) / 31 + ((DG1 + 30 ) / 31 ) + i ] = packed_e_content [i ];
279282 }
280- result [3 + (SA + 30 ) / 31 + ((DG1 + 30 ) / 31 ) + ((ECONTENT + 30 ) / 31 )] = private_nullifier ;
283+ // Store private_nullifier in the last field position
284+ result [3 + (SA + 30 ) / 31 + ((DG1 + 30 ) / 31 ) + ((ECONTENT + 30 ) / 31 ) - 1 ] = private_nullifier ;
281285
282286 Poseidon2 ::hash (
283287 result ,
@@ -286,7 +290,7 @@ pub fn hash_salt_country_signed_attr_dg1_e_content_private_nullifier<let SA: u32
286290}
287291
288292// Returns the merkle root of the tree from the provided leaf, index and hash_path, using the Poseidon2 hash function
289- // Arity is expected to be 2 and the the tree depth is equal to the hash_path array length
293+ // Arity is expected to be 2 and the tree depth is equal to the hash_path array length
290294pub fn compute_merkle_root <let N : u32 >(leaf : Field , index : Field , hash_path : [Field ; N ]) -> Field {
291295 let index_bits : [u1 ; N ] = index .to_le_bits ();
292296 let mut current = leaf ;
0 commit comments