replace privkey functions with seckey functions, deprecate privkey functions
This commit is contained in:
parent
f19c6bbece
commit
1605bde420
|
@ -243,32 +243,51 @@ extern "C" {
|
||||||
//TODO secp256k1_ec_privkey_export
|
//TODO secp256k1_ec_privkey_export
|
||||||
//TODO secp256k1_ec_privkey_import
|
//TODO secp256k1_ec_privkey_import
|
||||||
|
|
||||||
|
#[deprecated(since = "0.2.0",note = "Please use the secp256k1_ec_seckey_tweak_add function instead")]
|
||||||
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_privkey_negate")]
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_privkey_negate")]
|
||||||
pub fn secp256k1_ec_privkey_negate(cx: *const Context,
|
pub fn secp256k1_ec_privkey_negate(cx: *const Context,
|
||||||
sk: *mut c_uchar) -> c_int;
|
sk: *mut c_uchar) -> c_int;
|
||||||
|
|
||||||
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_privkey_negate")]
|
||||||
|
pub fn secp256k1_ec_seckey_negate(cx: *const Context,
|
||||||
|
sk: *mut c_uchar) -> c_int;
|
||||||
|
|
||||||
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_pubkey_negate")]
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_pubkey_negate")]
|
||||||
pub fn secp256k1_ec_pubkey_negate(cx: *const Context,
|
pub fn secp256k1_ec_pubkey_negate(cx: *const Context,
|
||||||
pk: *mut PublicKey) -> c_int;
|
pk: *mut PublicKey) -> c_int;
|
||||||
|
|
||||||
|
#[deprecated(since = "0.2.0",note = "Please use the secp256k1_ec_seckey_tweak_add function instead")]
|
||||||
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_privkey_tweak_add")]
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_privkey_tweak_add")]
|
||||||
pub fn secp256k1_ec_privkey_tweak_add(cx: *const Context,
|
pub fn secp256k1_ec_privkey_tweak_add(cx: *const Context,
|
||||||
sk: *mut c_uchar,
|
sk: *mut c_uchar,
|
||||||
tweak: *const c_uchar)
|
tweak: *const c_uchar)
|
||||||
-> c_int;
|
-> c_int;
|
||||||
|
|
||||||
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_seckey_tweak_add")]
|
||||||
|
pub fn secp256k1_ec_seckey_tweak_add(cx: *const Context,
|
||||||
|
sk: *mut c_uchar,
|
||||||
|
tweak: *const c_uchar)
|
||||||
|
-> c_int;
|
||||||
|
|
||||||
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_pubkey_tweak_add")]
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_pubkey_tweak_add")]
|
||||||
pub fn secp256k1_ec_pubkey_tweak_add(cx: *const Context,
|
pub fn secp256k1_ec_pubkey_tweak_add(cx: *const Context,
|
||||||
pk: *mut PublicKey,
|
pk: *mut PublicKey,
|
||||||
tweak: *const c_uchar)
|
tweak: *const c_uchar)
|
||||||
-> c_int;
|
-> c_int;
|
||||||
|
|
||||||
|
#[deprecated(since = "0.2.0",note = "Please use the secp256k1_ec_seckey_tweak_mul function instead")]
|
||||||
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_privkey_tweak_mul")]
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_privkey_tweak_mul")]
|
||||||
pub fn secp256k1_ec_privkey_tweak_mul(cx: *const Context,
|
pub fn secp256k1_ec_privkey_tweak_mul(cx: *const Context,
|
||||||
sk: *mut c_uchar,
|
sk: *mut c_uchar,
|
||||||
tweak: *const c_uchar)
|
tweak: *const c_uchar)
|
||||||
-> c_int;
|
-> c_int;
|
||||||
|
|
||||||
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_seckey_tweak_mul")]
|
||||||
|
pub fn secp256k1_ec_seckey_tweak_mul(cx: *const Context,
|
||||||
|
sk: *mut c_uchar,
|
||||||
|
tweak: *const c_uchar)
|
||||||
|
-> c_int;
|
||||||
|
|
||||||
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_pubkey_tweak_mul")]
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_2_0_ec_pubkey_tweak_mul")]
|
||||||
pub fn secp256k1_ec_pubkey_tweak_mul(cx: *const Context,
|
pub fn secp256k1_ec_pubkey_tweak_mul(cx: *const Context,
|
||||||
pk: *mut PublicKey,
|
pk: *mut PublicKey,
|
||||||
|
@ -287,7 +306,7 @@ extern "C" {
|
||||||
cx: *const Context,
|
cx: *const Context,
|
||||||
output: *mut c_uchar,
|
output: *mut c_uchar,
|
||||||
pubkey: *const PublicKey,
|
pubkey: *const PublicKey,
|
||||||
privkey: *const c_uchar,
|
seckey: *const c_uchar,
|
||||||
hashfp: EcdhHashFn,
|
hashfp: EcdhHashFn,
|
||||||
data: *mut c_void,
|
data: *mut c_void,
|
||||||
) -> c_int;
|
) -> c_int;
|
||||||
|
@ -413,7 +432,7 @@ unsafe fn strlen(mut str_ptr: *const c_char) -> usize {
|
||||||
/// A trait for producing pointers that will always be valid in C. (assuming NULL pointer is a valid no-op)
|
/// A trait for producing pointers that will always be valid in C. (assuming NULL pointer is a valid no-op)
|
||||||
/// Rust doesn't promise what pointers does it give to ZST (https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts)
|
/// Rust doesn't promise what pointers does it give to ZST (https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts)
|
||||||
/// In case the type is empty this trait will give a NULL pointer, which should be handled in C.
|
/// In case the type is empty this trait will give a NULL pointer, which should be handled in C.
|
||||||
///
|
///
|
||||||
pub trait CPtr {
|
pub trait CPtr {
|
||||||
type Target;
|
type Target;
|
||||||
fn as_c_ptr(&self) -> *const Self::Target;
|
fn as_c_ptr(&self) -> *const Self::Target;
|
||||||
|
@ -702,8 +721,14 @@ mod fuzz_dummy {
|
||||||
//TODO secp256k1_ec_privkey_export
|
//TODO secp256k1_ec_privkey_export
|
||||||
//TODO secp256k1_ec_privkey_import
|
//TODO secp256k1_ec_privkey_import
|
||||||
|
|
||||||
|
#[deprecated(since = "0.2.0",note = "Please use the secp256k1_ec_seckey_negate function instead")]
|
||||||
pub unsafe fn secp256k1_ec_privkey_negate(cx: *const Context,
|
pub unsafe fn secp256k1_ec_privkey_negate(cx: *const Context,
|
||||||
sk: *mut c_uchar) -> c_int {
|
sk: *mut c_uchar) -> c_int {
|
||||||
|
secp256k1_ec_seckey_negate(cx, sk)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn secp256k1_ec_seckey_negate(cx: *const Context,
|
||||||
|
sk: *mut c_uchar) -> c_int {
|
||||||
assert!(!cx.is_null() && (*cx).0 as u32 & !(SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN) == 0);
|
assert!(!cx.is_null() && (*cx).0 as u32 & !(SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN) == 0);
|
||||||
if secp256k1_ec_seckey_verify(cx, sk) != 1 { return 0; }
|
if secp256k1_ec_seckey_verify(cx, sk) != 1 { return 0; }
|
||||||
1
|
1
|
||||||
|
@ -721,6 +746,13 @@ mod fuzz_dummy {
|
||||||
sk: *mut c_uchar,
|
sk: *mut c_uchar,
|
||||||
tweak: *const c_uchar)
|
tweak: *const c_uchar)
|
||||||
-> c_int {
|
-> c_int {
|
||||||
|
secp256k1_ec_seckey_tweak_add(cx, sk, tweak)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn secp256k1_ec_seckey_tweak_add(cx: *const Context,
|
||||||
|
sk: *mut c_uchar,
|
||||||
|
tweak: *const c_uchar)
|
||||||
|
-> c_int {
|
||||||
assert!(!cx.is_null() && (*cx).0 as u32 & !(SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN) == 0);
|
assert!(!cx.is_null() && (*cx).0 as u32 & !(SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN) == 0);
|
||||||
if secp256k1_ec_seckey_verify(cx, sk) != 1 { return 0; }
|
if secp256k1_ec_seckey_verify(cx, sk) != 1 { return 0; }
|
||||||
ptr::copy(tweak.offset(16), sk.offset(16), 16);
|
ptr::copy(tweak.offset(16), sk.offset(16), 16);
|
||||||
|
@ -747,6 +779,14 @@ mod fuzz_dummy {
|
||||||
sk: *mut c_uchar,
|
sk: *mut c_uchar,
|
||||||
tweak: *const c_uchar)
|
tweak: *const c_uchar)
|
||||||
-> c_int {
|
-> c_int {
|
||||||
|
secp256k1_ec_seckey_tweak_mul(cx, sk, tweak)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Copies the last 16 bytes of tweak into the last 16 bytes of sk
|
||||||
|
pub unsafe fn secp256k1_ec_seckey_tweak_mul(cx: *const Context,
|
||||||
|
sk: *mut c_uchar,
|
||||||
|
tweak: *const c_uchar)
|
||||||
|
-> c_int {
|
||||||
assert!(!cx.is_null() && (*cx).0 as u32 & !(SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN) == 0);
|
assert!(!cx.is_null() && (*cx).0 as u32 & !(SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN) == 0);
|
||||||
if secp256k1_ec_seckey_verify(cx, sk) != 1 { return 0; }
|
if secp256k1_ec_seckey_verify(cx, sk) != 1 { return 0; }
|
||||||
ptr::copy(tweak.offset(16), sk.offset(16), 16);
|
ptr::copy(tweak.offset(16), sk.offset(16), 16);
|
||||||
|
|
Loading…
Reference in New Issue