@@ -164,11 +164,56 @@ void test_norm_util_helpers(void) {
164164 secp256k1_scalar_set_int (& res , 256 ); CHECK (secp256k1_scalar_eq (& res , & r_pows [3 ]));
165165}
166166
167+ void norm_arg_test (unsigned int n , unsigned int m ) {
168+ secp256k1_scalar n_vec [64 ], l_vec [64 ], c_vec [64 ];
169+ secp256k1_scalar r , q ;
170+ secp256k1_ge commit ;
171+ size_t i , plen ;
172+ int res ;
173+ secp256k1_bulletproofs_generators * gs = secp256k1_bulletproofs_generators_create (ctx , n + m );
174+ secp256k1_scratch * scratch = secp256k1_scratch_space_create (ctx , 1000 * 1000 ); /* shouldn't need much */
175+ unsigned char proof [1000 ], transcript32 [32 ];
176+ for (i = 0 ; i < 32 ; i ++ ) {
177+ transcript32 [i ] = i ;
178+ }
179+ random_scalar_order (& r );
180+ secp256k1_scalar_sqr (& q , & r );
181+
182+ for (i = 0 ; i < n ; i ++ ) {
183+ random_scalar_order (& n_vec [i ]);
184+ }
185+
186+ for (i = 0 ; i < m ; i ++ ) {
187+ random_scalar_order (& l_vec [i ]);
188+ random_scalar_order (& c_vec [i ]);
189+ }
190+
191+ res = secp256k1_bulletproofs_commit (ctx , scratch , & commit , gs , n_vec , n , l_vec , m , c_vec , m , & q );
192+ CHECK (res == 1 );
193+ 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 );
194+ CHECK (res == 1 );
195+
196+ for (i = 0 ; i < 32 ; i ++ ) {
197+ transcript32 [i ] = i ;
198+ }
199+
200+ res = secp256k1_bulletproofs_pp_rangeproof_norm_product_verify (ctx , scratch , proof , plen , transcript32 , & r , gs , n , c_vec , m , & commit );
201+ CHECK (res == 1 );
202+ }
203+
167204void run_bulletproofs_tests (void ) {
168205 test_log_exp ();
169206 test_norm_util_helpers ();
170207 test_bulletproofs_generators_api ();
171208 test_bulletproofs_generators_fixed ();
209+
210+ norm_arg_test (1 , 1 );
211+ norm_arg_test (1 , 64 );
212+ norm_arg_test (64 , 1 );
213+ norm_arg_test (32 , 32 );
214+ norm_arg_test (32 , 64 );
215+ norm_arg_test (64 , 32 );
216+ norm_arg_test (64 , 64 );
172217}
173218
174219#endif
0 commit comments