349 {
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;
358 int ecount;
365
366 CHECK(
sizeof(zeros96) ==
sizeof(keypair));
367 memset(overflows, 0xFF,
sizeof(overflows));
368
369
370 ecount = 0;
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);
388
389
391 CHECK(secp256k1_memcmp_var(zeros96, &keypair,
sizeof(keypair)) == 0);
393 CHECK(secp256k1_memcmp_var(zeros96, &keypair,
sizeof(keypair)) == 0);
394
395
396 ecount = 0;
397 secp256k1_testrand256(sk);
404 CHECK(secp256k1_memcmp_var(zeros96, &pk,
sizeof(pk)) == 0);
405
406
407 memset(&keypair, 0,
sizeof(keypair));
409 CHECK(secp256k1_memcmp_var(zeros96, &pk,
sizeof(pk)) == 0);
410
411
415 CHECK(secp256k1_memcmp_var(&pk, &pk_tmp,
sizeof(pk)) == 0);
416
418 ecount = 0;
419 secp256k1_testrand256(sk);
427 CHECK(secp256k1_memcmp_var(zeros96, &xonly_pk,
sizeof(xonly_pk)) == 0);
428
429
431 memset(&keypair, 0,
sizeof(keypair));
433 CHECK(secp256k1_memcmp_var(zeros96, &xonly_pk,
sizeof(xonly_pk)) == 0);
435
441 CHECK(secp256k1_memcmp_var(&xonly_pk, &xonly_pk_tmp,
sizeof(pk)) == 0);
442 CHECK(pk_parity == pk_parity_tmp);
443
444
445 ecount = 0;
446 secp256k1_testrand256(sk);
453 CHECK(secp256k1_memcmp_var(zeros96, sk_tmp,
sizeof(sk_tmp)) == 0);
454
455
458 CHECK(secp256k1_memcmp_var(sk, sk_tmp,
sizeof(sk_tmp)) == 0);
459
460
461
462 memset(&keypair, 0,
sizeof(keypair));
464 CHECK(secp256k1_memcmp_var(zeros96, sk_tmp,
sizeof(sk_tmp)) == 0);
465
470}
void verify(const char *msg, const T &a, const S &b)
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
#define SECP256K1_CONTEXT_SIGN
SECP256K1_API const secp256k1_context * secp256k1_context_no_precomp
SECP256K1_API void secp256k1_context_set_error_callback(secp256k1_context *ctx, void(*fun)(const char *message, void *data), const void *data) SECP256K1_ARG_NONNULL(1)
SECP256K1_API void secp256k1_context_set_illegal_callback(secp256k1_context *ctx, void(*fun)(const char *message, void *data), const void *data) SECP256K1_ARG_NONNULL(1)
#define SECP256K1_CONTEXT_NONE
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
SECP256K1_API secp256k1_context * secp256k1_context_clone(const secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT
#define SECP256K1_CONTEXT_VERIFY
memset(pInfo->slotDescription, ' ', 64)