Bitcoin Core  31.0.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 static void run_tests(secp256k1_context *ctx, unsigned char *key);
44 
45 int main(void) {
46  secp256k1_context* ctx;
47  unsigned char key[32];
48  int ret, i;
49 
51  fprintf(stderr, "This test can only usefully be run inside valgrind because it was not compiled under msan.\n");
52  fprintf(stderr, "Usage: libtool --mode=execute valgrind ./ctime_tests\n");
53  return EXIT_FAILURE;
54  }
59  for (i = 0; i < 32; i++) {
60  key[i] = i + 65;
61  }
62 
63  run_tests(ctx, key);
64 
65  /* Test context randomisation. Do this last because it leaves the context
66  * tainted. */
68  ret = secp256k1_context_randomize(ctx, key);
70  CHECK(ret);
71 
73  return EXIT_SUCCESS;
74 }
75 
76 static void run_tests(secp256k1_context *ctx, unsigned char *key) {
77  secp256k1_ecdsa_signature signature;
78  secp256k1_pubkey pubkey;
79  size_t siglen = 74;
80  size_t outputlen = 33;
81  int i;
82  int ret;
83  unsigned char msg[32];
84  unsigned char sig[74];
85  unsigned char spubkey[33];
86 #ifdef ENABLE_MODULE_RECOVERY
87  secp256k1_ecdsa_recoverable_signature recoverable_signature;
88  int recid;
89 #endif
90 #ifdef ENABLE_MODULE_EXTRAKEYS
91  secp256k1_keypair keypair;
92 #endif
93 #ifdef ENABLE_MODULE_ELLSWIFT
94  unsigned char ellswift[64];
95  static const unsigned char prefix[64] = {'t', 'e', 's', 't'};
96 #endif
97 
98  for (i = 0; i < 32; i++) {
99  msg[i] = i + 1;
100  }
101 
102  /* Test keygen. */
104  ret = secp256k1_ec_pubkey_create(ctx, &pubkey, key);
106  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
107  CHECK(ret);
108  CHECK(secp256k1_ec_pubkey_serialize(ctx, spubkey, &outputlen, &pubkey, SECP256K1_EC_COMPRESSED) == 1);
109 
110  /* Test signing. */
112  ret = secp256k1_ecdsa_sign(ctx, &signature, msg, key, NULL, NULL);
114  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
115  CHECK(ret);
116  CHECK(secp256k1_ecdsa_signature_serialize_der(ctx, sig, &siglen, &signature));
117 
118 #ifdef ENABLE_MODULE_ECDH
119  /* Test ECDH. */
121  ret = secp256k1_ecdh(ctx, msg, &pubkey, key, NULL, NULL);
122  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
123  CHECK(ret == 1);
124 #endif
125 
126 #ifdef ENABLE_MODULE_RECOVERY
127  /* Test signing a recoverable signature. */
129  ret = secp256k1_ecdsa_sign_recoverable(ctx, &recoverable_signature, msg, key, NULL, NULL);
130  SECP256K1_CHECKMEM_DEFINE(&recoverable_signature, sizeof(recoverable_signature));
131  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
132  CHECK(ret);
133  CHECK(secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx, sig, &recid, &recoverable_signature));
134  CHECK(recid >= 0 && recid <= 3);
135 #endif
136 
138  ret = secp256k1_ec_seckey_verify(ctx, key);
139  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
140  CHECK(ret == 1);
141 
143  ret = secp256k1_ec_seckey_negate(ctx, key);
144  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
145  CHECK(ret == 1);
146 
150  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
151  CHECK(ret == 1);
152 
156  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
157  CHECK(ret == 1);
158 
159  /* Test keypair_create and keypair_xonly_tweak_add. */
160 #ifdef ENABLE_MODULE_EXTRAKEYS
162  ret = secp256k1_keypair_create(ctx, &keypair, key);
163  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
164  CHECK(ret == 1);
165 
166  /* The tweak is not treated as a secret in keypair_tweak_add */
168  ret = secp256k1_keypair_xonly_tweak_add(ctx, &keypair, msg);
169  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
170  CHECK(ret == 1);
171 
173  SECP256K1_CHECKMEM_UNDEFINE(&keypair, sizeof(keypair));
174  ret = secp256k1_keypair_sec(ctx, key, &keypair);
175  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
176  CHECK(ret == 1);
177 #endif
178 
179 #ifdef ENABLE_MODULE_SCHNORRSIG
181  ret = secp256k1_keypair_create(ctx, &keypair, key);
182  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
183  CHECK(ret == 1);
184  ret = secp256k1_schnorrsig_sign32(ctx, sig, msg, &keypair, NULL);
185  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
186  CHECK(ret == 1);
187 #endif
188 
189 #ifdef ENABLE_MODULE_MUSIG
190  {
192  const secp256k1_pubkey *pk_ptr[1];
193  secp256k1_xonly_pubkey agg_pk;
194  unsigned char session_secrand[32];
195  uint64_t nonrepeating_cnt = 0;
196  secp256k1_musig_secnonce secnonce;
197  secp256k1_musig_pubnonce pubnonce;
198  const secp256k1_musig_pubnonce *pubnonce_ptr[1];
199  secp256k1_musig_aggnonce aggnonce;
201  secp256k1_musig_session session;
202  secp256k1_musig_partial_sig partial_sig;
203  unsigned char extra_input[32];
204 
205  pk_ptr[0] = &pk;
206  pubnonce_ptr[0] = &pubnonce;
207  SECP256K1_CHECKMEM_DEFINE(key, 32);
208  memcpy(session_secrand, key, sizeof(session_secrand));
209  session_secrand[0] = session_secrand[0] + 1;
210  memcpy(extra_input, key, sizeof(extra_input));
211  extra_input[0] = extra_input[0] + 2;
212 
213  CHECK(secp256k1_keypair_create(ctx, &keypair, key));
214  CHECK(secp256k1_keypair_pub(ctx, &pk, &keypair));
215  CHECK(secp256k1_musig_pubkey_agg(ctx, &agg_pk, &cache, pk_ptr, 1));
216 
218  SECP256K1_CHECKMEM_UNDEFINE(session_secrand, sizeof(session_secrand));
219  SECP256K1_CHECKMEM_UNDEFINE(extra_input, sizeof(extra_input));
220  ret = secp256k1_musig_nonce_gen(ctx, &secnonce, &pubnonce, session_secrand, key, &pk, msg, &cache, extra_input);
221  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
222  CHECK(ret == 1);
223  ret = secp256k1_musig_nonce_gen_counter(ctx, &secnonce, &pubnonce, nonrepeating_cnt, &keypair, msg, &cache, extra_input);
224  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
225  CHECK(ret == 1);
226 
227  CHECK(secp256k1_musig_nonce_agg(ctx, &aggnonce, pubnonce_ptr, 1));
228  /* Make sure that previous tests don't undefine msg. It's not used as a secret here. */
230  CHECK(secp256k1_musig_nonce_process(ctx, &session, &aggnonce, msg, &cache) == 1);
231 
232  ret = secp256k1_keypair_create(ctx, &keypair, key);
233  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
234  CHECK(ret == 1);
235  ret = secp256k1_musig_partial_sign(ctx, &partial_sig, &secnonce, &keypair, &cache, &session);
236  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
237  CHECK(ret == 1);
238  }
239 #endif
240 
241 #ifdef ENABLE_MODULE_ELLSWIFT
243  ret = secp256k1_ellswift_create(ctx, ellswift, key, NULL);
244  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
245  CHECK(ret == 1);
246 
248  ret = secp256k1_ellswift_create(ctx, ellswift, key, ellswift);
249  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
250  CHECK(ret == 1);
251 
252  for (i = 0; i < 2; i++) {
254  SECP256K1_CHECKMEM_DEFINE(&ellswift, sizeof(ellswift));
255  ret = secp256k1_ellswift_xdh(ctx, msg, ellswift, ellswift, key, i, secp256k1_ellswift_xdh_hash_function_bip324, NULL);
256  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
257  CHECK(ret == 1);
258 
260  SECP256K1_CHECKMEM_DEFINE(&ellswift, sizeof(ellswift));
261  ret = secp256k1_ellswift_xdh(ctx, msg, ellswift, ellswift, key, i, secp256k1_ellswift_xdh_hash_function_prefix, (void *)prefix);
262  SECP256K1_CHECKMEM_DEFINE(&ret, sizeof(ret));
263  CHECK(ret == 1);
264  }
265 
266 #endif
267 }
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:574
This module implements BIP 327 "MuSig2 for BIP340-compatible Multi-Signatures" (https://github.com/bitcoin/bips/blob/master/bip-0327.mediawiki) v1.0.0.
int ret
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:712
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:649
return EXIT_SUCCESS
Opaque data structure that holds an aggregate public nonce.
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:755
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:196
#define SECP256K1_CHECKMEM_UNDEFINE(p, len)
Definition: checkmem.h:105
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 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 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:214
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:522
const char * prefix
Definition: rest.cpp:1141
Opaque data structure that holds a parsed ECDSA signature, supporting pubkey recovery.
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:630
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:187
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:255
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:268
memcpy(result.begin(), stream.data(), stream.size())
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:672
int main(void)
Definition: ctime_tests.c:45
Opaque data structure that holds a partial MuSig signature.
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 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:612
#define SECP256K1_CHECKMEM_RUNNING()
Definition: checkmem.h:108
#define SECP256K1_EC_COMPRESSED
Flag to pass to secp256k1_ec_pubkey_serialize.
Definition: secp256k1.h:224
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:603
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:168
#define SECP256K1_CONTEXT_DECLASSIFY
Definition: secp256k1.h:221
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:588
Opaque data structure that holds a parsed and valid "x-only" public key.
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:544
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:200
Opaque data structure that holds a signer&#39;s secret nonce.
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:443
#define CHECK(cond)
Unconditional failure on condition failure.
Definition: util.h:35
#define SECP256K1_CHECKMEM_DEFINE(p, len)
Definition: checkmem.h:106
Opaque data structure that holds a parsed ECDSA signature.
Definition: secp256k1.h:74
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 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:447
Opaque data structure that holds a keypair consisting of a secret and a public key.
Opaque data structure that holds a signer&#39;s public nonce.
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:30
Opaque data structure that holds a MuSig session.
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:414
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:224
static void run_tests(secp256k1_context *ctx, unsigned char *key)
Definition: ctime_tests.c:76
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:141
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:475
Opaque data structure that holds a parsed and valid public key.
Definition: secp256k1.h:61