Skip to content

Commit

Permalink
Update secp256k1-sys to add adaptor/schnorr/extra keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Tibo-lg committed Oct 22, 2020
1 parent e472562 commit fd173b3
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions secp256k1-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,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
Expand Down Expand Up @@ -85,6 +86,19 @@ pub type SchnorrNonceFn = unsafe extern "C" fn(
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
Expand Down Expand Up @@ -374,6 +388,15 @@ extern "C" {
noncedata: *const c_void
) -> c_int;

#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_adaptor_schnorrsig_compute_sigpoint")]
pub fn secp256k1_schnorrsig_compute_sigpoint(
cx: *const Context,
sigpoint: *mut PublicKey,
msg32: *const c_uchar,
nonce: *const XOnlyPublicKey,
pubkey: *const XOnlyPublicKey,
) -> c_int;

#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_adaptor_schnorrsig_verify")]
pub fn secp256k1_schnorrsig_verify(
cx: *const Context,
Expand Down Expand Up @@ -428,6 +451,44 @@ extern "C" {
pk_parity: *mut c_int,
keypair: *const KeyPair
) -> c_int;

// ECDSA Adaptor
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_adaptor_ecdsa_adaptor_sign")]
pub fn secp256k1_ecdsa_adaptor_sign(
cx: *const Context,
adaptor_sig: *mut c_uchar,
adaptor_proof: *mut c_uchar,
seckey: *const c_uchar,
adaptor: *const PublicKey,
msg32: *const c_uchar
) -> c_int;

#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_adaptor_ecdsa_adaptor_sig_verify")]
pub fn secp256k1_ecdsa_adaptor_sig_verify(
cx: *const Context,
adaptor_sig: *const c_uchar,
pubkey: *const PublicKey,
msg32: *const c_uchar,
adaptor: *const PublicKey,
adaptor_proof: *const c_uchar,
) -> c_int;

#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_adaptor_ecdsa_adaptor_adapt")]
pub fn secp256k1_ecdsa_adaptor_adapt(
cx: *const Context,
sig: *mut Signature,
adaptor_secret: *const c_uchar,
adaptor_sig: *const c_uchar,
) -> c_int;

#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_3_1_adaptor_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 c_uchar,
adaptor: *const PublicKey,
) -> c_int;
}


Expand Down Expand Up @@ -1059,5 +1120,6 @@ mod tests {

assert_eq!(orig.len(), unsafe {strlen(test.as_ptr())});
}

}

0 comments on commit fd173b3

Please sign in to comment.