@@ -66,7 +66,7 @@ extern "C" {
66
66
67
67
/** A pointer to a function to deterministically generate a nonce.
68
68
*
69
- * Same as secp256k1_schnorrsig_nonce function with the exception of using the
69
+ * Same as `secp256k1_nonce_function_hardened` with the exception of using the
70
70
* compressed 33-byte encoding for the adaptor argument.
71
71
*
72
72
* Returns: 1 if a nonce was successfully generated. 0 will cause signing to
@@ -96,12 +96,19 @@ typedef int (*secp256k1_nonce_function_hardened_schnorr_adaptor)(
96
96
void * data
97
97
);
98
98
99
- /** A Schnorr Adaptor nonce generation function. */
99
+ /** A modified BIP-340 nonce generation function. If a data pointer is passed, it is
100
+ * assumed to be a pointer to 32 bytes of auxiliary random data as defined in BIP-340.
101
+ * If the data pointer is NULL, the nonce derivation procedure uses a zeroed 32-byte
102
+ * auxiliary random data. The hash will be tagged with algo after removing all
103
+ * terminating null bytes.
104
+ */
100
105
SECP256K1_API const secp256k1_nonce_function_hardened_schnorr_adaptor secp256k1_nonce_function_schnorr_adaptor ;
101
106
102
- /** Creates a Schnorr pre-signature.
103
- * TODO: this description could be improved & do we really need the
104
- * below paragraph?
107
+ /** Creates a pre-signature for a given message and adaptor point.
108
+ *
109
+ * The pre-signature can be converted into a valid BIP-340 Schnorr signature
110
+ * (using `schnorr_adaptor_adapt`) by combining it with the discrete logarithm
111
+ * of the adaptor point.
105
112
*
106
113
* This function only signs 32-byte messages. If you have messages of a
107
114
* different size (or the same size but without a context-specific tag
@@ -111,16 +118,16 @@ SECP256K1_API const secp256k1_nonce_function_hardened_schnorr_adaptor secp256k1_
111
118
* signatures from being valid in multiple contexts by accident.
112
119
*
113
120
* Returns 1 on success, 0 on failure.
114
- * Args: ctx: pointer to a context object (not secp256k1_context_static).
115
- * Out: pre_sig65: pointer to a 65-byte array to store the serialized pre-signature.
116
- * In: msg32: the 32-byte message being signed.
117
- * keypair: pointer to an initialized keypair.
118
- * adaptor: pointer to an adaptor point encoded as a public key.
119
- * aux_rand32: pointer to arbitrary data used by the nonce generation
120
- * function (can be NULL). If it is non-NULL and
121
- * secp256k1_nonce_function_schnorr_adaptor is used, then
122
- * aux_rand32 must be a pointer to 32-byte auxiliary randomness
123
- * as per BIP-340.
121
+ * Args: ctx: pointer to a context object (not secp256k1_context_static).
122
+ * Out: pre_sig65: pointer to a 65-byte array to store the pre-signature.
123
+ * In: msg32: the 32-byte message being signed.
124
+ * keypair: pointer to an initialized keypair.
125
+ * adaptor: pointer to an adaptor point encoded as a public key.
126
+ * aux_rand32: pointer to arbitrary data used by the nonce generation
127
+ * function (can be NULL). If it is non-NULL and
128
+ * secp256k1_nonce_function_schnorr_adaptor is used, then
129
+ * aux_rand32 must be a pointer to 32-byte auxiliary randomness
130
+ * as per BIP-340.
124
131
*/
125
132
SECP256K1_API int secp256k1_schnorr_adaptor_presign (
126
133
const secp256k1_context * ctx ,
@@ -131,12 +138,17 @@ SECP256K1_API int secp256k1_schnorr_adaptor_presign(
131
138
const unsigned char * aux_rand32
132
139
) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 ) SECP256K1_ARG_NONNULL (4 ) SECP256K1_ARG_NONNULL (5 );
133
140
134
- /** Extract an adaptor point from the pre-signature.
141
+ /** Extracts an adaptor point from the pre-signature.
142
+ * TODO: Note: returning 1 doesn't neccessarily guarantee
143
+ * that the extracted adaptor point is correct.
144
+ * If this funtion passes, secp256k1_schnorr_adaptor_adapt called with
145
+ * the secret key corresponding to public key T and presig65 outputs a
146
+ * valid Schnorr signature.
135
147
*
136
148
* Returns 1 on success, 0 on failure.
137
149
* Args: ctx: pointer to a context object.
138
- * Out: adaptor: pointer to an adaptor point.
139
- * In: pre_sig65: pointer to a 65-byte pre-signature.
150
+ * Out: adaptor: pointer to store the adaptor point.
151
+ * In: pre_sig65: pointer to a 65-byte pre-signature.
140
152
* msg32: the 32-byte message being signed.
141
153
* pubkey: pointer to the x-only public key used to
142
154
* generate the `pre_sig65`
@@ -150,15 +162,19 @@ SECP256K1_API int secp256k1_schnorr_adaptor_extract(
150
162
) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 ) SECP256K1_ARG_NONNULL (4 ) SECP256K1_ARG_NONNULL (5 );
151
163
152
164
/** Creates a signature from a pre-signature and a secret adaptor.
165
+ *
166
+ * TODO: Note: returning 1 doesn't neccessarily guarantee
167
+ * that the extracted adaptor point is correct.
153
168
*
154
169
* If the sec_adaptor32 argument is incorrect, the output signature will be
155
170
* invalid. This function does not verify the signature.
156
171
*
157
172
* Returns 1 on success, 0 on failure.
158
173
* Args: ctx: pointer to a context object.
159
- * Out: sig64: 64-byte signature. This pointer may point to the same
160
- * memory area as `pre_sig65`.
161
- * In: pre_sig65: 65-byte pre-signature
174
+ * Out: sig64: pointer to a 64-byte array to store the adapted
175
+ * pre-signature. This pointer may point to the same
176
+ * memory area as `pre_sig65`.
177
+ * In: pre_sig65: 65-byte pre-signature corresponding to `sec_adaptor32`.
162
178
* sec_adaptor32: pointer to a 32-byte secret adaptor.
163
179
*/
164
180
SECP256K1_API int secp256k1_schnorr_adaptor_adapt (
@@ -171,12 +187,14 @@ SECP256K1_API int secp256k1_schnorr_adaptor_adapt(
171
187
/** Extracts a secret adaptor from a pre-signature and the corresponding
172
188
* signature.
173
189
*
190
+ * TODO: Note: returning 1 doesn't neccessarily guarantee
191
+ * that the extracted adaptor point is correct.
192
+ *
174
193
* Returns 1 on success, 0 on failure.
175
194
* Args: ctx: pointer to a context object.
176
- * Out: sec_adaptor32: 32-byte secret adaptor.
195
+ * Out: sec_adaptor32: pointer to a 32-byte array to store the secret adaptor.
177
196
* In: pre_sig65: the pre-signature corresponding to `sig64`
178
- * sig64: complete, valid 64-byte signature.
179
- * TODO: swap the presig and sig arg order
197
+ * sig64: complete, valid 64-byte BIP-340 Schnorr signature.
180
198
*/
181
199
SECP256K1_API int secp256k1_schnorr_adaptor_extract_sec (
182
200
const secp256k1_context * ctx ,
0 commit comments