@@ -87,12 +87,42 @@ pub type EcdhHashFn = Option<unsafe extern "C" fn(
87
87
pub type SchnorrNonceFn = Option < unsafe extern "C" fn (
88
88
nonce32 : * mut c_uchar ,
89
89
msg32 : * const c_uchar ,
90
+ msg_len : size_t ,
90
91
key32 : * const c_uchar ,
91
92
xonly_pk32 : * const c_uchar ,
92
93
algo16 : * const c_uchar ,
94
+ algo_len : size_t ,
93
95
data : * mut c_void ,
94
96
) -> c_int > ;
95
97
98
+ /// Data structure that contains additional arguments for schnorrsig_sign_custom.
99
+ #[ repr( C ) ]
100
+ pub struct SchnorrSigExtraParams {
101
+ magic : [ c_uchar ; 4 ] ,
102
+ nonce_fp : SchnorrNonceFn ,
103
+ ndata : * const c_void ,
104
+ }
105
+
106
+ impl SchnorrSigExtraParams {
107
+ /// Create a new SchnorrSigExtraParams properly initialized.
108
+ ///
109
+ /// `nonce_fp`: pointer to a nonce generation function. If NULL
110
+ /// rustsecp256k1_v0_5_0_nonce_function_bip340 is used
111
+ ///
112
+ /// `ndata`: pointer to arbitrary data used by the nonce generation function
113
+ /// (can be NULL). If it is non-NULL and
114
+ /// rustsecp256k1_v0_5_0_nonce_function_bip340 is used,
115
+ /// then ndata must be a pointer to 32-byte auxiliary randomness as per
116
+ /// BIP-340.
117
+ pub fn new ( nonce_fp : SchnorrNonceFn , ndata : * const c_void ) -> Self {
118
+ SchnorrSigExtraParams {
119
+ magic : [ 0xda , 0x6f , 0xb3 , 0x8c ] ,
120
+ nonce_fp,
121
+ ndata,
122
+ }
123
+ }
124
+ }
125
+
96
126
/// A Secp256k1 context, containing various precomputed values and such
97
127
/// needed to do elliptic curve computations. If you create one of these
98
128
/// with `secp256k1_context_create` you MUST destroy it with
@@ -461,6 +491,17 @@ extern "C" {
461
491
aux_rand32 : * const c_uchar
462
492
) -> c_int ;
463
493
494
+ // Schnorr Signatures with extra parameters (see [`SchnorrSigExtraParams`])
495
+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_5_0_schnorrsig_sign_custom" ) ]
496
+ pub fn secp256k1_schnorrsig_sign_custom (
497
+ cx : * const Context ,
498
+ sig : * mut c_uchar ,
499
+ msg : * const c_uchar ,
500
+ msg_len : size_t ,
501
+ keypair : * const KeyPair ,
502
+ extra_params : * const SchnorrSigExtraParams ,
503
+ ) -> c_int ;
504
+
464
505
#[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_5_0_schnorrsig_verify" ) ]
465
506
pub fn secp256k1_schnorrsig_verify (
466
507
cx : * const Context ,
0 commit comments