@@ -95,16 +95,15 @@ impl<P: Pairing, D: Digest + Send + Sync> HolographicHomomorphicSignatureScheme<
9595 //TODO: allocationn_ids (tag in this case) must be unpredictable
9696 // some random value has to be appended during initialization, prior
9797 // to the precompute in this function
98- fn precompute < R : Rng > (
98+ fn precompute (
9999 _pp : & Self :: Parameters ,
100- rng : & mut R ,
100+ tag : P :: ScalarField ,
101101 n : usize ,
102102 ) -> Result < ( P :: G1 , P :: ScalarField ) , Box < dyn Error > > {
103- let allocation_id = P :: ScalarField :: rand ( rng) ;
104103 let hash_vec = ( 0 ..n)
105104 . into_iter ( )
106105 . map ( |lane_id| {
107- let mut message_data = allocation_id . into_bigint ( ) . to_bytes_be ( ) ;
106+ let mut message_data = tag . into_bigint ( ) . to_bytes_be ( ) ;
108107 message_data. append ( & mut lane_id. to_be_bytes ( ) . to_vec ( ) ) ;
109108 hash_to_g1 :: < P , D > ( message_data)
110109 } )
@@ -113,7 +112,7 @@ impl<P: Pairing, D: Digest + Send + Sync> HolographicHomomorphicSignatureScheme<
113112 for hash_val in hash_vec {
114113 allocation_hash += hash_val;
115114 }
116- Ok ( ( allocation_hash, allocation_id ) )
115+ Ok ( ( allocation_hash, tag ) )
117116 }
118117
119118 fn keygen < R : Rng > (
@@ -212,6 +211,7 @@ impl<P: Pairing, D: Digest + Send + Sync> HolographicHomomorphicSignatureScheme<
212211
213212#[ cfg( test) ]
214213mod tests {
214+
215215 use super :: * ;
216216 use ark_bn254:: Bn254 ;
217217 //we could also use the ark_bls12_381 curve which was intended to substitute this one:
@@ -270,9 +270,10 @@ mod tests {
270270 #[ test]
271271 fn test_precompute ( ) {
272272 let params = & * PARAMS ;
273- let mut rng = test_rng ( ) ;
273+
274+ let allocation_id = ark_bn254:: Fr :: from_be_bytes_mod_order ( & Hasher :: digest ( & b"test" ) ) ;
274275 let ( hash_aggregate, alloc_id) =
275- NCS :: < Curve , Hasher > :: precompute ( & params, & mut rng , N ) . expect ( "Precompute failed" ) ;
276+ NCS :: < Curve , Hasher > :: precompute ( & params, allocation_id , N ) . expect ( "Precompute failed" ) ;
276277
277278 println ! ( "Precomputed Hash Aggregate: {:?}" , hash_aggregate) ;
278279 println ! ( "allocation_id {:?}" , alloc_id) ;
@@ -284,8 +285,9 @@ mod tests {
284285 let params = & * PARAMS ;
285286
286287 // Precompute the hash aggregate and allocation ID
288+ let allocation_id = ark_bn254:: Fr :: from_be_bytes_mod_order ( & Hasher :: digest ( & b"test" ) ) ;
287289 let ( _, allocation_id) =
288- NCS :: < Curve , Hasher > :: precompute ( & params, & mut rng , N ) . expect ( "Precompute failed" ) ;
290+ NCS :: < Curve , Hasher > :: precompute ( & params, allocation_id , N ) . expect ( "Precompute failed" ) ;
289291
290292 // Generate messages for each lane/index
291293 let messages: Vec < Fr > = ( 0 ..N ) . map ( |_| Fr :: rand ( & mut rng) ) . collect ( ) ;
@@ -326,8 +328,9 @@ mod tests {
326328 let messages: Vec < Fr > = ( 0 ..N ) . map ( |_| Fr :: rand ( & mut rng) ) . collect ( ) ;
327329
328330 // Precompute the hash aggregate and allocation ID
331+ let allocation_id = ark_bn254:: Fr :: from_be_bytes_mod_order ( & Hasher :: digest ( & b"test" ) ) ;
329332 let ( hash_aggregate, allocation_id) =
330- NCS :: < Curve , Hasher > :: precompute ( & params, & mut rng , N ) . expect ( "Precompute failed" ) ;
333+ NCS :: < Curve , Hasher > :: precompute ( & params, allocation_id , N ) . expect ( "Precompute failed" ) ;
331334
332335 // Generate individual signatures for each message
333336 let mut signatures: Vec < _ > = ( 0 ..N )
0 commit comments