26 unsigned char xy_sk[32];
27 unsigned char buf32[32];
28 unsigned char ones32[32];
29 unsigned char zeros64[64] = { 0 };
38 secp256k1_testrand256(sk);
40 secp256k1_testrand256(xy_sk);
54 memset(&pk, 0,
sizeof(pk));
63 CHECK(secp256k1_memcmp_var(&pk, &xonly_pk,
sizeof(pk)) == 0);
64 CHECK(pk_parity == 0);
71 CHECK(secp256k1_memcmp_var(&xonly_pk, &pk,
sizeof(xonly_pk)) != 0);
72 CHECK(pk_parity == 1);
73 secp256k1_pubkey_load(ctx, &pk1, &pk);
75 CHECK(secp256k1_fe_equal(&pk1.
x, &pk2.
x) == 1);
76 secp256k1_fe_negate(&y, &pk2.
y, 1);
77 CHECK(secp256k1_fe_equal(&pk1.
y, &y) == 1);
84 CHECK(secp256k1_memcmp_var(buf32, zeros64, 32) == 0);
90 memset(&pk_tmp, 0,
sizeof(pk_tmp));
107 CHECK(secp256k1_memcmp_var(&xonly_pk, &xonly_pk_tmp,
sizeof(xonly_pk)) == 0);
110 memset(&xonly_pk, 1,
sizeof(xonly_pk));
113 CHECK(secp256k1_memcmp_var(&xonly_pk, zeros64,
sizeof(xonly_pk)) == 0);
114 memset(&xonly_pk, 1,
sizeof(xonly_pk));
117 CHECK(secp256k1_memcmp_var(&xonly_pk, zeros64,
sizeof(xonly_pk)) == 0);
121 for (i = 0; i <
count; i++) {
122 unsigned char rand33[33];
123 secp256k1_testrand256(&rand33[1]);
126 memset(&xonly_pk, 1,
sizeof(xonly_pk));
128 CHECK(secp256k1_memcmp_var(&xonly_pk, zeros64,
sizeof(xonly_pk)) == 0);
141 unsigned char pk1_ser[32] = {
142 0x58, 0x84, 0xb3, 0xa2, 0x4b, 0x97, 0x37, 0x88, 0x92, 0x38, 0xa6, 0x26, 0x62, 0x52, 0x35, 0x11,
143 0xd0, 0x9a, 0xa1, 0x1b, 0x80, 0x0b, 0x5e, 0x93, 0x80, 0x26, 0x11, 0xef, 0x67, 0x4b, 0xd9, 0x23
145 const unsigned char pk2_ser[32] = {
146 0xde, 0x36, 0x0e, 0x87, 0x59, 0x8f, 0x3c, 0x01, 0x36, 0x2a, 0x2a, 0xb8, 0xc6, 0xf4, 0x5e, 0x4d,
147 0xb2, 0xc2, 0xd5, 0x03, 0xa7, 0xf9, 0xf1, 0x4f, 0xa8, 0xfa, 0x95, 0xa8, 0xe9, 0x69, 0x76, 0x1c
166 memset(&pk1, 0,
sizeof(pk1));
178 unsigned char zeros64[64] = { 0 };
179 unsigned char overflows[32];
180 unsigned char sk[32];
185 unsigned char tweak[32];
193 memset(overflows, 0xff,
sizeof(overflows));
194 secp256k1_testrand256(tweak);
195 secp256k1_testrand256(sk);
210 CHECK(secp256k1_memcmp_var(&output_pk, zeros64,
sizeof(output_pk)) == 0);
214 CHECK(secp256k1_memcmp_var(&output_pk, zeros64,
sizeof(output_pk)) == 0);
218 CHECK(secp256k1_memcmp_var(&output_pk, zeros64,
sizeof(output_pk)) == 0);
224 for (i = 0; i <
count; i++) {
228 secp256k1_scalar_set_b32(&scalar_tweak, sk, NULL);
229 secp256k1_scalar_negate(&scalar_tweak, &scalar_tweak);
230 secp256k1_scalar_get_b32(tweak, &scalar_tweak);
233 CHECK(secp256k1_memcmp_var(&output_pk, zeros64,
sizeof(output_pk)) == 0);
237 memset(&internal_xonly_pk, 0,
sizeof(internal_xonly_pk));
238 secp256k1_testrand256(tweak);
242 CHECK(secp256k1_memcmp_var(&output_pk, zeros64,
sizeof(output_pk)) == 0);
250 unsigned char zeros64[64] = { 0 };
251 unsigned char overflows[32];
252 unsigned char sk[32];
257 unsigned char output_pk32[32];
258 unsigned char buf32[32];
260 unsigned char tweak[32];
267 memset(overflows, 0xff,
sizeof(overflows));
268 secp256k1_testrand256(tweak);
269 secp256k1_testrand256(sk);
292 memset(tweak, 1,
sizeof(tweak));
308 CHECK(secp256k1_memcmp_var(&output_pk, zeros64,
sizeof(output_pk)) == 0);
350 unsigned char sk[32];
351 unsigned char sk_tmp[32];
352 unsigned char zeros96[96] = { 0 };
353 unsigned char overflows[32];
357 int pk_parity, pk_parity_tmp;
366 CHECK(
sizeof(zeros96) ==
sizeof(keypair));
367 memset(overflows, 0xFF,
sizeof(overflows));
371 secp256k1_testrand256(sk);
373 CHECK(secp256k1_memcmp_var(zeros96, &keypair,
sizeof(keypair)) != 0);
376 CHECK(secp256k1_memcmp_var(zeros96, &keypair,
sizeof(keypair)) != 0);
381 CHECK(secp256k1_memcmp_var(zeros96, &keypair,
sizeof(keypair)) == 0);
386 CHECK(secp256k1_memcmp_var(zeros96, &keypair,
sizeof(keypair)) == 0);
391 CHECK(secp256k1_memcmp_var(zeros96, &keypair,
sizeof(keypair)) == 0);
393 CHECK(secp256k1_memcmp_var(zeros96, &keypair,
sizeof(keypair)) == 0);
397 secp256k1_testrand256(sk);
404 CHECK(secp256k1_memcmp_var(zeros96, &pk,
sizeof(pk)) == 0);
407 memset(&keypair, 0,
sizeof(keypair));
409 CHECK(secp256k1_memcmp_var(zeros96, &pk,
sizeof(pk)) == 0);
415 CHECK(secp256k1_memcmp_var(&pk, &pk_tmp,
sizeof(pk)) == 0);
419 secp256k1_testrand256(sk);
427 CHECK(secp256k1_memcmp_var(zeros96, &xonly_pk,
sizeof(xonly_pk)) == 0);
431 memset(&keypair, 0,
sizeof(keypair));
433 CHECK(secp256k1_memcmp_var(zeros96, &xonly_pk,
sizeof(xonly_pk)) == 0);
441 CHECK(secp256k1_memcmp_var(&xonly_pk, &xonly_pk_tmp,
sizeof(pk)) == 0);
442 CHECK(pk_parity == pk_parity_tmp);
446 secp256k1_testrand256(sk);
453 CHECK(secp256k1_memcmp_var(zeros96, sk_tmp,
sizeof(sk_tmp)) == 0);
458 CHECK(secp256k1_memcmp_var(sk, sk_tmp,
sizeof(sk_tmp)) == 0);
462 memset(&keypair, 0,
sizeof(keypair));
464 CHECK(secp256k1_memcmp_var(zeros96, sk_tmp,
sizeof(sk_tmp)) == 0);
473 unsigned char sk[32];
475 unsigned char overflows[32];
476 unsigned char zeros96[96] = { 0 };
477 unsigned char tweak[32];
484 CHECK(
sizeof(zeros96) ==
sizeof(keypair));
485 secp256k1_testrand256(sk);
486 secp256k1_testrand256(tweak);
487 memset(overflows, 0xFF, 32);
500 CHECK(secp256k1_memcmp_var(&keypair, zeros96,
sizeof(keypair)) != 0);
505 CHECK(secp256k1_memcmp_var(&keypair, zeros96,
sizeof(keypair)) == 0);
512 for (i = 0; i <
count; i++) {
515 secp256k1_testrand256(sk);
517 memcpy(&keypair_tmp, &keypair,
sizeof(keypair));
520 secp256k1_scalar_set_b32(&scalar_tweak, sk, NULL);
521 secp256k1_scalar_negate(&scalar_tweak, &scalar_tweak);
522 secp256k1_scalar_get_b32(tweak, &scalar_tweak);
525 CHECK(secp256k1_memcmp_var(&keypair, zeros96,
sizeof(keypair)) == 0
526 || secp256k1_memcmp_var(&keypair_tmp, zeros96,
sizeof(keypair_tmp)) == 0);
530 memset(&keypair, 0,
sizeof(keypair));
531 secp256k1_testrand256(tweak);
535 CHECK(secp256k1_memcmp_var(&keypair, zeros96,
sizeof(keypair)) == 0);
549 for (i = 0; i <
count; i++) {
554 unsigned char pk32[32];
555 unsigned char sk32[32];
558 secp256k1_testrand256(tweak);
570 CHECK(secp256k1_memcmp_var(&output_pk_xy, &output_pk_expected,
sizeof(output_pk_xy)) == 0);
575 CHECK(secp256k1_memcmp_var(&output_pk_xy, &output_pk_expected,
sizeof(output_pk_xy)) == 0);