@@ -276,12 +276,57 @@ void test_norm_util_helpers(void) {
276
276
secp256k1_scalar_set_int (& res , 256 ); CHECK (secp256k1_scalar_eq (& res , & r_pows [3 ]));
277
277
}
278
278
279
+ void norm_arg_test (unsigned int n , unsigned int m ) {
280
+ secp256k1_scalar n_vec [64 ], l_vec [64 ], c_vec [64 ];
281
+ secp256k1_scalar r , q ;
282
+ secp256k1_ge commit ;
283
+ size_t i , plen ;
284
+ int res ;
285
+ secp256k1_bulletproofs_generators * gs = secp256k1_bulletproofs_generators_create (ctx , n + m );
286
+ secp256k1_scratch * scratch = secp256k1_scratch_space_create (ctx , 1000 * 1000 ); /* shouldn't need much */
287
+ unsigned char proof [1000 ], transcript32 [32 ];
288
+ for (i = 0 ; i < 32 ; i ++ ) {
289
+ transcript32 [i ] = i ;
290
+ }
291
+ random_scalar_order (& r );
292
+ secp256k1_scalar_sqr (& q , & r );
293
+
294
+ for (i = 0 ; i < n ; i ++ ) {
295
+ random_scalar_order (& n_vec [i ]);
296
+ }
297
+
298
+ for (i = 0 ; i < m ; i ++ ) {
299
+ random_scalar_order (& l_vec [i ]);
300
+ random_scalar_order (& c_vec [i ]);
301
+ }
302
+
303
+ res = secp256k1_bulletproofs_commit (ctx , scratch , & commit , gs , n_vec , n , l_vec , m , c_vec , m , & q );
304
+ CHECK (res == 1 );
305
+ res = secp256k1_bulletproofs_pp_rangeproof_norm_product_prove (ctx , scratch , proof , & plen , transcript32 , & r , gs , n_vec , n , l_vec , m , c_vec , m , & commit );
306
+ CHECK (res == 1 );
307
+
308
+ for (i = 0 ; i < 32 ; i ++ ) {
309
+ transcript32 [i ] = i ;
310
+ }
311
+
312
+ res = secp256k1_bulletproofs_pp_rangeproof_norm_product_verify (ctx , scratch , proof , plen , transcript32 , & r , gs , n , c_vec , m , & commit );
313
+ CHECK (res == 1 );
314
+ }
315
+
279
316
void run_bulletproofs_tests (void ) {
280
317
test_log_exp ();
281
318
test_norm_util_helpers ();
282
319
test_bulletproofs_generators_api ();
283
320
test_bulletproofs_generators_fixed ();
284
321
test_bulletproofs_rangeproof_uncompressed_api ();
322
+
323
+ norm_arg_test (1 , 1 );
324
+ norm_arg_test (1 , 64 );
325
+ norm_arg_test (64 , 1 );
326
+ norm_arg_test (32 , 32 );
327
+ norm_arg_test (32 , 64 );
328
+ norm_arg_test (64 , 32 );
329
+ norm_arg_test (64 , 64 );
285
330
}
286
331
287
332
#endif
0 commit comments