[API CHANGE] Use secp256k1_ec_ prefix for non-ECDSA key operations
This commit is contained in:
@@ -165,7 +165,7 @@ int secp256k1_ecdsa_recover_compact(const unsigned char *msg, int msglen, const
|
||||
return ret;
|
||||
}
|
||||
|
||||
int secp256k1_ecdsa_seckey_verify(const unsigned char *seckey) {
|
||||
int secp256k1_ec_seckey_verify(const unsigned char *seckey) {
|
||||
DEBUG_CHECK(seckey != NULL);
|
||||
|
||||
secp256k1_num_t sec;
|
||||
@@ -178,14 +178,14 @@ int secp256k1_ecdsa_seckey_verify(const unsigned char *seckey) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int secp256k1_ecdsa_pubkey_verify(const unsigned char *pubkey, int pubkeylen) {
|
||||
int secp256k1_ec_pubkey_verify(const unsigned char *pubkey, int pubkeylen) {
|
||||
DEBUG_CHECK(pubkey != NULL);
|
||||
|
||||
secp256k1_ge_t q;
|
||||
return secp256k1_ecdsa_pubkey_parse(&q, pubkey, pubkeylen);
|
||||
}
|
||||
|
||||
int secp256k1_ecdsa_pubkey_create(unsigned char *pubkey, int *pubkeylen, const unsigned char *seckey, int compressed) {
|
||||
int secp256k1_ec_pubkey_create(unsigned char *pubkey, int *pubkeylen, const unsigned char *seckey, int compressed) {
|
||||
DEBUG_CHECK(secp256k1_ecmult_gen_consts != NULL);
|
||||
DEBUG_CHECK(pubkey != NULL);
|
||||
DEBUG_CHECK(pubkeylen != NULL);
|
||||
@@ -204,7 +204,7 @@ int secp256k1_ecdsa_pubkey_create(unsigned char *pubkey, int *pubkeylen, const u
|
||||
return 1;
|
||||
}
|
||||
|
||||
int secp256k1_ecdsa_pubkey_decompress(unsigned char *pubkey, int *pubkeylen) {
|
||||
int secp256k1_ec_pubkey_decompress(unsigned char *pubkey, int *pubkeylen) {
|
||||
DEBUG_CHECK(pubkey != NULL);
|
||||
DEBUG_CHECK(pubkeylen != NULL);
|
||||
|
||||
@@ -215,7 +215,7 @@ int secp256k1_ecdsa_pubkey_decompress(unsigned char *pubkey, int *pubkeylen) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int secp256k1_ecdsa_privkey_tweak_add(unsigned char *seckey, const unsigned char *tweak) {
|
||||
int secp256k1_ec_privkey_tweak_add(unsigned char *seckey, const unsigned char *tweak) {
|
||||
DEBUG_CHECK(seckey != NULL);
|
||||
DEBUG_CHECK(tweak != NULL);
|
||||
|
||||
@@ -243,7 +243,7 @@ int secp256k1_ecdsa_privkey_tweak_add(unsigned char *seckey, const unsigned char
|
||||
return ret;
|
||||
}
|
||||
|
||||
int secp256k1_ecdsa_pubkey_tweak_add(unsigned char *pubkey, int pubkeylen, const unsigned char *tweak) {
|
||||
int secp256k1_ec_pubkey_tweak_add(unsigned char *pubkey, int pubkeylen, const unsigned char *tweak) {
|
||||
DEBUG_CHECK(secp256k1_ecmult_consts != NULL);
|
||||
DEBUG_CHECK(pubkey != NULL);
|
||||
DEBUG_CHECK(tweak != NULL);
|
||||
@@ -278,7 +278,7 @@ int secp256k1_ecdsa_pubkey_tweak_add(unsigned char *pubkey, int pubkeylen, const
|
||||
return ret;
|
||||
}
|
||||
|
||||
int secp256k1_ecdsa_privkey_tweak_mul(unsigned char *seckey, const unsigned char *tweak) {
|
||||
int secp256k1_ec_privkey_tweak_mul(unsigned char *seckey, const unsigned char *tweak) {
|
||||
DEBUG_CHECK(seckey != NULL);
|
||||
DEBUG_CHECK(tweak != NULL);
|
||||
|
||||
@@ -303,7 +303,7 @@ int secp256k1_ecdsa_privkey_tweak_mul(unsigned char *seckey, const unsigned char
|
||||
return ret;
|
||||
}
|
||||
|
||||
int secp256k1_ecdsa_pubkey_tweak_mul(unsigned char *pubkey, int pubkeylen, const unsigned char *tweak) {
|
||||
int secp256k1_ec_pubkey_tweak_mul(unsigned char *pubkey, int pubkeylen, const unsigned char *tweak) {
|
||||
DEBUG_CHECK(secp256k1_ecmult_consts != NULL);
|
||||
DEBUG_CHECK(pubkey != NULL);
|
||||
DEBUG_CHECK(tweak != NULL);
|
||||
@@ -338,7 +338,7 @@ int secp256k1_ecdsa_pubkey_tweak_mul(unsigned char *pubkey, int pubkeylen, const
|
||||
return ret;
|
||||
}
|
||||
|
||||
int secp256k1_ecdsa_privkey_export(const unsigned char *seckey, unsigned char *privkey, int *privkeylen, int compressed) {
|
||||
int secp256k1_ec_privkey_export(const unsigned char *seckey, unsigned char *privkey, int *privkeylen, int compressed) {
|
||||
DEBUG_CHECK(seckey != NULL);
|
||||
DEBUG_CHECK(privkey != NULL);
|
||||
DEBUG_CHECK(privkeylen != NULL);
|
||||
@@ -351,7 +351,7 @@ int secp256k1_ecdsa_privkey_export(const unsigned char *seckey, unsigned char *p
|
||||
return ret;
|
||||
}
|
||||
|
||||
int secp256k1_ecdsa_privkey_import(unsigned char *seckey, const unsigned char *privkey, int privkeylen) {
|
||||
int secp256k1_ec_privkey_import(unsigned char *seckey, const unsigned char *privkey, int privkeylen) {
|
||||
DEBUG_CHECK(seckey != NULL);
|
||||
DEBUG_CHECK(privkey != NULL);
|
||||
|
||||
|
||||
22
src/tests.c
22
src/tests.c
@@ -560,28 +560,28 @@ void test_ecdsa_end_to_end() {
|
||||
}
|
||||
|
||||
// Construct and verify corresponding public key.
|
||||
CHECK(secp256k1_ecdsa_seckey_verify(privkey) == 1);
|
||||
CHECK(secp256k1_ec_seckey_verify(privkey) == 1);
|
||||
char pubkey[65]; int pubkeylen = 65;
|
||||
CHECK(secp256k1_ecdsa_pubkey_create(pubkey, &pubkeylen, privkey, secp256k1_rand32() % 2) == 1);
|
||||
CHECK(secp256k1_ecdsa_pubkey_verify(pubkey, pubkeylen));
|
||||
CHECK(secp256k1_ec_pubkey_create(pubkey, &pubkeylen, privkey, secp256k1_rand32() % 2) == 1);
|
||||
CHECK(secp256k1_ec_pubkey_verify(pubkey, pubkeylen));
|
||||
|
||||
// Verify private key import and export.
|
||||
unsigned char seckey[300]; int seckeylen = 300;
|
||||
CHECK(secp256k1_ecdsa_privkey_export(privkey, seckey, &seckeylen, secp256k1_rand32() % 2) == 1);
|
||||
CHECK(secp256k1_ec_privkey_export(privkey, seckey, &seckeylen, secp256k1_rand32() % 2) == 1);
|
||||
unsigned char privkey2[32];
|
||||
CHECK(secp256k1_ecdsa_privkey_import(privkey2, seckey, seckeylen) == 1);
|
||||
CHECK(secp256k1_ec_privkey_import(privkey2, seckey, seckeylen) == 1);
|
||||
CHECK(memcmp(privkey, privkey2, 32) == 0);
|
||||
|
||||
// Optionally tweak the keys using addition.
|
||||
if (secp256k1_rand32() % 3 == 0) {
|
||||
unsigned char rnd[32];
|
||||
secp256k1_rand256_test(rnd);
|
||||
int ret1 = secp256k1_ecdsa_privkey_tweak_add(privkey, rnd);
|
||||
int ret2 = secp256k1_ecdsa_pubkey_tweak_add(pubkey, pubkeylen, rnd);
|
||||
int ret1 = secp256k1_ec_privkey_tweak_add(privkey, rnd);
|
||||
int ret2 = secp256k1_ec_pubkey_tweak_add(pubkey, pubkeylen, rnd);
|
||||
CHECK(ret1 == ret2);
|
||||
if (ret1 == 0) return;
|
||||
char pubkey2[65]; int pubkeylen2 = 65;
|
||||
CHECK(secp256k1_ecdsa_pubkey_create(pubkey2, &pubkeylen2, privkey, pubkeylen == 33) == 1);
|
||||
CHECK(secp256k1_ec_pubkey_create(pubkey2, &pubkeylen2, privkey, pubkeylen == 33) == 1);
|
||||
CHECK(memcmp(pubkey, pubkey2, pubkeylen) == 0);
|
||||
}
|
||||
|
||||
@@ -589,12 +589,12 @@ void test_ecdsa_end_to_end() {
|
||||
if (secp256k1_rand32() % 3 == 0) {
|
||||
unsigned char rnd[32];
|
||||
secp256k1_rand256_test(rnd);
|
||||
int ret1 = secp256k1_ecdsa_privkey_tweak_mul(privkey, rnd);
|
||||
int ret2 = secp256k1_ecdsa_pubkey_tweak_mul(pubkey, pubkeylen, rnd);
|
||||
int ret1 = secp256k1_ec_privkey_tweak_mul(privkey, rnd);
|
||||
int ret2 = secp256k1_ec_pubkey_tweak_mul(pubkey, pubkeylen, rnd);
|
||||
CHECK(ret1 == ret2);
|
||||
if (ret1 == 0) return;
|
||||
char pubkey2[65]; int pubkeylen2 = 65;
|
||||
CHECK(secp256k1_ecdsa_pubkey_create(pubkey2, &pubkeylen2, privkey, pubkeylen == 33) == 1);
|
||||
CHECK(secp256k1_ec_pubkey_create(pubkey2, &pubkeylen2, privkey, pubkeylen == 33) == 1);
|
||||
CHECK(memcmp(pubkey, pubkey2, pubkeylen) == 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user