From 8ddd84b8791f790f1e526a0c6f7c669f28b45e64 Mon Sep 17 00:00:00 2001 From: Tibo-lg Date: Wed, 19 Aug 2020 15:13:11 +0900 Subject: [PATCH] Update secp256k1-sys to add adaptor/schnorr/extra keys --- secp256k1-sys/Cargo.toml | 2 +- secp256k1-sys/src/lib.rs | 371 ++++++++++++++++++++++++++++++---- secp256k1-sys/src/recovery.rs | 10 +- 3 files changed, 339 insertions(+), 44 deletions(-) diff --git a/secp256k1-sys/Cargo.toml b/secp256k1-sys/Cargo.toml index 4dcaa58c6..9a855ab6f 100644 --- a/secp256k1-sys/Cargo.toml +++ b/secp256k1-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "secp256k1-sys" -version = "0.1.3" +version = "0.1.3-adaptor.0" authors = [ "Dawid Ciężarkiewicz ", "Andrew Poelstra ", "Steven Roose " ] diff --git a/secp256k1-sys/src/lib.rs b/secp256k1-sys/src/lib.rs index 3aaa808a3..b4b36b61f 100644 --- a/secp256k1-sys/src/lib.rs +++ b/secp256k1-sys/src/lib.rs @@ -37,6 +37,7 @@ pub mod types; pub mod recovery; use core::{hash, slice, ptr}; +use std::ops::Deref; use types::*; /// Flag for context to enable no precomputation @@ -74,6 +75,33 @@ pub type EcdhHashFn = unsafe extern "C" fn( data: *mut c_void, ) -> c_int; +/// Same as secp256k1_nonce function with the exception of accepting an +/// additional pubkey argument and not requiring an attempt argument. The pubkey +/// argument can protect signature schemes with key-prefixed challenge hash +/// inputs against reusing the nonce when signing with the wrong precomputed +/// pubkey. +pub type SchnorrNonceFn = unsafe extern "C" fn( + nonce32: *mut c_uchar, + msg32: *const c_uchar, + key32: *const c_uchar, + xonly_pk32: *const c_uchar, + algo16: *const c_uchar, + data: *mut c_void, +) -> c_int; + +pub extern "C" fn constant_nonce_fn( + nonce32: *mut c_uchar, + _msg32: *const c_uchar, + _key32: *const c_uchar, + _xonly_pk32: *const c_uchar, + _algo16: *const c_uchar, + data: *mut c_void) -> c_int { + unsafe { + ptr::copy_nonoverlapping(data as *const c_uchar, nonce32, 32); + } + return 1; +} + /// A Secp256k1 context, containing various precomputed values and such /// needed to do elliptic curve computations. If you create one of these /// with `secp256k1_context_create` you MUST destroy it with @@ -134,95 +162,260 @@ impl Default for Signature { } } +/// Library-internal representation of an adaptor signature +#[repr(C)] +pub struct AdaptorSignature([c_uchar; 65]); +impl_array_newtype!(AdaptorSignature, c_uchar, 65); +impl_raw_debug!(AdaptorSignature); + +impl AdaptorSignature { + /// Create a new (zeroed) adaptor signature usable for the FFI interface + pub fn new() -> AdaptorSignature { AdaptorSignature([0; 65]) } + pub fn from_array(data: [c_uchar; 65]) -> AdaptorSignature { + AdaptorSignature(data) + } +} + +impl Default for AdaptorSignature { + fn default() -> Self { + AdaptorSignature::new() + } +} + +impl Deref for AdaptorSignature { + type Target = [u8; 65]; + + fn deref(&self) -> &[u8; 65] { + &self.0 + } +} + +/// Library-internal representation of an adaptor proof +#[repr(C)] +pub struct AdaptorProof([c_uchar; 97]); +impl_array_newtype!(AdaptorProof, c_uchar, 97); +impl_raw_debug!(AdaptorProof); + +impl AdaptorProof { + /// Create a new (zeroed) proof usable for the FFI interface + pub fn new() -> AdaptorProof { AdaptorProof([0; 97]) } + pub fn from_array(data: [c_uchar; 97]) -> AdaptorProof { + AdaptorProof(data) + } +} + +impl Default for AdaptorProof { + fn default() -> Self { + AdaptorProof::new() + } +} + +impl Deref for AdaptorProof { + type Target = [u8; 97]; + + fn deref(&self) -> &[u8; 97] { + &self.0 + } +} + +#[repr(C)] +pub struct SchnorrSignature([c_uchar; 64]); +impl_array_newtype!(SchnorrSignature, c_uchar, 64); +impl_raw_debug!(SchnorrSignature); + +impl SchnorrSignature { + /// Create a new (zeroed) proof usable for the FFI interface + pub fn new() -> SchnorrSignature { SchnorrSignature([0; 64]) } + pub fn from_array(data: [c_uchar; 64]) -> SchnorrSignature { + SchnorrSignature(data) + } +} + +impl Default for SchnorrSignature { + fn default() -> Self { + SchnorrSignature::new() + } +} + +impl Deref for SchnorrSignature { + type Target = [u8; 64]; + + fn deref(&self) -> &[u8; 64] { + &self.0 + } +} + +#[repr(C)] +pub struct SchnorrNonce([c_uchar; 32]); +impl_array_newtype!(SchnorrNonce, c_uchar, 32); +impl_raw_debug!(SchnorrNonce); + +impl SchnorrNonce { + /// Create a new (zeroed) proof usable for the FFI interface + pub fn new() -> SchnorrNonce { + SchnorrNonce([0; 32]) + } + pub fn from_array(data: [c_uchar; 32]) -> SchnorrNonce { + SchnorrNonce(data) + } +} + +impl Default for SchnorrNonce { + fn default() -> Self { + SchnorrNonce::new() + } +} + +impl Deref for SchnorrNonce { + type Target = [u8; 32]; + + fn deref(&self) -> &[u8; 32] { + &self.0 + } +} + +#[repr(C)] +pub struct XOnlyPublicKey([c_uchar; 64]); +impl_array_newtype!(XOnlyPublicKey, c_uchar, 64); +impl_raw_debug!(XOnlyPublicKey); + +impl XOnlyPublicKey { + /// Create a new (zeroed) proof usable for the FFI interface + pub fn new() -> XOnlyPublicKey { XOnlyPublicKey([0; 64]) } + pub fn from_array(data: [c_uchar; 64]) -> XOnlyPublicKey { + XOnlyPublicKey(data) + } +} + +impl Default for XOnlyPublicKey { + fn default() -> Self { + XOnlyPublicKey::new() + } +} + +impl Deref for XOnlyPublicKey { + type Target = [u8; 64]; + + fn deref(&self) -> &[u8; 64] { + &self.0 + } +} + +#[repr(C)] +pub struct KeyPair([c_uchar; 96]); +impl_array_newtype!(KeyPair, c_uchar, 96); +impl_raw_debug!(KeyPair); + +impl KeyPair { + /// Create a new (zeroed) proof usable for the FFI interface + pub fn new() -> KeyPair { KeyPair([0; 96]) } + pub fn from_array(data: [c_uchar; 96]) -> KeyPair { + KeyPair(data) + } +} + +impl Default for KeyPair { + fn default() -> Self { + KeyPair::new() + } +} + +impl Deref for KeyPair { + type Target = [u8; 96]; + + fn deref(&self) -> &[u8; 96] { + &self.0 + } +} #[cfg(not(feature = "fuzztarget"))] extern "C" { /// Default ECDH hash function - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdh_hash_function_default")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdh_hash_function_default")] pub static secp256k1_ecdh_hash_function_default: EcdhHashFn; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_nonce_function_rfc6979")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_nonce_function_rfc6979")] pub static secp256k1_nonce_function_rfc6979: NonceFn; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_nonce_function_default")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_nonce_function_default")] pub static secp256k1_nonce_function_default: NonceFn; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_context_no_precomp")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_context_no_precomp")] pub static secp256k1_context_no_precomp: *const Context; // Contexts - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_context_preallocated_size")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_context_preallocated_size")] pub fn secp256k1_context_preallocated_size(flags: c_uint) -> size_t; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_context_preallocated_create")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_context_preallocated_create")] 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_1_2_context_preallocated_destroy")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_context_preallocated_destroy")] pub fn secp256k1_context_preallocated_destroy(cx: *mut Context); - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_context_preallocated_clone_size")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_context_preallocated_clone_size")] pub fn secp256k1_context_preallocated_clone_size(cx: *const Context) -> size_t; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_context_preallocated_clone")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_context_preallocated_clone")] 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_1_2_context_randomize")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_context_randomize")] pub fn secp256k1_context_randomize(cx: *mut Context, seed32: *const c_uchar) -> c_int; // Pubkeys - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ec_pubkey_parse")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ec_pubkey_parse")] pub fn secp256k1_ec_pubkey_parse(cx: *const Context, pk: *mut PublicKey, input: *const c_uchar, in_len: size_t) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ec_pubkey_serialize")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ec_pubkey_serialize")] pub fn secp256k1_ec_pubkey_serialize(cx: *const Context, output: *mut c_uchar, out_len: *mut size_t, pk: *const PublicKey, compressed: c_uint) -> c_int; // Signatures - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_signature_parse_der")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_signature_parse_der")] pub fn secp256k1_ecdsa_signature_parse_der(cx: *const Context, sig: *mut Signature, input: *const c_uchar, in_len: size_t) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_signature_parse_compact")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_signature_parse_compact")] pub fn secp256k1_ecdsa_signature_parse_compact(cx: *const Context, sig: *mut Signature, input64: *const c_uchar) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_signature_parse_der_lax")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_signature_parse_der_lax")] pub fn ecdsa_signature_parse_der_lax(cx: *const Context, sig: *mut Signature, input: *const c_uchar, in_len: size_t) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_signature_serialize_der")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_signature_serialize_der")] pub fn secp256k1_ecdsa_signature_serialize_der(cx: *const Context, output: *mut c_uchar, out_len: *mut size_t, sig: *const Signature) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_signature_serialize_compact")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_signature_serialize_compact")] pub fn secp256k1_ecdsa_signature_serialize_compact(cx: *const Context, output64: *mut c_uchar, sig: *const Signature) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_signature_normalize")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_signature_normalize")] pub fn secp256k1_ecdsa_signature_normalize(cx: *const Context, out_sig: *mut Signature, in_sig: *const Signature) -> c_int; // ECDSA - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_verify")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_verify")] pub fn secp256k1_ecdsa_verify(cx: *const Context, sig: *const Signature, msg32: *const c_uchar, pk: *const PublicKey) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_sign")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_sign")] pub fn secp256k1_ecdsa_sign(cx: *const Context, sig: *mut Signature, msg32: *const c_uchar, @@ -232,11 +425,11 @@ extern "C" { -> c_int; // EC - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ec_seckey_verify")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ec_seckey_verify")] pub fn secp256k1_ec_seckey_verify(cx: *const Context, sk: *const c_uchar) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ec_pubkey_create")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ec_pubkey_create")] pub fn secp256k1_ec_pubkey_create(cx: *const Context, pk: *mut PublicKey, sk: *const c_uchar) -> c_int; @@ -244,52 +437,52 @@ extern "C" { //TODO secp256k1_ec_privkey_import #[deprecated(since = "0.1.3",note = "Please use the secp256k1_ec_seckey_tweak_add function instead")] - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ec_privkey_tweak_add")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ec_privkey_tweak_add")] pub fn secp256k1_ec_privkey_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_1_2_ec_seckey_tweak_add")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_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_1_2_ec_pubkey_tweak_add")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ec_pubkey_tweak_add")] pub fn secp256k1_ec_pubkey_tweak_add(cx: *const Context, pk: *mut PublicKey, tweak: *const c_uchar) -> c_int; #[deprecated(since = "0.1.3",note = "Please use the secp256k1_ec_seckey_tweak_mul function instead")] - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ec_privkey_tweak_mul")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ec_privkey_tweak_mul")] pub fn secp256k1_ec_privkey_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_1_2_ec_seckey_tweak_mul")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_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_1_2_ec_pubkey_tweak_mul")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ec_pubkey_tweak_mul")] pub fn secp256k1_ec_pubkey_tweak_mul(cx: *const Context, pk: *mut PublicKey, tweak: *const c_uchar) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ec_pubkey_combine")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ec_pubkey_combine")] pub fn secp256k1_ec_pubkey_combine(cx: *const Context, out: *mut PublicKey, ins: *const *const PublicKey, n: c_int) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdh")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdh")] pub fn secp256k1_ecdh( cx: *const Context, output: *mut c_uchar, @@ -298,6 +491,107 @@ extern "C" { hashfp: EcdhHashFn, data: *mut c_void, ) -> c_int; + + + // ECDSA Adaptor + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_adaptor_sign")] + pub fn secp256k1_ecdsa_adaptor_sign( + cx: *const Context, + adaptor_sig: *mut AdaptorSignature, + adaptor_proof: *mut AdaptorProof, + seckey: *const c_uchar, + adaptor: *const PublicKey, + msg32: *const c_uchar + ) -> c_int; + + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_adaptor_sig_verify")] + pub fn secp256k1_ecdsa_adaptor_sig_verify( + cx: *const Context, + adaptor_sig: *const AdaptorSignature, + pubkey: *const PublicKey, + msg32: *const c_uchar, + adaptor: *const PublicKey, + adaptor_proof: *const AdaptorProof, + ) -> c_int; + + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_adaptor_adapt")] + pub fn secp256k1_ecdsa_adaptor_adapt( + cx: *const Context, + sig: *mut Signature, + adaptor_secret: *const c_uchar, + adaptor_sig: *const AdaptorSignature, + ) -> c_int; + + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_adaptor_extract_secret")] + pub fn secp256k1_ecdsa_adaptor_extract_secret( + cx: *const Context, + adaptor_secret: *mut c_uchar, + sig: *const Signature, + adaptor_sig: *const AdaptorSignature, + adaptor: *const PublicKey, + ) -> c_int; + + // Schnorr Signatures + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_nonce_function_bip340")] + pub static secp256k1_nonce_function_bip340: SchnorrNonceFn; + + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_schnorrsig_sign")] + pub fn secp256k1_schnorrsig_sign( + cx: *const Context, + sig: *mut SchnorrSignature, + msg32: *const c_uchar, + keypair: *const KeyPair, + noncefp: SchnorrNonceFn, + noncedata: *const c_void + ) -> c_int; + + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_schnorrsig_compute_sigpoint")] + pub fn secp256k1_schnorrsig_compute_sigpoint( + cx: *const Context, + sigpoint: *mut PublicKey, + msg32: *const c_uchar, + nonce: *const SchnorrNonce, + pubkey: *const XOnlyPublicKey, + ) -> c_int; + + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_schnorrsig_verify")] + pub fn secp256k1_schnorrsig_verify( + cx: *const Context, + sig64: *const SchnorrSignature, + msg32: *const c_uchar, + pubkey: *const XOnlyPublicKey, + ) -> c_int; + + // Extra keys + + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_keypair_create")] + pub fn secp256k1_keypair_create( + cx: *const Context, + keypair: *mut KeyPair, + seckey: *const c_uchar, + ) -> c_int; + + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_xonly_pubkey_parse")] + pub fn secp256k1_xonly_pubkey_parse( + cx: *const Context, + pubkey: *mut XOnlyPublicKey, + input32: *const c_uchar, + ) -> c_int; + + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_xonly_pubkey_serialize")] + pub fn secp256k1_xonly_pubkey_serialize( + cx: *const Context, + output32: *mut c_uchar, + pubkey: *const XOnlyPublicKey, + ) -> c_int; + + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_xonly_pubkey_from_pubkey")] + pub fn secp256k1_xonly_pubkey_from_pubkey( + cx: *const Context, + xonly_pubkey: *mut XOnlyPublicKey, + pk_parity: *mut c_int, + pubkey: *const PublicKey, + ) -> c_int; } @@ -311,7 +605,7 @@ extern "C" { // In: flags: which parts of the context to initialize. #[no_mangle] #[cfg(all(feature = "std", not(feature = "external-symbols")))] -pub unsafe extern "C" fn rustsecp256k1_v0_1_2_context_create(flags: c_uint) -> *mut Context { +pub unsafe extern "C" fn rustsecp256k1_v1_1_3_temp_context_create(flags: c_uint) -> *mut Context { use std::mem; assert!(mem::align_of::() >= mem::align_of::()); assert_eq!(mem::size_of::(), mem::size_of::<&usize>()); @@ -329,7 +623,7 @@ pub unsafe extern "C" fn rustsecp256k1_v0_1_2_context_create(flags: c_uint) -> * #[cfg(all(feature = "std", not(feature = "external-symbols")))] pub unsafe fn secp256k1_context_create(flags: c_uint) -> *mut Context { - rustsecp256k1_v0_1_2_context_create(flags) + rustsecp256k1_v1_1_3_temp_context_create(flags) } /// A reimplementation of the C function `secp256k1_context_destroy` in rust. @@ -340,7 +634,7 @@ pub unsafe fn secp256k1_context_create(flags: c_uint) -> *mut Context { /// #[no_mangle] #[cfg(all(feature = "std", not(feature = "external-symbols")))] -pub unsafe extern "C" fn rustsecp256k1_v0_1_2_context_destroy(ctx: *mut Context) { +pub unsafe extern "C" fn rustsecp256k1_v1_1_3_temp_context_destroy(ctx: *mut Context) { secp256k1_context_preallocated_destroy(ctx); let ctx: *mut usize = ctx as *mut usize; @@ -352,7 +646,7 @@ pub unsafe extern "C" fn rustsecp256k1_v0_1_2_context_destroy(ctx: *mut Context) #[cfg(all(feature = "std", not(feature = "external-symbols")))] pub unsafe fn secp256k1_context_destroy(ctx: *mut Context) { - rustsecp256k1_v0_1_2_context_destroy(ctx) + rustsecp256k1_v1_1_3_temp_context_destroy(ctx) } @@ -376,7 +670,7 @@ pub unsafe fn secp256k1_context_destroy(ctx: *mut Context) { /// #[no_mangle] #[cfg(not(feature = "external-symbols"))] -pub unsafe extern "C" fn rustsecp256k1_v0_1_2_default_illegal_callback_fn(message: *const c_char, _data: *mut c_void) { +pub unsafe extern "C" fn rustsecp256k1_v1_1_3_temp_default_illegal_callback_fn(message: *const c_char, _data: *mut c_void) { use core::str; let msg_slice = slice::from_raw_parts(message as *const u8, strlen(message)); let msg = str::from_utf8_unchecked(msg_slice); @@ -399,7 +693,7 @@ pub unsafe extern "C" fn rustsecp256k1_v0_1_2_default_illegal_callback_fn(messag /// #[no_mangle] #[cfg(not(feature = "external-symbols"))] -pub unsafe extern "C" fn rustsecp256k1_v0_1_2_default_error_callback_fn(message: *const c_char, _data: *mut c_void) { +pub unsafe extern "C" fn rustsecp256k1_v1_1_3_temp_default_error_callback_fn(message: *const c_char, _data: *mut c_void) { use core::str; let msg_slice = slice::from_raw_parts(message as *const u8, strlen(message)); let msg = str::from_utf8_unchecked(msg_slice); @@ -463,9 +757,9 @@ mod fuzz_dummy { pub static secp256k1_context_no_precomp: &Context = &Context(0); extern "C" { - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdh_hash_function_default")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdh_hash_function_default")] pub static secp256k1_ecdh_hash_function_default: EcdhHashFn; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_nonce_function_rfc6979")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_nonce_function_rfc6979")] pub static secp256k1_nonce_function_rfc6979: NonceFn; } @@ -837,5 +1131,6 @@ mod tests { assert_eq!(orig.len(), unsafe {strlen(test.as_ptr())}); } + } diff --git a/secp256k1-sys/src/recovery.rs b/secp256k1-sys/src/recovery.rs index d7f45e815..4892536d2 100644 --- a/secp256k1-sys/src/recovery.rs +++ b/secp256k1-sys/src/recovery.rs @@ -41,21 +41,21 @@ impl Default for RecoverableSignature { #[cfg(not(feature = "fuzztarget"))] extern "C" { - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_recoverable_signature_parse_compact")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_recoverable_signature_parse_compact")] pub fn secp256k1_ecdsa_recoverable_signature_parse_compact(cx: *const Context, sig: *mut RecoverableSignature, input64: *const c_uchar, recid: c_int) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_recoverable_signature_serialize_compact")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_recoverable_signature_serialize_compact")] pub fn secp256k1_ecdsa_recoverable_signature_serialize_compact(cx: *const Context, output64: *mut c_uchar, recid: *mut c_int, sig: *const RecoverableSignature) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_recoverable_signature_convert")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_recoverable_signature_convert")] pub fn secp256k1_ecdsa_recoverable_signature_convert(cx: *const Context, sig: *mut Signature, input: *const RecoverableSignature) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_sign_recoverable")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_sign_recoverable")] pub fn secp256k1_ecdsa_sign_recoverable(cx: *const Context, sig: *mut RecoverableSignature, msg32: *const c_uchar, @@ -64,7 +64,7 @@ extern "C" { noncedata: *const c_void) -> c_int; - #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_2_ecdsa_recover")] + #[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v1_1_3_temp_ecdsa_recover")] pub fn secp256k1_ecdsa_recover(cx: *const Context, pk: *mut PublicKey, sig: *const RecoverableSignature,