7 #ifndef SECP256K1_MODULE_EXTRAKEYS_TESTS_H 8 #define SECP256K1_MODULE_EXTRAKEYS_TESTS_H 10 #include "../../../include/secp256k1_extrakeys.h" 24 unsigned char xy_sk[32];
25 unsigned char buf32[32];
26 unsigned char ones32[32];
27 unsigned char zeros64[64] = { 0 };
36 memset(ones32, 0xFF, 32);
49 memset(&
pk, 0,
sizeof(
pk));
54 memset(sk, 0,
sizeof(sk));
59 CHECK(pk_parity == 0);
67 CHECK(pk_parity == 1);
85 memset(&pk_tmp, 0,
sizeof(pk_tmp));
105 memset(&xonly_pk, 1,
sizeof(xonly_pk));
109 memset(&xonly_pk, 1,
sizeof(xonly_pk));
116 for (i = 0; i <
COUNT; i++) {
117 unsigned char rand33[33];
121 memset(&xonly_pk, 1,
sizeof(xonly_pk));
132 unsigned char pk1_ser[32] = {
133 0x58, 0x84, 0xb3, 0xa2, 0x4b, 0x97, 0x37, 0x88, 0x92, 0x38, 0xa6, 0x26, 0x62, 0x52, 0x35, 0x11,
134 0xd0, 0x9a, 0xa1, 0x1b, 0x80, 0x0b, 0x5e, 0x93, 0x80, 0x26, 0x11, 0xef, 0x67, 0x4b, 0xd9, 0x23
136 const unsigned char pk2_ser[32] = {
137 0xde, 0x36, 0x0e, 0x87, 0x59, 0x8f, 0x3c, 0x01, 0x36, 0x2a, 0x2a, 0xb8, 0xc6, 0xf4, 0x5e, 0x4d,
138 0xb2, 0xc2, 0xd5, 0x03, 0xa7, 0xf9, 0xf1, 0x4f, 0xa8, 0xfa, 0x95, 0xa8, 0xe9, 0x69, 0x76, 0x1c
158 memset(&pk1, 0,
sizeof(pk1));
168 unsigned char zeros64[64] = { 0 };
169 unsigned char overflows[32];
170 unsigned char sk[32];
175 unsigned char tweak[32];
182 memset(overflows, 0xff,
sizeof(overflows));
213 for (i = 0; i <
COUNT; i++) {
226 memset(&internal_xonly_pk, 0,
sizeof(internal_xonly_pk));
235 unsigned char zeros64[64] = { 0 };
236 unsigned char overflows[32];
237 unsigned char sk[32];
242 unsigned char output_pk32[32];
243 unsigned char buf32[32];
245 unsigned char tweak[32];
251 memset(overflows, 0xff,
sizeof(overflows));
276 memset(tweak, 1,
sizeof(tweak));
301 unsigned char sk[32];
303 unsigned char pk_serialized[32];
312 memset(tweak[i], i + 1,
sizeof(tweak[i]));
330 unsigned char sk[32];
331 unsigned char sk_tmp[32];
332 unsigned char zeros96[96] = { 0 };
333 unsigned char overflows[32];
337 int pk_parity, pk_parity_tmp;
343 CHECK(
sizeof(zeros96) ==
sizeof(keypair));
344 memset(overflows, 0xFF,
sizeof(overflows));
384 memset(&keypair, 0,
sizeof(keypair));
408 memset(&keypair, 0,
sizeof(keypair));
419 CHECK(pk_parity == pk_parity_tmp);
439 memset(&keypair, 0,
sizeof(keypair));
448 unsigned char sk[32];
450 unsigned char overflows[32];
451 unsigned char zeros96[96] = { 0 };
452 unsigned char tweak[32];
458 CHECK(
sizeof(zeros96) ==
sizeof(keypair));
461 memset(overflows, 0xFF, 32);
486 for (i = 0; i <
COUNT; i++) {
491 memcpy(&keypair_tmp, &keypair,
sizeof(keypair));
504 memset(&keypair, 0,
sizeof(keypair));
512 memset(&keypair, 0, 32);
517 memset(&keypair.
data[32], 0, 64);
523 for (i = 0; i <
COUNT; i++) {
528 unsigned char pk32[32];
529 unsigned char sk32[32];
This field implementation represents the value as 10 uint32_t limbs in base 2^26. ...
static void secp256k1_testrand256(unsigned char *b32)
Generate a pseudorandom 32-byte array.
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)
Set a callback function to be called when an illegal argument is passed to an API call...
static int secp256k1_fe_equal(const secp256k1_fe *a, const secp256k1_fe *b)
Determine whether two field elements are equal.
static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the complement of a scalar (modulo the group order).
static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *bin, int *overflow)
Set a scalar from a big endian byte array.
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)
Compute the public key for a secret key.
static secp256k1_context * STATIC_CTX
Opaque data structure that holds a parsed and valid "x-only" public key.
static secp256k1_context * CTX
#define CHECK(cond)
Unconditional failure on condition failure.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_parse(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *input, size_t inputlen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Parse a variable-length public key into the pubkey object.
A group element in affine coordinates on the secp256k1 curve, or occasionally on an isomorphic curve ...
A scalar modulo the group order of the secp256k1 curve.
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)
Set a callback function to be called when an internal consistency check fails.
Opaque data structure that holds a keypair consisting of a secret and a public key.
static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar *a)
Convert a scalar to a byte array.
static SECP256K1_INLINE int secp256k1_memcmp_var(const void *s1, const void *s2, size_t n)
Semantics like memcmp.
#define secp256k1_fe_negate(r, a, m)
Negate a field element.
static int secp256k1_pubkey_load(const secp256k1_context *ctx, secp256k1_ge *ge, const secp256k1_pubkey *pubkey)
static void counting_illegal_callback_fn(const char *str, void *data)
#define SECP256K1_TAG_PUBKEY_EVEN
Prefix byte used to tag various encoded curvepoints for specific purposes.
Opaque data structure that holds a parsed and valid public key.