@@ -22,7 +22,8 @@ static void test_bulletproofs_generators_api(void) {
22
22
23
23
secp256k1_bulletproofs_generators * gens ;
24
24
secp256k1_bulletproofs_generators * gens_orig ;
25
- unsigned char gens_ser [330 - 33 ];
25
+ enum { N_GENS = 10 , GENS_SER_SIZE = (N_GENS - 1 ) * 33 };
26
+ unsigned char gens_ser [GENS_SER_SIZE ];
26
27
size_t len = sizeof (gens_ser );
27
28
28
29
int32_t ecount = 0 ;
@@ -31,12 +32,13 @@ static void test_bulletproofs_generators_api(void) {
31
32
secp256k1_context_set_illegal_callback (none , counting_illegal_callback_fn , & ecount );
32
33
33
34
/* Create */
34
- gens = secp256k1_bulletproofs_generators_create (none , 10 );
35
+ gens = secp256k1_bulletproofs_generators_create (none , N_GENS );
35
36
CHECK (gens != NULL && ecount == 0 );
36
37
gens_orig = gens ; /* Preserve for round-trip test */
37
38
38
39
/* Serialize */
39
40
ecount = 0 ;
41
+ CHECK (secp256k1_bulletproofs_generators_serialize (none , gens , gens_ser , & len ));
40
42
CHECK (!secp256k1_bulletproofs_generators_serialize (none , NULL , gens_ser , & len ));
41
43
CHECK (ecount == 1 );
42
44
CHECK (!secp256k1_bulletproofs_generators_serialize (none , gens , NULL , & len ));
@@ -50,7 +52,7 @@ static void test_bulletproofs_generators_api(void) {
50
52
len = sizeof (gens_ser );
51
53
{
52
54
/* Output buffer can be greater than minimum needed */
53
- unsigned char gens_ser_tmp [331 ];
55
+ unsigned char gens_ser_tmp [GENS_SER_SIZE + 1 ];
54
56
size_t len_tmp = sizeof (gens_ser_tmp );
55
57
CHECK (secp256k1_bulletproofs_generators_serialize (none , gens , gens_ser_tmp , & len_tmp ));
56
58
CHECK (len_tmp == sizeof (gens_ser_tmp ) - 1 );
0 commit comments