|
|
@ -26,6 +26,9 @@
|
|
|
|
#[cfg(any(test, feature = "std"))]
|
|
|
|
#[cfg(any(test, feature = "std"))]
|
|
|
|
extern crate core;
|
|
|
|
extern crate core;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(rust_secp_fuzz)]
|
|
|
|
|
|
|
|
const THIS_UNUSED_CONSTANT_IS_YOUR_WARNING_THAT_ALL_THE_CRYPTO_IN_THIS_LIB_IS_DISABLED_FOR_FUZZING: usize = 0;
|
|
|
|
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
#[macro_use]
|
|
|
|
mod macros;
|
|
|
|
mod macros;
|
|
|
|
pub mod types;
|
|
|
|
pub mod types;
|
|
|
@ -93,7 +96,7 @@ pub type SchnorrNonceFn = unsafe extern "C" fn(
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
#[repr(C)] pub struct Context(c_int);
|
|
|
|
#[repr(C)] pub struct Context(c_int);
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "fuzztarget")]
|
|
|
|
#[cfg(rust_secp_fuzz)]
|
|
|
|
impl Context {
|
|
|
|
impl Context {
|
|
|
|
pub fn flags(&self) -> u32 {
|
|
|
|
pub fn flags(&self) -> u32 {
|
|
|
|
self.0 as u32
|
|
|
|
self.0 as u32
|
|
|
@ -260,94 +263,94 @@ impl hash::Hash for KeyPair {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "fuzztarget"))]
|
|
|
|
#[cfg(not(rust_secp_fuzz))]
|
|
|
|
extern "C" {
|
|
|
|
extern "C" {
|
|
|
|
/// Default ECDH hash function
|
|
|
|
/// Default ECDH hash function
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ecdh_hash_function_default")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ecdh_hash_function_default")]
|
|
|
|
pub static secp256k1_ecdh_hash_function_default: EcdhHashFn;
|
|
|
|
pub static secp256k1_ecdh_hash_function_default: EcdhHashFn;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_nonce_function_rfc6979")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_nonce_function_rfc6979")]
|
|
|
|
pub static secp256k1_nonce_function_rfc6979: NonceFn;
|
|
|
|
pub static secp256k1_nonce_function_rfc6979: NonceFn;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_nonce_function_default")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_nonce_function_default")]
|
|
|
|
pub static secp256k1_nonce_function_default: NonceFn;
|
|
|
|
pub static secp256k1_nonce_function_default: NonceFn;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_context_no_precomp")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_context_no_precomp")]
|
|
|
|
pub static secp256k1_context_no_precomp: *const Context;
|
|
|
|
pub static secp256k1_context_no_precomp: *const Context;
|
|
|
|
|
|
|
|
|
|
|
|
// Contexts
|
|
|
|
// Contexts
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_context_preallocated_size")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_context_preallocated_size")]
|
|
|
|
pub fn secp256k1_context_preallocated_size(flags: c_uint) -> size_t;
|
|
|
|
pub fn secp256k1_context_preallocated_size(flags: c_uint) -> size_t;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_context_preallocated_create")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_context_preallocated_create")]
|
|
|
|
pub fn secp256k1_context_preallocated_create(prealloc: *mut c_void, flags: c_uint) -> *mut Context;
|
|
|
|
pub fn secp256k1_context_preallocated_create(prealloc: *mut c_void, flags: c_uint) -> *mut Context;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_context_preallocated_destroy")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_context_preallocated_destroy")]
|
|
|
|
pub fn secp256k1_context_preallocated_destroy(cx: *mut Context);
|
|
|
|
pub fn secp256k1_context_preallocated_destroy(cx: *mut Context);
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_context_preallocated_clone_size")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_context_preallocated_clone_size")]
|
|
|
|
pub fn secp256k1_context_preallocated_clone_size(cx: *const Context) -> size_t;
|
|
|
|
pub fn secp256k1_context_preallocated_clone_size(cx: *const Context) -> size_t;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_context_preallocated_clone")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_context_preallocated_clone")]
|
|
|
|
pub fn secp256k1_context_preallocated_clone(cx: *const Context, prealloc: *mut c_void) -> *mut Context;
|
|
|
|
pub fn secp256k1_context_preallocated_clone(cx: *const Context, prealloc: *mut c_void) -> *mut Context;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_context_randomize")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_context_randomize")]
|
|
|
|
pub fn secp256k1_context_randomize(cx: *mut Context,
|
|
|
|
pub fn secp256k1_context_randomize(cx: *mut Context,
|
|
|
|
seed32: *const c_uchar)
|
|
|
|
seed32: *const c_uchar)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
// Pubkeys
|
|
|
|
// Pubkeys
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ec_pubkey_parse")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ec_pubkey_parse")]
|
|
|
|
pub fn secp256k1_ec_pubkey_parse(cx: *const Context, pk: *mut PublicKey,
|
|
|
|
pub fn secp256k1_ec_pubkey_parse(cx: *const Context, pk: *mut PublicKey,
|
|
|
|
input: *const c_uchar, in_len: size_t)
|
|
|
|
input: *const c_uchar, in_len: size_t)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ec_pubkey_serialize")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ec_pubkey_serialize")]
|
|
|
|
pub fn secp256k1_ec_pubkey_serialize(cx: *const Context, output: *mut c_uchar,
|
|
|
|
pub fn secp256k1_ec_pubkey_serialize(cx: *const Context, output: *mut c_uchar,
|
|
|
|
out_len: *mut size_t, pk: *const PublicKey,
|
|
|
|
out_len: *mut size_t, pk: *const PublicKey,
|
|
|
|
compressed: c_uint)
|
|
|
|
compressed: c_uint)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
// Signatures
|
|
|
|
// Signatures
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_parse_der")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_parse_der")]
|
|
|
|
pub fn secp256k1_ecdsa_signature_parse_der(cx: *const Context, sig: *mut Signature,
|
|
|
|
pub fn secp256k1_ecdsa_signature_parse_der(cx: *const Context, sig: *mut Signature,
|
|
|
|
input: *const c_uchar, in_len: size_t)
|
|
|
|
input: *const c_uchar, in_len: size_t)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_parse_compact")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_parse_compact")]
|
|
|
|
pub fn secp256k1_ecdsa_signature_parse_compact(cx: *const Context, sig: *mut Signature,
|
|
|
|
pub fn secp256k1_ecdsa_signature_parse_compact(cx: *const Context, sig: *mut Signature,
|
|
|
|
input64: *const c_uchar)
|
|
|
|
input64: *const c_uchar)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_parse_der_lax")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_parse_der_lax")]
|
|
|
|
pub fn ecdsa_signature_parse_der_lax(cx: *const Context, sig: *mut Signature,
|
|
|
|
pub fn ecdsa_signature_parse_der_lax(cx: *const Context, sig: *mut Signature,
|
|
|
|
input: *const c_uchar, in_len: size_t)
|
|
|
|
input: *const c_uchar, in_len: size_t)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_serialize_der")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_serialize_der")]
|
|
|
|
pub fn secp256k1_ecdsa_signature_serialize_der(cx: *const Context, output: *mut c_uchar,
|
|
|
|
pub fn secp256k1_ecdsa_signature_serialize_der(cx: *const Context, output: *mut c_uchar,
|
|
|
|
out_len: *mut size_t, sig: *const Signature)
|
|
|
|
out_len: *mut size_t, sig: *const Signature)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_serialize_compact")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_serialize_compact")]
|
|
|
|
pub fn secp256k1_ecdsa_signature_serialize_compact(cx: *const Context, output64: *mut c_uchar,
|
|
|
|
pub fn secp256k1_ecdsa_signature_serialize_compact(cx: *const Context, output64: *mut c_uchar,
|
|
|
|
sig: *const Signature)
|
|
|
|
sig: *const Signature)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_normalize")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ecdsa_signature_normalize")]
|
|
|
|
pub fn secp256k1_ecdsa_signature_normalize(cx: *const Context, out_sig: *mut Signature,
|
|
|
|
pub fn secp256k1_ecdsa_signature_normalize(cx: *const Context, out_sig: *mut Signature,
|
|
|
|
in_sig: *const Signature)
|
|
|
|
in_sig: *const Signature)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
// ECDSA
|
|
|
|
// ECDSA
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ecdsa_verify")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ecdsa_verify")]
|
|
|
|
pub fn secp256k1_ecdsa_verify(cx: *const Context,
|
|
|
|
pub fn secp256k1_ecdsa_verify(cx: *const Context,
|
|
|
|
sig: *const Signature,
|
|
|
|
sig: *const Signature,
|
|
|
|
msg32: *const c_uchar,
|
|
|
|
msg32: *const c_uchar,
|
|
|
|
pk: *const PublicKey)
|
|
|
|
pk: *const PublicKey)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ecdsa_sign")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ecdsa_sign")]
|
|
|
|
pub fn secp256k1_ecdsa_sign(cx: *const Context,
|
|
|
|
pub fn secp256k1_ecdsa_sign(cx: *const Context,
|
|
|
|
sig: *mut Signature,
|
|
|
|
sig: *mut Signature,
|
|
|
|
msg32: *const c_uchar,
|
|
|
|
msg32: *const c_uchar,
|
|
|
@ -357,11 +360,11 @@ extern "C" {
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
// EC
|
|
|
|
// EC
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ec_seckey_verify")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ec_seckey_verify")]
|
|
|
|
pub fn secp256k1_ec_seckey_verify(cx: *const Context,
|
|
|
|
pub fn secp256k1_ec_seckey_verify(cx: *const Context,
|
|
|
|
sk: *const c_uchar) -> c_int;
|
|
|
|
sk: *const c_uchar) -> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ec_pubkey_create")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ec_pubkey_create")]
|
|
|
|
pub fn secp256k1_ec_pubkey_create(cx: *const Context, pk: *mut PublicKey,
|
|
|
|
pub fn secp256k1_ec_pubkey_create(cx: *const Context, pk: *mut PublicKey,
|
|
|
|
sk: *const c_uchar) -> c_int;
|
|
|
|
sk: *const c_uchar) -> c_int;
|
|
|
|
|
|
|
|
|
|
|
@ -369,64 +372,64 @@ extern "C" {
|
|
|
|
//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")]
|
|
|
|
#[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_3_1_ec_privkey_negate")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_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_3_1_ec_privkey_negate")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ec_privkey_negate")]
|
|
|
|
pub fn secp256k1_ec_seckey_negate(cx: *const Context,
|
|
|
|
pub fn secp256k1_ec_seckey_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_3_1_ec_pubkey_negate")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_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")]
|
|
|
|
#[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_3_1_ec_privkey_tweak_add")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_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_3_1_ec_seckey_tweak_add")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ec_seckey_tweak_add")]
|
|
|
|
pub fn secp256k1_ec_seckey_tweak_add(cx: *const Context,
|
|
|
|
pub fn secp256k1_ec_seckey_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_3_1_ec_pubkey_tweak_add")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_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")]
|
|
|
|
#[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_3_1_ec_privkey_tweak_mul")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_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_3_1_ec_seckey_tweak_mul")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ec_seckey_tweak_mul")]
|
|
|
|
pub fn secp256k1_ec_seckey_tweak_mul(cx: *const Context,
|
|
|
|
pub fn secp256k1_ec_seckey_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_3_1_ec_pubkey_tweak_mul")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_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,
|
|
|
|
tweak: *const c_uchar)
|
|
|
|
tweak: *const c_uchar)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ec_pubkey_combine")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ec_pubkey_combine")]
|
|
|
|
pub fn secp256k1_ec_pubkey_combine(cx: *const Context,
|
|
|
|
pub fn secp256k1_ec_pubkey_combine(cx: *const Context,
|
|
|
|
out: *mut PublicKey,
|
|
|
|
out: *mut PublicKey,
|
|
|
|
ins: *const *const PublicKey,
|
|
|
|
ins: *const *const PublicKey,
|
|
|
|
n: c_int)
|
|
|
|
n: c_int)
|
|
|
|
-> c_int;
|
|
|
|
-> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ecdh")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ecdh")]
|
|
|
|
pub fn secp256k1_ecdh(
|
|
|
|
pub fn secp256k1_ecdh(
|
|
|
|
cx: *const Context,
|
|
|
|
cx: *const Context,
|
|
|
|
output: *mut c_uchar,
|
|
|
|
output: *mut c_uchar,
|
|
|
@ -438,10 +441,10 @@ extern "C" {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Schnorr Signatures
|
|
|
|
// Schnorr Signatures
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_nonce_function_bip340")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_nonce_function_bip340")]
|
|
|
|
pub static secp256k1_nonce_function_bip340: SchnorrNonceFn;
|
|
|
|
pub static secp256k1_nonce_function_bip340: SchnorrNonceFn;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_schnorrsig_sign")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_schnorrsig_sign")]
|
|
|
|
pub fn secp256k1_schnorrsig_sign(
|
|
|
|
pub fn secp256k1_schnorrsig_sign(
|
|
|
|
cx: *const Context,
|
|
|
|
cx: *const Context,
|
|
|
|
sig: *mut c_uchar,
|
|
|
|
sig: *mut c_uchar,
|
|
|
@ -451,7 +454,7 @@ extern "C" {
|
|
|
|
noncedata: *const c_void
|
|
|
|
noncedata: *const c_void
|
|
|
|
) -> c_int;
|
|
|
|
) -> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_schnorrsig_verify")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_schnorrsig_verify")]
|
|
|
|
pub fn secp256k1_schnorrsig_verify(
|
|
|
|
pub fn secp256k1_schnorrsig_verify(
|
|
|
|
cx: *const Context,
|
|
|
|
cx: *const Context,
|
|
|
|
sig64: *const c_uchar,
|
|
|
|
sig64: *const c_uchar,
|
|
|
@ -461,28 +464,28 @@ extern "C" {
|
|
|
|
|
|
|
|
|
|
|
|
// Extra keys
|
|
|
|
// Extra keys
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_keypair_create")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_keypair_create")]
|
|
|
|
pub fn secp256k1_keypair_create(
|
|
|
|
pub fn secp256k1_keypair_create(
|
|
|
|
cx: *const Context,
|
|
|
|
cx: *const Context,
|
|
|
|
keypair: *mut KeyPair,
|
|
|
|
keypair: *mut KeyPair,
|
|
|
|
seckey: *const c_uchar,
|
|
|
|
seckey: *const c_uchar,
|
|
|
|
) -> c_int;
|
|
|
|
) -> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_xonly_pubkey_parse")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_xonly_pubkey_parse")]
|
|
|
|
pub fn secp256k1_xonly_pubkey_parse(
|
|
|
|
pub fn secp256k1_xonly_pubkey_parse(
|
|
|
|
cx: *const Context,
|
|
|
|
cx: *const Context,
|
|
|
|
pubkey: *mut XOnlyPublicKey,
|
|
|
|
pubkey: *mut XOnlyPublicKey,
|
|
|
|
input32: *const c_uchar,
|
|
|
|
input32: *const c_uchar,
|
|
|
|
) -> c_int;
|
|
|
|
) -> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_xonly_pubkey_serialize")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_xonly_pubkey_serialize")]
|
|
|
|
pub fn secp256k1_xonly_pubkey_serialize(
|
|
|
|
pub fn secp256k1_xonly_pubkey_serialize(
|
|
|
|
cx: *const Context,
|
|
|
|
cx: *const Context,
|
|
|
|
output32: *mut c_uchar,
|
|
|
|
output32: *mut c_uchar,
|
|
|
|
pubkey: *const XOnlyPublicKey,
|
|
|
|
pubkey: *const XOnlyPublicKey,
|
|
|
|
) -> c_int;
|
|
|
|
) -> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_xonly_pubkey_from_pubkey")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_xonly_pubkey_from_pubkey")]
|
|
|
|
pub fn secp256k1_xonly_pubkey_from_pubkey(
|
|
|
|
pub fn secp256k1_xonly_pubkey_from_pubkey(
|
|
|
|
cx: *const Context,
|
|
|
|
cx: *const Context,
|
|
|
|
xonly_pubkey: *mut XOnlyPublicKey,
|
|
|
|
xonly_pubkey: *mut XOnlyPublicKey,
|
|
|
@ -490,7 +493,7 @@ extern "C" {
|
|
|
|
pubkey: *const PublicKey,
|
|
|
|
pubkey: *const PublicKey,
|
|
|
|
) -> c_int;
|
|
|
|
) -> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_xonly_pubkey_tweak_add")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_xonly_pubkey_tweak_add")]
|
|
|
|
pub fn secp256k1_xonly_pubkey_tweak_add(
|
|
|
|
pub fn secp256k1_xonly_pubkey_tweak_add(
|
|
|
|
cx: *const Context,
|
|
|
|
cx: *const Context,
|
|
|
|
output_pubkey: *mut PublicKey,
|
|
|
|
output_pubkey: *mut PublicKey,
|
|
|
@ -498,7 +501,7 @@ extern "C" {
|
|
|
|
tweak32: *const c_uchar,
|
|
|
|
tweak32: *const c_uchar,
|
|
|
|
) -> c_int;
|
|
|
|
) -> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_keypair_xonly_pub")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_keypair_xonly_pub")]
|
|
|
|
pub fn secp256k1_keypair_xonly_pub(
|
|
|
|
pub fn secp256k1_keypair_xonly_pub(
|
|
|
|
cx: *const Context,
|
|
|
|
cx: *const Context,
|
|
|
|
pubkey: *mut XOnlyPublicKey,
|
|
|
|
pubkey: *mut XOnlyPublicKey,
|
|
|
@ -506,14 +509,14 @@ extern "C" {
|
|
|
|
keypair: *const KeyPair
|
|
|
|
keypair: *const KeyPair
|
|
|
|
) -> c_int;
|
|
|
|
) -> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_keypair_xonly_tweak_add")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_keypair_xonly_tweak_add")]
|
|
|
|
pub fn secp256k1_keypair_xonly_tweak_add(
|
|
|
|
pub fn secp256k1_keypair_xonly_tweak_add(
|
|
|
|
cx: *const Context,
|
|
|
|
cx: *const Context,
|
|
|
|
keypair: *mut KeyPair,
|
|
|
|
keypair: *mut KeyPair,
|
|
|
|
tweak32: *const c_uchar,
|
|
|
|
tweak32: *const c_uchar,
|
|
|
|
) -> c_int;
|
|
|
|
) -> c_int;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_xonly_pubkey_tweak_add_check")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_xonly_pubkey_tweak_add_check")]
|
|
|
|
pub fn secp256k1_xonly_pubkey_tweak_add_check(
|
|
|
|
pub fn secp256k1_xonly_pubkey_tweak_add_check(
|
|
|
|
cx: *const Context,
|
|
|
|
cx: *const Context,
|
|
|
|
tweaked_pubkey32: *const c_uchar,
|
|
|
|
tweaked_pubkey32: *const c_uchar,
|
|
|
@ -533,7 +536,7 @@ extern "C" {
|
|
|
|
// Returns: a newly created context object.
|
|
|
|
// Returns: a newly created context object.
|
|
|
|
// In: flags: which parts of the context to initialize.
|
|
|
|
// In: flags: which parts of the context to initialize.
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
|
#[cfg(all(feature = "std", not(feature = "external-symbols")))]
|
|
|
|
#[cfg(all(feature = "std", not(rust_secp_no_symbol_renaming)))]
|
|
|
|
pub unsafe extern "C" fn rustsecp256k1_v0_3_1_context_create(flags: c_uint) -> *mut Context {
|
|
|
|
pub unsafe extern "C" fn rustsecp256k1_v0_3_1_context_create(flags: c_uint) -> *mut Context {
|
|
|
|
use core::mem;
|
|
|
|
use core::mem;
|
|
|
|
use std::alloc;
|
|
|
|
use std::alloc;
|
|
|
@ -552,7 +555,7 @@ pub unsafe extern "C" fn rustsecp256k1_v0_3_1_context_create(flags: c_uint) -> *
|
|
|
|
secp256k1_context_preallocated_create(ptr, flags)
|
|
|
|
secp256k1_context_preallocated_create(ptr, flags)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(all(feature = "std", not(feature = "external-symbols")))]
|
|
|
|
#[cfg(all(feature = "std", not(rust_secp_no_symbol_renaming)))]
|
|
|
|
pub unsafe fn secp256k1_context_create(flags: c_uint) -> *mut Context {
|
|
|
|
pub unsafe fn secp256k1_context_create(flags: c_uint) -> *mut Context {
|
|
|
|
rustsecp256k1_v0_3_1_context_create(flags)
|
|
|
|
rustsecp256k1_v0_3_1_context_create(flags)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -564,7 +567,7 @@ pub unsafe fn secp256k1_context_create(flags: c_uint) -> *mut Context {
|
|
|
|
/// The pointer shouldn't be used after passing to this function, consider it as passing it to `free()`.
|
|
|
|
/// The pointer shouldn't be used after passing to this function, consider it as passing it to `free()`.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
|
#[cfg(all(feature = "std", not(feature = "external-symbols")))]
|
|
|
|
#[cfg(all(feature = "std", not(rust_secp_no_symbol_renaming)))]
|
|
|
|
pub unsafe extern "C" fn rustsecp256k1_v0_3_1_context_destroy(ctx: *mut Context) {
|
|
|
|
pub unsafe extern "C" fn rustsecp256k1_v0_3_1_context_destroy(ctx: *mut Context) {
|
|
|
|
use std::alloc;
|
|
|
|
use std::alloc;
|
|
|
|
secp256k1_context_preallocated_destroy(ctx);
|
|
|
|
secp256k1_context_preallocated_destroy(ctx);
|
|
|
@ -574,7 +577,7 @@ pub unsafe extern "C" fn rustsecp256k1_v0_3_1_context_destroy(ctx: *mut Context)
|
|
|
|
alloc::dealloc(ptr, layout);
|
|
|
|
alloc::dealloc(ptr, layout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(all(feature = "std", not(feature = "external-symbols")))]
|
|
|
|
#[cfg(all(feature = "std", not(rust_secp_no_symbol_renaming)))]
|
|
|
|
pub unsafe fn secp256k1_context_destroy(ctx: *mut Context) {
|
|
|
|
pub unsafe fn secp256k1_context_destroy(ctx: *mut Context) {
|
|
|
|
rustsecp256k1_v0_3_1_context_destroy(ctx)
|
|
|
|
rustsecp256k1_v0_3_1_context_destroy(ctx)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -599,7 +602,7 @@ pub unsafe fn secp256k1_context_destroy(ctx: *mut Context) {
|
|
|
|
/// See also secp256k1_default_error_callback_fn.
|
|
|
|
/// See also secp256k1_default_error_callback_fn.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
|
#[cfg(not(feature = "external-symbols"))]
|
|
|
|
#[cfg(not(rust_secp_no_symbol_renaming))]
|
|
|
|
pub unsafe extern "C" fn rustsecp256k1_v0_3_1_default_illegal_callback_fn(message: *const c_char, _data: *mut c_void) {
|
|
|
|
pub unsafe extern "C" fn rustsecp256k1_v0_3_1_default_illegal_callback_fn(message: *const c_char, _data: *mut c_void) {
|
|
|
|
use core::str;
|
|
|
|
use core::str;
|
|
|
|
let msg_slice = slice::from_raw_parts(message as *const u8, strlen(message));
|
|
|
|
let msg_slice = slice::from_raw_parts(message as *const u8, strlen(message));
|
|
|
@ -622,7 +625,7 @@ pub unsafe extern "C" fn rustsecp256k1_v0_3_1_default_illegal_callback_fn(messag
|
|
|
|
/// See also secp256k1_default_illegal_callback_fn.
|
|
|
|
/// See also secp256k1_default_illegal_callback_fn.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
|
#[cfg(not(feature = "external-symbols"))]
|
|
|
|
#[cfg(not(rust_secp_no_symbol_renaming))]
|
|
|
|
pub unsafe extern "C" fn rustsecp256k1_v0_3_1_default_error_callback_fn(message: *const c_char, _data: *mut c_void) {
|
|
|
|
pub unsafe extern "C" fn rustsecp256k1_v0_3_1_default_error_callback_fn(message: *const c_char, _data: *mut c_void) {
|
|
|
|
use core::str;
|
|
|
|
use core::str;
|
|
|
|
let msg_slice = slice::from_raw_parts(message as *const u8, strlen(message));
|
|
|
|
let msg_slice = slice::from_raw_parts(message as *const u8, strlen(message));
|
|
|
@ -631,7 +634,7 @@ pub unsafe extern "C" fn rustsecp256k1_v0_3_1_default_error_callback_fn(message:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
|
#[cfg(not(feature = "external-symbols"))]
|
|
|
|
#[cfg(not(rust_secp_no_symbol_renaming))]
|
|
|
|
unsafe fn strlen(mut str_ptr: *const c_char) -> usize {
|
|
|
|
unsafe fn strlen(mut str_ptr: *const c_char) -> usize {
|
|
|
|
let mut ctr = 0;
|
|
|
|
let mut ctr = 0;
|
|
|
|
while *str_ptr != '\0' as c_char {
|
|
|
|
while *str_ptr != '\0' as c_char {
|
|
|
@ -674,7 +677,7 @@ impl<T> CPtr for [T] {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "fuzztarget")]
|
|
|
|
#[cfg(rust_secp_fuzz)]
|
|
|
|
mod fuzz_dummy {
|
|
|
|
mod fuzz_dummy {
|
|
|
|
extern crate std;
|
|
|
|
extern crate std;
|
|
|
|
use self::std::{ptr, mem};
|
|
|
|
use self::std::{ptr, mem};
|
|
|
@ -689,11 +692,11 @@ mod fuzz_dummy {
|
|
|
|
pub static secp256k1_context_no_precomp: &Context = &Context(0);
|
|
|
|
pub static secp256k1_context_no_precomp: &Context = &Context(0);
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
extern "C" {
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_ecdh_hash_function_default")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_ecdh_hash_function_default")]
|
|
|
|
pub static secp256k1_ecdh_hash_function_default: EcdhHashFn;
|
|
|
|
pub static secp256k1_ecdh_hash_function_default: EcdhHashFn;
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_nonce_function_rfc6979")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_nonce_function_rfc6979")]
|
|
|
|
pub static secp256k1_nonce_function_rfc6979: NonceFn;
|
|
|
|
pub static secp256k1_nonce_function_rfc6979: NonceFn;
|
|
|
|
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_nonce_function_bip340")]
|
|
|
|
#[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_3_1_nonce_function_bip340")]
|
|
|
|
pub static secp256k1_nonce_function_bip340: SchnorrNonceFn;
|
|
|
|
pub static secp256k1_nonce_function_bip340: SchnorrNonceFn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1156,14 +1159,15 @@ mod fuzz_dummy {
|
|
|
|
unimplemented!();
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#[cfg(feature = "fuzztarget")]
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(rust_secp_fuzz)]
|
|
|
|
pub use self::fuzz_dummy::*;
|
|
|
|
pub use self::fuzz_dummy::*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
mod tests {
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
|
#[cfg(not(feature = "external-symbols"))]
|
|
|
|
#[cfg(not(rust_secp_no_symbol_renaming))]
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_strlen() {
|
|
|
|
fn test_strlen() {
|
|
|
|
use std::ffi::CString;
|
|
|
|
use std::ffi::CString;
|
|
|
|