7 #ifndef SECP256K1_MODULE_ECDH_TESTS_H 8 #define SECP256K1_MODULE_ECDH_TESTS_H 23 memcpy(output + 33, y, 32);
31 unsigned char res[32];
32 unsigned char s_one[32] = { 0 };
57 unsigned char s_one[32] = { 0 };
63 for (i = 0; i < 100; ++i) {
65 unsigned char s_b32[32];
66 unsigned char output_ecdh[65];
67 unsigned char output_ser[32];
68 unsigned char point_ser[65];
69 size_t point_ser_len =
sizeof(point_ser);
83 CHECK(memcmp(output_ecdh, point_ser, 65) == 0);
93 CHECK(memcmp(output_ecdh, output_ser, 32) == 0);
98 unsigned char s_zero[32] = { 0 };
99 unsigned char s_overflow[32] = {
100 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
101 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
102 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
103 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41
105 unsigned char s_rand[32] = { 0 };
106 unsigned char output[32];
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)
Definition: secp256k1.c:111
void test_ecdh_api(void)
Definition: tests_impl.h:27
void random_scalar_order(secp256k1_scalar *num)
Definition: tests.c:127
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)
Definition: secp256k1.c:186
Definition: secp256k1.c:52
#define SECP256K1_CONTEXT_SIGN
Definition: secp256k1.h:168
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx)
Definition: secp256k1.c:101
void run_ecdh_tests(void)
Definition: tests_impl.h:126
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)
Definition: secp256k1.c:428
#define SECP256K1_EC_UNCOMPRESSED
Definition: secp256k1.h:173
#define SECP256K1_EC_COMPRESSED
Definition: secp256k1.h:172
void test_ecdh_generator_basepoint(void)
Definition: tests_impl.h:56
static secp256k1_context * ctx
Definition: tests.c:46
#define CHECK(cond)
Definition: util.h:52
Definition: scalar_4x64.h:13
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)
Definition: secp256k1.c:120
static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar *a)
static void secp256k1_sha256_write(secp256k1_sha256 *hash, const unsigned char *data, size_t size)
std::vector< uint8_t > data
Definition: bech32.cpp:10
int ecdh_hash_function_test_fail(unsigned char *output, const unsigned char *x, const unsigned char *y, void *data)
Definition: tests_impl.h:10
void * memcpy(void *a, const void *b, size_t c)
Definition: glibc_compat.cpp:18
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdh(const secp256k1_context *ctx, unsigned char *output, const secp256k1_pubkey *pubkey, const unsigned char *privkey, secp256k1_ecdh_hash_function hashfp, void *data) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Definition: main_impl.h:29
static void secp256k1_sha256_initialize(secp256k1_sha256 *hash)
void test_bad_scalar(void)
Definition: tests_impl.h:97
static void counting_illegal_callback_fn(const char *str, void *data)
Definition: tests.c:48
signed int int32_t
Definition: stdint.h:17
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
Definition: secp256k1.c:67
static void secp256k1_sha256_finalize(secp256k1_sha256 *hash, unsigned char *out32)
int ecdh_hash_function_custom(unsigned char *output, const unsigned char *x, const unsigned char *y, void *data)
Definition: tests_impl.h:18
Definition: secp256k1.h:66