@@ -207,7 +207,8 @@ pub fn hash_salt_dg1_private_nullifier<let N: u32>(
207
207
for i in 0 ..((N + 30 ) / 31 ) {
208
208
result [1 + i ] = packed_dg1 [i ];
209
209
}
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 ;
211
212
Poseidon2 ::hash (result , 2 + ((N + 30 ) / 31 ))
212
213
}
213
214
@@ -234,6 +235,8 @@ pub fn calculate_private_nullifier<let DG1: u32, let ECONTENT: u32, let SIG: u32
234
235
for i in 0 ..((SIG + 30 ) / 31 ) {
235
236
result [(DG1 + 30 ) / 31 + ((ECONTENT + 30 ) / 31 ) + i ] = packed_sod_sig [i ];
236
237
}
238
+ // Store sod_sig in the last field position
239
+ result [(DG1 + 30 ) / 31 + ((ECONTENT + 30 ) / 31 ) + ((SIG + 30 ) / 31 ) - 1 ] = sod_sig ;
237
240
238
241
Poseidon2 ::hash (
239
242
result ,
@@ -277,7 +280,8 @@ pub fn hash_salt_country_signed_attr_dg1_e_content_private_nullifier<let SA: u32
277
280
for i in 0 ..((ECONTENT + 30 ) / 31 ) {
278
281
result [3 + (SA + 30 ) / 31 + ((DG1 + 30 ) / 31 ) + i ] = packed_e_content [i ];
279
282
}
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 ;
281
285
282
286
Poseidon2 ::hash (
283
287
result ,
@@ -286,7 +290,7 @@ pub fn hash_salt_country_signed_attr_dg1_e_content_private_nullifier<let SA: u32
286
290
}
287
291
288
292
// 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
290
294
pub fn compute_merkle_root <let N : u32 >(leaf : Field , index : Field , hash_path : [Field ; N ]) -> Field {
291
295
let index_bits : [u1 ; N ] = index .to_le_bits ();
292
296
let mut current = leaf ;
0 commit comments