7 #ifndef _SECP256K1_MODULE_ECDH_TESTS_ 8 #define _SECP256K1_MODULE_ECDH_TESTS_ 11 unsigned char s_one[32] = { 0 };
17 for (i = 0; i < 100; ++i) {
19 unsigned char s_b32[32];
20 unsigned char output_ecdh[32];
21 unsigned char output_ser[32];
22 unsigned char point_ser[33];
23 size_t point_ser_len =
sizeof(point_ser);
35 CHECK(point_ser_len ==
sizeof(point_ser));
40 CHECK(memcmp(output_ecdh, output_ser,
sizeof(output_ser)) == 0);
45 unsigned char s_zero[32] = { 0 };
46 unsigned char s_overflow[32] = {
47 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
48 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
49 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
50 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41
52 unsigned char s_rand[32] = { 0 };
53 unsigned char output[32];
void random_scalar_order(secp256k1_scalar *num)
SECP256K1_API int secp256k1_ec_pubkey_serialize(const secp256k1_context *ctx, unsigned char *output, size_t *outputlen, const secp256k1_pubkey *pubkey, unsigned int flags) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
void run_ecdh_tests(void)
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)
#define SECP256K1_EC_COMPRESSED
static void secp256k1_sha256_finalize(secp256k1_sha256_t *hash, unsigned char *out32)
static void secp256k1_sha256_write(secp256k1_sha256_t *hash, const unsigned char *data, size_t size)
void test_ecdh_generator_basepoint(void)
static secp256k1_context * ctx
static void secp256k1_sha256_initialize(secp256k1_sha256_t *hash)
static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar *a)
void test_bad_scalar(void)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdh(const secp256k1_context *ctx, unsigned char *result, const secp256k1_pubkey *pubkey, const unsigned char *privkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)