@@ -170,11 +170,59 @@ void test_norm_util_helpers(void) {
170
170
secp256k1_scalar_set_int (& res , 256 ); CHECK (secp256k1_scalar_eq (& res , & r_pows [3 ]));
171
171
}
172
172
173
+ void norm_arg_test (unsigned int n , unsigned int m ) {
174
+ secp256k1_scalar n_vec [64 ], l_vec [64 ], c_vec [64 ];
175
+ secp256k1_scalar r , q ;
176
+ secp256k1_ge commit ;
177
+ size_t i , plen ;
178
+ int res ;
179
+ secp256k1_bulletproofs_generators * gs = secp256k1_bulletproofs_generators_create (ctx , n + m );
180
+ secp256k1_scratch * scratch = secp256k1_scratch_space_create (ctx , 1000 * 1000 ); /* shouldn't need much */
181
+ unsigned char proof [1000 ], transcript32 [32 ];
182
+ plen = 1000 ;
183
+ for (i = 0 ; i < 32 ; i ++ ) {
184
+ transcript32 [i ] = i ;
185
+ }
186
+ random_scalar_order (& r );
187
+ secp256k1_scalar_sqr (& q , & r );
188
+
189
+ for (i = 0 ; i < n ; i ++ ) {
190
+ random_scalar_order (& n_vec [i ]);
191
+ }
192
+
193
+ for (i = 0 ; i < m ; i ++ ) {
194
+ random_scalar_order (& l_vec [i ]);
195
+ random_scalar_order (& c_vec [i ]);
196
+ }
197
+
198
+ res = secp256k1_bulletproofs_commit (ctx , scratch , & commit , gs , n_vec , n , l_vec , m , c_vec , m , & q );
199
+ CHECK (res == 1 );
200
+ 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 );
201
+ CHECK (res == 1 );
202
+
203
+ for (i = 0 ; i < 32 ; i ++ ) {
204
+ transcript32 [i ] = i ;
205
+ }
206
+
207
+ res = secp256k1_bulletproofs_pp_rangeproof_norm_product_verify (ctx , scratch , proof , plen , transcript32 , & r , gs , n , c_vec , m , & commit );
208
+ CHECK (res == 1 );
209
+
210
+ secp256k1_bulletproofs_generators_destroy (ctx , gs );
211
+ }
212
+
173
213
void run_bulletproofs_tests (void ) {
174
214
test_log_exp ();
175
215
test_norm_util_helpers ();
176
216
test_bulletproofs_generators_api ();
177
217
test_bulletproofs_generators_fixed ();
218
+
219
+ norm_arg_test (1 , 1 );
220
+ norm_arg_test (1 , 64 );
221
+ norm_arg_test (64 , 1 );
222
+ norm_arg_test (32 , 32 );
223
+ norm_arg_test (32 , 64 );
224
+ norm_arg_test (64 , 32 );
225
+ norm_arg_test (64 , 64 );
178
226
}
179
227
180
228
#endif
0 commit comments