@@ -139,54 +139,63 @@ static int secp256k1_silentpayments_create_output_pubkey(const secp256k1_context
139
139
return ret ;
140
140
}
141
141
142
- static void print_hex (unsigned char * data , size_t size ) {
142
+ /* static void print_hex(unsigned char* data, size_t size) {
143
143
size_t i;
144
144
printf("0x");
145
145
for (i = 0; i < size; i++) {
146
146
printf("%02x", data[i]);
147
147
}
148
148
printf("\n");
149
- }
149
+ } */
150
150
151
151
int secp256k1_silentpayments_test_outputs (
152
152
const secp256k1_context * ctx ,
153
153
const secp256k1_silentpayments_recipient * recipients ,
154
- size_t n_recipients
154
+ size_t n_recipients ,
155
+ unsigned char * out_pubkeys ,
156
+ size_t n_out_pubkeys
155
157
) {
156
158
size_t i ;
157
159
int ret = 1 ;
158
160
161
+ VERIFY_CHECK (n_out_pubkeys == 66 * n_recipients );
159
162
160
163
for (i = 0 ; i < n_recipients ; i ++ ) {
161
164
ARG_CHECK (recipients [i ].index == i );
162
165
}
163
166
167
+ /* Initialize out_pubkeys to zero */
168
+ memset (out_pubkeys , 0 , n_out_pubkeys );
169
+
164
170
for (i = 0 ; i < n_recipients ; i ++ ) {
165
- unsigned char compressed_scan_pubkey [33 ];
166
- unsigned char compressed_spend_pubkey [33 ];
171
+ unsigned char * compressed_scan_pubkey = & out_pubkeys [i * 66 ];
172
+ unsigned char * compressed_spend_pubkey = & out_pubkeys [i * 66 + 33 ];
173
+
167
174
size_t len ;
168
175
169
- printf ("index: %ld\n" , recipients [i ].index );
176
+ // printf("index: %ld\n", recipients[i].index);
170
177
171
178
/* Serialize pubkey1 in a compressed form (33 bytes), should always return 1 */
172
- len = sizeof ( compressed_scan_pubkey ) ;
179
+ len = 33 ;
173
180
ret = secp256k1_ec_pubkey_serialize (ctx , compressed_scan_pubkey , & len , & recipients [i ].scan_pubkey , SECP256K1_EC_COMPRESSED );
174
181
/* Should be the same size as the size of the output, because we passed a 33 byte array. */
175
- VERIFY_CHECK (len == sizeof ( compressed_scan_pubkey ) );
182
+ VERIFY_CHECK (len == 33 );
176
183
177
- len = sizeof ( compressed_spend_pubkey ) ;
184
+ len = 33 ;
178
185
ret = secp256k1_ec_pubkey_serialize (ctx , compressed_spend_pubkey , & len , & recipients [i ].spend_pubkey , SECP256K1_EC_COMPRESSED );
179
186
/* Should be the same size as the size of the output, because we passed a 33 byte array. */
180
- VERIFY_CHECK (len == sizeof ( compressed_spend_pubkey ) );
187
+ VERIFY_CHECK (len == 33 );
181
188
182
- printf ("scan_pubkey: " );
183
- print_hex (compressed_scan_pubkey , sizeof ( compressed_scan_pubkey ) );
189
+ // printf("scan_pubkey: ");
190
+ // print_hex(compressed_scan_pubkey, 33 );
184
191
185
- printf ("spend_pubkey: " );
186
- print_hex (compressed_spend_pubkey , sizeof ( compressed_spend_pubkey ) );
192
+ // printf("spend_pubkey: ");
193
+ // print_hex(compressed_spend_pubkey, 33 );
187
194
188
195
}
189
196
197
+ VERIFY_CHECK ((i * 66 ) == n_out_pubkeys );
198
+
190
199
return ret ;
191
200
}
192
201
0 commit comments