Bitcoin Core 31.99.0
P2P Digital Currency
ctime_tests.c
Go to the documentation of this file.
1/***********************************************************************
2 * Copyright (c) 2020 Gregory Maxwell *
3 * Distributed under the MIT software license, see the accompanying *
4 * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
5 ***********************************************************************/
6
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
10
11#include "../include/secp256k1.h"
12#include "assumptions.h"
13#include "checkmem.h"
14
15#if !SECP256K1_CHECKMEM_ENABLED
16# error "This tool cannot be compiled without memory-checking interface (valgrind or msan)"
17#endif
18
19#ifdef ENABLE_MODULE_ECDH
20# include "../include/secp256k1_ecdh.h"
21#endif
22
23#ifdef ENABLE_MODULE_RECOVERY
24# include "../include/secp256k1_recovery.h"
25#endif
26
27#ifdef ENABLE_MODULE_EXTRAKEYS
28# include "../include/secp256k1_extrakeys.h"
29#endif
30
31#ifdef ENABLE_MODULE_SCHNORRSIG
32#include "../include/secp256k1_schnorrsig.h"
33#endif
34
35#ifdef ENABLE_MODULE_MUSIG
36#include "../include/secp256k1_musig.h"
37#endif
38
39#ifdef ENABLE_MODULE_ELLSWIFT
40#include "../include/secp256k1_ellswift.h"
41#endif
42
43#ifdef ENABLE_MODULE_SILENTPAYMENTS
44#include "../include/secp256k1_silentpayments.h"
45#endif
46
47#if defined(__GNUC__)
48# pragma GCC diagnostic push
49# pragma GCC diagnostic warning "-Wunused-function"
50#endif
51
52static void run_tests(secp256k1_context *ctx, unsigned char *key);
53
54int main(void) {
56 unsigned char key[32];
57 int ret, i;
58
60 fprintf(stderr, "This test can only usefully be run inside valgrind because it was not compiled under msan.\n");
61 fprintf(stderr, "Usage: valgrind ./ctime_tests (or with Autotools: libtool --mode=execute valgrind ./ctime_tests)\n");
62 return EXIT_FAILURE;
63 }
68 for (i = 0; i < 32; i++) {
69 key[i] = i + 65;
70 }
71
72 run_tests(ctx, key);
73
74 /* Test context randomisation. Do this last because it leaves the context
75 * tainted. */
79 CHECK(ret);
80
82 return EXIT_SUCCESS;
83}
84
85static void run_tests(secp256k1_context *ctx, unsigned char *key) {
87 secp256k1_pubkey pubkey;
88 size_t siglen = 74;
89 size_t outputlen = 33;
90 int i;
91 int ret;
92 unsigned char msg[32];
93 unsigned char sig[74];
94 unsigned char spubkey[33];
95#ifdef ENABLE_MODULE_RECOVERY
96 secp256k1_ecdsa_recoverable_signature recoverable_signature;
97 int recid;
98#endif
99#ifdef ENABLE_MODULE_EXTRAKEYS
100 secp256k1_keypair keypair;
101#endif
102#ifdef ENABLE_MODULE_ELLSWIFT
103 unsigned char ellswift[64];
104 static const unsigned char prefix[64] = {'t', 'e', 's', 't'};
105#endif
106#ifdef ENABLE_MODULE_SILENTPAYMENTS
107 secp256k1_xonly_pubkey generated_output;
108 secp256k1_xonly_pubkey *generated_outputs[1];
111 const secp256k1_silentpayments_recipient *recipients[1];
112 unsigned char outpoint_smallest[36] = { 0 };
113 secp256k1_keypair sp_keypair;
114 const secp256k1_keypair *sp_keypairs[1];
115 const unsigned char *sp_seckeys[1];
117 secp256k1_silentpayments_found_output *found_outputs_ptrs[1];
118 uint32_t n_found_outputs;
119 const secp256k1_xonly_pubkey *tx_outputs[1];
121 unsigned char label_tweak[32] = { 0 };
122 secp256k1_xonly_pubkey sp_xonly_pubkey;
123 const secp256k1_xonly_pubkey *sp_xonly_pubkeys[1];
124 secp256k1_pubkey sp_pubkey;
125 const secp256k1_pubkey *sp_pubkeys[1];
126#endif
127
128 for (i = 0; i < 32; i++) {
129 msg[i] = i + 1;
130 }
131
132 /* Test keygen. */
134 ret = secp256k1_ec_pubkey_create(ctx, &pubkey, key);
137 CHECK(ret);
138 CHECK(secp256k1_ec_pubkey_serialize(ctx, spubkey, &outputlen, &pubkey, SECP256K1_EC_COMPRESSED) == 1);
139
140 /* Test signing. */
142 ret = secp256k1_ecdsa_sign(ctx, &signature, msg, key, NULL, NULL);
145 CHECK(ret);
146 CHECK(secp256k1_ecdsa_signature_serialize_der(ctx, sig, &siglen, &signature));
147
148#ifdef ENABLE_MODULE_ECDH
149 /* Test ECDH. */
151 ret = secp256k1_ecdh(ctx, msg, &pubkey, key, NULL, NULL);
153 CHECK(ret == 1);
154#endif
155
156#ifdef ENABLE_MODULE_RECOVERY
157 /* Test signing a recoverable signature. */
159 ret = secp256k1_ecdsa_sign_recoverable(ctx, &recoverable_signature, msg, key, NULL, NULL);
160 SECP256K1_CHECKMEM_DEFINE(&recoverable_signature, sizeof(recoverable_signature));
162 CHECK(ret);
163 CHECK(secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx, sig, &recid, &recoverable_signature));
164 CHECK(recid >= 0 && recid <= 3);
165#endif
166
170 CHECK(ret == 1);
171
175 CHECK(ret == 1);
176
181 CHECK(ret == 1);
182
187 CHECK(ret == 1);
188
189 /* Test keypair_create and keypair_xonly_tweak_add. */
190#ifdef ENABLE_MODULE_EXTRAKEYS
192 ret = secp256k1_keypair_create(ctx, &keypair, key);
194 CHECK(ret == 1);
195
196 /* The tweak is not treated as a secret in keypair_tweak_add */
198 ret = secp256k1_keypair_xonly_tweak_add(ctx, &keypair, msg);
200 CHECK(ret == 1);
201
203 SECP256K1_CHECKMEM_UNDEFINE(&keypair, sizeof(keypair));
204 ret = secp256k1_keypair_sec(ctx, key, &keypair);
206 CHECK(ret == 1);
207#endif
208
209#ifdef ENABLE_MODULE_SCHNORRSIG
211 ret = secp256k1_keypair_create(ctx, &keypair, key);
213 CHECK(ret == 1);
214 ret = secp256k1_schnorrsig_sign32(ctx, sig, msg, &keypair, NULL);
216 CHECK(ret == 1);
217#endif
218
219#ifdef ENABLE_MODULE_MUSIG
220 {
222 const secp256k1_pubkey *pk_ptr[1];
224 unsigned char session_secrand[32];
225 uint64_t nonrepeating_cnt = 0;
228 const secp256k1_musig_pubnonce *pubnonce_ptr[1];
232 secp256k1_musig_partial_sig partial_sig;
233 unsigned char extra_input[32];
234
235 pk_ptr[0] = &pk;
236 pubnonce_ptr[0] = &pubnonce;
238 memcpy(session_secrand, key, sizeof(session_secrand));
239 session_secrand[0] = session_secrand[0] + 1;
240 memcpy(extra_input, key, sizeof(extra_input));
241 extra_input[0] = extra_input[0] + 2;
242
243 CHECK(secp256k1_keypair_create(ctx, &keypair, key));
244 CHECK(secp256k1_keypair_pub(ctx, &pk, &keypair));
245 CHECK(secp256k1_musig_pubkey_agg(ctx, &agg_pk, &cache, pk_ptr, 1));
246
248 SECP256K1_CHECKMEM_UNDEFINE(session_secrand, sizeof(session_secrand));
249 SECP256K1_CHECKMEM_UNDEFINE(extra_input, sizeof(extra_input));
250 ret = secp256k1_musig_nonce_gen(ctx, &secnonce, &pubnonce, session_secrand, key, &pk, msg, &cache, extra_input);
252 CHECK(ret == 1);
253 ret = secp256k1_musig_nonce_gen_counter(ctx, &secnonce, &pubnonce, nonrepeating_cnt, &keypair, msg, &cache, extra_input);
255 CHECK(ret == 1);
256
257 CHECK(secp256k1_musig_nonce_agg(ctx, &aggnonce, pubnonce_ptr, 1));
258 /* Make sure that previous tests don't undefine msg. It's not used as a secret here. */
260 CHECK(secp256k1_musig_nonce_process(ctx, &session, &aggnonce, msg, &cache) == 1);
261
262 ret = secp256k1_keypair_create(ctx, &keypair, key);
264 CHECK(ret == 1);
265 ret = secp256k1_musig_partial_sign(ctx, &partial_sig, &secnonce, &keypair, &cache, &session);
267 CHECK(ret == 1);
268 }
269#endif
270
271#ifdef ENABLE_MODULE_ELLSWIFT
273 ret = secp256k1_ellswift_create(ctx, ellswift, key, NULL);
275 CHECK(ret == 1);
276
278 ret = secp256k1_ellswift_create(ctx, ellswift, key, ellswift);
280 CHECK(ret == 1);
281
282 for (i = 0; i < 2; i++) {
284 SECP256K1_CHECKMEM_DEFINE(&ellswift, sizeof(ellswift));
285 ret = secp256k1_ellswift_xdh(ctx, msg, ellswift, ellswift, key, i, secp256k1_ellswift_xdh_hash_function_bip324, NULL);
287 CHECK(ret == 1);
288
290 SECP256K1_CHECKMEM_DEFINE(&ellswift, sizeof(ellswift));
291 ret = secp256k1_ellswift_xdh(ctx, msg, ellswift, ellswift, key, i, secp256k1_ellswift_xdh_hash_function_prefix, (void *)prefix);
293 CHECK(ret == 1);
294 }
295
296#endif
297
298#ifdef ENABLE_MODULE_SILENTPAYMENTS
300
301 generated_outputs[0] = &generated_output;
302
303 /* Initialize recipient */
304 CHECK(secp256k1_ec_pubkey_create(ctx, &recipient.scan_pubkey, key));
305 key[31] ^= 1;
306 CHECK(secp256k1_ec_pubkey_create(ctx, &recipient.spend_pubkey, key));
307 key[31] ^= (1 << 1);
308 recipient.index = 0;
309 recipients[0] = &recipient;
310
311 /* Set up secret keys */
313 ret = secp256k1_keypair_create(ctx, &sp_keypair, key);
315 CHECK(ret);
316 key[31] ^= (1 << 2);
317 sp_keypairs[0] = &sp_keypair;
318 sp_seckeys[0] = key;
319
320 ret = secp256k1_silentpayments_sender_create_outputs(ctx, generated_outputs, recipients, 1, outpoint_smallest, sp_keypairs, 1, sp_seckeys, 1);
321 CHECK(ret == 1);
322
323 ret = secp256k1_silentpayments_recipient_label_create(ctx, &label, label_tweak, key, 0);
324 key[31] ^= (1 << 3);
326 CHECK(ret == 1);
327
328 CHECK(secp256k1_keypair_xonly_pub(ctx, &sp_xonly_pubkey, NULL, &sp_keypair));
329 SECP256K1_CHECKMEM_DEFINE(&sp_xonly_pubkey, sizeof(sp_xonly_pubkey));
330 sp_xonly_pubkeys[0] = &sp_xonly_pubkey;
331 ret = secp256k1_ec_pubkey_create(ctx, &sp_pubkey, sp_seckeys[0]);
333 CHECK(ret == 1);
334 SECP256K1_CHECKMEM_DEFINE(&sp_pubkey, sizeof(sp_pubkey));
335 sp_pubkeys[0] = &sp_pubkey;
336
337 ret = secp256k1_silentpayments_recipient_prevouts_summary_create(ctx, &prevouts_summary, outpoint_smallest, sp_xonly_pubkeys, 1, sp_pubkeys, 1);
338 CHECK(ret == 1);
339
340 tx_outputs[0] = generated_outputs[0];
341 found_outputs_ptrs[0] = &found_outputs[0];
342 n_found_outputs = 1;
343 SECP256K1_CHECKMEM_DEFINE(&recipient.spend_pubkey, sizeof(recipient.spend_pubkey));
344 /* It is sufficient to check _recipient_scan_outputs without a label lookup function, since the shared secret is created once (which is where the constant timeness matters)
345 * and then reused for the rest of the scanning logic.
346 */
347 CHECK(secp256k1_silentpayments_recipient_scan_outputs(ctx, found_outputs_ptrs, &n_found_outputs, tx_outputs, 1, key, &prevouts_summary, &recipient.spend_pubkey, NULL, NULL));
348
349#endif
350}
351
352#if defined(__GNUC__)
353# pragma GCC diagnostic pop
354#endif
int ret
return EXIT_SUCCESS
#define SECP256K1_CHECKMEM_UNDEFINE(p, len)
Definition: checkmem.h:105
#define SECP256K1_CHECKMEM_DEFINE(p, len)
Definition: checkmem.h:106
#define SECP256K1_CHECKMEM_RUNNING()
Definition: checkmem.h:108
static void run_tests(secp256k1_context *ctx, unsigned char *key)
Definition: ctime_tests.c:85
int main(void)
Definition: ctime_tests.c:54
#define CHECK(cond)
Unconditional failure on condition failure.
Definition: util.h:35
const char * prefix
Definition: rest.cpp:1180
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
Destroy a secp256k1 context object (created in dynamically allocated memory).
Definition: secp256k1.c:189
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_tweak_mul(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Tweak a secret key by multiplying it by a tweak.
Definition: secp256k1.c:736
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize(secp256k1_context *ctx, const unsigned char *seed32) SECP256K1_ARG_NONNULL(1)
Randomizes the context to provide enhanced protection against side-channel leakage.
Definition: secp256k1.c:779
#define SECP256K1_CONTEXT_DECLASSIFY
Definition: secp256k1.h:213
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_negate(const secp256k1_context *ctx, unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
Negates a secret key in place.
Definition: secp256k1.c:654
SECP256K1_API int secp256k1_ec_pubkey_serialize(const secp256k1_context *ctx, unsigned char *output, size_t *outputlen, const secp256k1_pubkey *pubkey, unsigned int flags) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Serialize a pubkey object into a serialized byte sequence.
Definition: secp256k1.c:286
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify(const secp256k1_context *ctx, const unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
Verify an elliptic curve secret key.
Definition: secp256k1.c:615
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
Create a secp256k1 context object (in dynamically allocated memory).
Definition: secp256k1.c:143
SECP256K1_API int secp256k1_ecdsa_sign(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *msghash32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void *ndata) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Create an ECDSA signature.
Definition: secp256k1.c:601
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Compute the public key for a secret key.
Definition: secp256k1.c:636
#define SECP256K1_EC_COMPRESSED
Flag to pass to secp256k1_ec_pubkey_serialize.
Definition: secp256k1.h:216
SECP256K1_API int secp256k1_ecdsa_signature_serialize_der(const secp256k1_context *ctx, unsigned char *output, size_t *outputlen, const secp256k1_ecdsa_signature *sig) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Serialize an ECDSA signature in DER format.
Definition: secp256k1.c:432
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_tweak_add(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Tweak a secret key by adding tweak to it.
Definition: secp256k1.c:696
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdh(const secp256k1_context *ctx, unsigned char *output, const secp256k1_pubkey *pubkey, const unsigned char *seckey, secp256k1_ecdh_hash_function hashfp, void *data) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Compute an EC Diffie-Hellman secret in constant time.
Definition: main_impl.h:34
SECP256K1_API const secp256k1_ellswift_xdh_hash_function secp256k1_ellswift_xdh_hash_function_prefix
An implementation of an secp256k1_ellswift_xdh_hash_function which uses SHA256(prefix64 || ell_a64 ||...
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ellswift_create(const secp256k1_context *ctx, unsigned char *ell64, const unsigned char *seckey32, const unsigned char *auxrnd32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Compute an ElligatorSwift public key for a secret key.
Definition: main_impl.h:431
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ellswift_xdh(const secp256k1_context *ctx, unsigned char *output, const unsigned char *ell_a64, const unsigned char *ell_b64, const unsigned char *seckey32, int party, secp256k1_ellswift_xdh_hash_function hashfp, void *data) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(7)
Given a private key, and ElligatorSwift public keys sent in both directions, compute a shared secret ...
Definition: main_impl.h:536
SECP256K1_API const secp256k1_ellswift_xdh_hash_function secp256k1_ellswift_xdh_hash_function_bip324
An implementation of an secp256k1_ellswift_xdh_hash_function compatible with BIP324.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_keypair_create(const secp256k1_context *ctx, secp256k1_keypair *keypair, const unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Compute the keypair for a valid secret key.
Definition: main_impl.h:203
SECP256K1_API int secp256k1_keypair_xonly_pub(const secp256k1_context *ctx, secp256k1_xonly_pubkey *pubkey, int *pk_parity, const secp256k1_keypair *keypair) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(4)
Get the x-only public key from a keypair.
Definition: main_impl.h:241
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_keypair_xonly_tweak_add(const secp256k1_context *ctx, secp256k1_keypair *keypair, const unsigned char *tweak32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Tweak a keypair by adding tweak32 to the secret key and updating the public key accordingly.
Definition: main_impl.h:262
SECP256K1_API int secp256k1_keypair_pub(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const secp256k1_keypair *keypair) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Get the public key from a keypair.
Definition: main_impl.h:231
SECP256K1_API int secp256k1_keypair_sec(const secp256k1_context *ctx, unsigned char *seckey, const secp256k1_keypair *keypair) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Get the secret key from a keypair.
Definition: main_impl.h:221
SECP256K1_API int secp256k1_musig_nonce_agg(const secp256k1_context *ctx, secp256k1_musig_aggnonce *aggnonce, const secp256k1_musig_pubnonce *const *pubnonces, size_t n_pubnonces) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Aggregates the nonces of all signers into a single nonce.
Definition: session_impl.h:510
SECP256K1_API int secp256k1_musig_partial_sign(const secp256k1_context *ctx, secp256k1_musig_partial_sig *partial_sig, secp256k1_musig_secnonce *secnonce, const secp256k1_keypair *keypair, const secp256k1_musig_keyagg_cache *keyagg_cache, const secp256k1_musig_session *session) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(6)
Produces a partial signature.
Definition: session_impl.h:632
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_nonce_gen(const secp256k1_context *ctx, secp256k1_musig_secnonce *secnonce, secp256k1_musig_pubnonce *pubnonce, unsigned char *session_secrand32, const unsigned char *seckey, const secp256k1_pubkey *pubkey, const unsigned char *msg32, const secp256k1_musig_keyagg_cache *keyagg_cache, const unsigned char *extra_input32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(6)
Starts a signing session by generating a nonce.
Definition: session_impl.h:437
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_nonce_gen_counter(const secp256k1_context *ctx, secp256k1_musig_secnonce *secnonce, secp256k1_musig_pubnonce *pubnonce, uint64_t nonrepeating_cnt, const secp256k1_keypair *keypair, const unsigned char *msg32, const secp256k1_musig_keyagg_cache *keyagg_cache, const unsigned char *extra_input32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(5)
Alternative way to generate a nonce and start a signing session.
Definition: session_impl.h:465
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_pubkey_agg(const secp256k1_context *ctx, secp256k1_xonly_pubkey *agg_pk, secp256k1_musig_keyagg_cache *keyagg_cache, const secp256k1_pubkey *const *pubkeys, size_t n_pubkeys) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(4)
Computes an aggregate public key and uses it to initialize a keyagg_cache.
Definition: keyagg_impl.h:156
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_nonce_process(const secp256k1_context *ctx, secp256k1_musig_session *session, const secp256k1_musig_aggnonce *aggnonce, const unsigned char *msg32, const secp256k1_musig_keyagg_cache *keyagg_cache) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5)
Takes the aggregate nonce and creates a session that is required for signing and verification of part...
Definition: session_impl.h:586
SECP256K1_API int secp256k1_ecdsa_recoverable_signature_serialize_compact(const secp256k1_context *ctx, unsigned char *output64, int *recid, const secp256k1_ecdsa_recoverable_signature *sig) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Serialize an ECDSA signature in compact format (64 bytes + recovery id).
Definition: main_impl.h:60
SECP256K1_API int secp256k1_ecdsa_sign_recoverable(const secp256k1_context *ctx, secp256k1_ecdsa_recoverable_signature *sig, const unsigned char *msghash32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void *ndata) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Create a recoverable ECDSA signature.
Definition: main_impl.h:123
SECP256K1_API int secp256k1_schnorrsig_sign32(const secp256k1_context *ctx, unsigned char *sig64, const unsigned char *msg32, const secp256k1_keypair *keypair, const unsigned char *aux_rand32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Create a Schnorr signature.
Definition: main_impl.h:188
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_recipient_prevouts_summary_create(const secp256k1_context *ctx, secp256k1_silentpayments_prevouts_summary *prevouts_summary, const unsigned char *outpoint_smallest36, const secp256k1_xonly_pubkey *const *xonly_pubkeys, size_t n_xonly_pubkeys, const secp256k1_pubkey *const *pubkeys, size_t n_pubkeys) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Compute Silent Payments prevouts summary from prevout public keys and transaction inputs.
Definition: main_impl.h:488
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_sender_create_outputs(const secp256k1_context *ctx, secp256k1_xonly_pubkey **generated_outputs, const secp256k1_silentpayments_recipient **recipients, size_t n_recipients, const unsigned char *outpoint_smallest36, const secp256k1_keypair *const *keypairs, size_t n_keypairs, const unsigned char *const *seckeys, size_t n_seckeys) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(5)
Create Silent Payments outputs for recipient(s).
Definition: main_impl.h:187
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_recipient_scan_outputs(const secp256k1_context *ctx, secp256k1_silentpayments_found_output **found_outputs, uint32_t *n_found_outputs, const secp256k1_xonly_pubkey *const *tx_outputs, size_t n_tx_outputs, const unsigned char *scan_key32, const secp256k1_silentpayments_prevouts_summary *prevouts_summary, const secp256k1_pubkey *unlabeled_spend_pubkey, secp256k1_silentpayments_label_lookup label_lookup, const void *label_context) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(6) SECP256K1_ARG_NONNULL(7) SECP256K1_ARG_NONNULL(8)
Scan for Silent Payments transaction outputs.
Definition: main_impl.h:606
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_recipient_label_create(const secp256k1_context *ctx, secp256k1_silentpayments_label *label, unsigned char *label_tweak32, const unsigned char *scan_key32, uint32_t m) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Create Silent Payments label tweak and label.
Definition: main_impl.h:393
Opaque data structure that holds a parsed ECDSA signature, supporting pubkey recovery.
Opaque data structure that holds a parsed ECDSA signature.
Definition: secp256k1.h:75
Opaque data structure that holds a keypair consisting of a secret and a public key.
Opaque data structure that holds an aggregate public nonce.
This module implements BIP 327 "MuSig2 for BIP340-compatible Multi-Signatures" (https://github....
Opaque data structure that holds a partial MuSig signature.
Opaque data structure that holds a signer's public nonce.
Opaque data structure that holds a signer's secret nonce.
Opaque data structure that holds a MuSig session.
Opaque data structure that holds a parsed and valid public key.
Definition: secp256k1.h:62
Opaque data structure that holds a Silent Payments label.
Opaque data structure that holds Silent Payments prevouts summary data.
The data from a single recipient address.
Opaque data structure that holds a parsed and valid "x-only" public key.