Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
secp256k1.h
Go to the documentation of this file.
1#ifndef SECP256K1_H
2#define SECP256K1_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stddef.h>
9
10/* Unless explicitly stated all pointer arguments must not be NULL.
11 *
12 * The following rules specify the order of arguments in API calls:
13 *
14 * 1. Context pointers go first, followed by output arguments, combined
15 * output/input arguments, and finally input-only arguments.
16 * 2. Array lengths always immediately follow the argument whose length
17 * they describe, even if this violates rule 1.
18 * 3. Within the OUT/OUTIN/IN groups, pointers to data that is typically generated
19 * later go first. This means: signatures, public nonces, secret nonces,
20 * messages, public keys, secret keys, tweaks.
21 * 4. Arguments that are not data pointers go last, from more complex to less
22 * complex: function pointers, algorithm names, messages, void pointers,
23 * counts, flags, booleans.
24 * 5. Opaque data pointers follow the function pointer they are to be passed to.
25 */
26
47
60
70typedef struct {
71 unsigned char data[64];
73
83typedef struct {
84 unsigned char data[64];
86
104 unsigned char *nonce32,
105 const unsigned char *msg32,
106 const unsigned char *key32,
107 const unsigned char *algo16,
108 void *data,
109 unsigned int attempt
110);
111
112# if !defined(SECP256K1_GNUC_PREREQ)
113# if defined(__GNUC__)&&defined(__GNUC_MINOR__)
114# define SECP256K1_GNUC_PREREQ(_maj,_min) \
115 ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
116# else
117# define SECP256K1_GNUC_PREREQ(_maj,_min) 0
118# endif
119# endif
120
121# if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
122# if SECP256K1_GNUC_PREREQ(2,7)
123# define SECP256K1_INLINE __inline__
124# elif (defined(_MSC_VER))
125# define SECP256K1_INLINE __inline
126# else
127# define SECP256K1_INLINE
128# endif
129# else
130# define SECP256K1_INLINE inline
131# endif
132
140#ifndef SECP256K1_BUILD
141# define SECP256K1_NO_BUILD
142#endif
143
144#ifndef SECP256K1_API
145# if defined(_WIN32)
146# ifdef SECP256K1_BUILD
147# define SECP256K1_API __declspec(dllexport)
148# else
149# define SECP256K1_API
150# endif
151# elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(SECP256K1_BUILD)
152# define SECP256K1_API __attribute__ ((visibility ("default")))
153# else
154# define SECP256K1_API
155# endif
156#endif
157
161# if defined(__GNUC__) && SECP256K1_GNUC_PREREQ(3, 4)
162# define SECP256K1_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
163# else
164# define SECP256K1_WARN_UNUSED_RESULT
165# endif
166# if !defined(SECP256K1_BUILD) && defined(__GNUC__) && SECP256K1_GNUC_PREREQ(3, 4)
167# define SECP256K1_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x)))
168# else
169# define SECP256K1_ARG_NONNULL(_x)
170# endif
171
173#if !defined(SECP256K1_BUILD) && defined(__has_attribute)
174# if __has_attribute(__deprecated__)
175# define SECP256K1_DEPRECATED(_msg) __attribute__ ((__deprecated__(_msg)))
176# else
177# define SECP256K1_DEPRECATED(_msg)
178# endif
179#else
180# define SECP256K1_DEPRECATED(_msg)
181#endif
182
184#define SECP256K1_FLAGS_TYPE_MASK ((1 << 8) - 1)
185#define SECP256K1_FLAGS_TYPE_CONTEXT (1 << 0)
186#define SECP256K1_FLAGS_TYPE_COMPRESSION (1 << 1)
188#define SECP256K1_FLAGS_BIT_CONTEXT_VERIFY (1 << 8)
189#define SECP256K1_FLAGS_BIT_CONTEXT_SIGN (1 << 9)
190#define SECP256K1_FLAGS_BIT_CONTEXT_DECLASSIFY (1 << 10)
191#define SECP256K1_FLAGS_BIT_COMPRESSION (1 << 8)
192
195#define SECP256K1_CONTEXT_VERIFY (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_VERIFY)
196#define SECP256K1_CONTEXT_SIGN (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_SIGN)
197#define SECP256K1_CONTEXT_DECLASSIFY (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_DECLASSIFY)
198#define SECP256K1_CONTEXT_NONE (SECP256K1_FLAGS_TYPE_CONTEXT)
199
201#define SECP256K1_EC_COMPRESSED (SECP256K1_FLAGS_TYPE_COMPRESSION | SECP256K1_FLAGS_BIT_COMPRESSION)
202#define SECP256K1_EC_UNCOMPRESSED (SECP256K1_FLAGS_TYPE_COMPRESSION)
203
205#define SECP256K1_TAG_PUBKEY_EVEN 0x02
206#define SECP256K1_TAG_PUBKEY_ODD 0x03
207#define SECP256K1_TAG_PUBKEY_UNCOMPRESSED 0x04
208#define SECP256K1_TAG_PUBKEY_HYBRID_EVEN 0x06
209#define SECP256K1_TAG_PUBKEY_HYBRID_ODD 0x07
210
217
230 unsigned int flags
232
243 const secp256k1_context* ctx
245
262
302 void (*fun)(const char* message, void* data),
303 const void* data
305
327 void (*fun)(const char* message, void* data),
328 const void* data
330
339 const secp256k1_context* ctx,
340 size_t size
342
350 const secp256k1_context* ctx,
353
369 const secp256k1_context* ctx,
371 const unsigned char *input,
372 size_t inputlen
374
391 const secp256k1_context* ctx,
392 unsigned char *output,
393 size_t *outputlen,
395 unsigned int flags
397
408 const secp256k1_context* ctx,
409 const secp256k1_pubkey* pubkey1,
410 const secp256k1_pubkey* pubkey2
412
429 const secp256k1_context* ctx,
431 const unsigned char *input64
433
450 const secp256k1_context* ctx,
452 const unsigned char *input,
453 size_t inputlen
455
468 const secp256k1_context* ctx,
469 unsigned char *output,
470 size_t *outputlen,
473
484 const secp256k1_context* ctx,
485 unsigned char *output64,
488
515 const secp256k1_context* ctx,
516 const secp256k1_ecdsa_signature *sig,
517 const unsigned char *msghash32,
520
563 const secp256k1_context* ctx,
565 const secp256k1_ecdsa_signature *sigin
567
573
576
596 const secp256k1_context* ctx,
598 const unsigned char *msghash32,
599 const unsigned char *seckey,
601 const void *ndata
603
617 const secp256k1_context* ctx,
618 const unsigned char *seckey
620
630 const secp256k1_context* ctx,
632 const unsigned char *seckey
634
646 const secp256k1_context* ctx,
647 unsigned char *seckey
649
653 const secp256k1_context* ctx,
654 unsigned char *seckey
657
665 const secp256k1_context* ctx,
668
685 const secp256k1_context* ctx,
686 unsigned char *seckey,
687 const unsigned char *tweak32
689
693 const secp256k1_context* ctx,
694 unsigned char *seckey,
695 const unsigned char *tweak32
698
713 const secp256k1_context* ctx,
715 const unsigned char *tweak32
717
732 const secp256k1_context* ctx,
733 unsigned char *seckey,
734 const unsigned char *tweak32
736
740 const secp256k1_context* ctx,
741 unsigned char *seckey,
742 const unsigned char *tweak32
745
758 const secp256k1_context* ctx,
760 const unsigned char *tweak32
762
790 const unsigned char *seed32
792
803 const secp256k1_context* ctx,
804 secp256k1_pubkey *out,
805 const secp256k1_pubkey * const * ins,
806 size_t n
808
826 const secp256k1_context* ctx,
827 unsigned char *hash32,
828 const unsigned char *tag,
829 size_t taglen,
830 const unsigned char *msg,
831 size_t msglen
833
834#ifdef __cplusplus
835}
836#endif
837
838#endif /* SECP256K1_H */
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
Definition secp256k1.c:146
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)
Definition secp256k1.c:659
#define SECP256K1_ARG_NONNULL(_x)
Definition secp256k1.h:169
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT secp256k1_scratch_space * secp256k1_scratch_space_create(const secp256k1_context *ctx, size_t size) SECP256K1_ARG_NONNULL(1)
Definition secp256k1.c:171
SECP256K1_API const secp256k1_context * secp256k1_context_no_precomp
Definition secp256k1.c:60
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize(secp256k1_context *ctx, const unsigned char *seed32) SECP256K1_ARG_NONNULL(1)
Definition secp256k1.c:706
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine(const secp256k1_context *ctx, secp256k1_pubkey *out, const secp256k1_pubkey *const *ins, size_t n) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Definition secp256k1.c:714
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)
Definition secp256k1.c:569
SECP256K1_API const secp256k1_nonce_function secp256k1_nonce_function_default
Definition secp256k1.c:456
SECP256K1_API int secp256k1_ecdsa_signature_parse_compact(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *input64) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Definition secp256k1.c:335
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)
Definition secp256k1.c:246
SECP256K1_API void secp256k1_context_set_error_callback(secp256k1_context *ctx, void(*fun)(const char *message, void *data), const void *data) SECP256K1_ARG_NONNULL(1)
Definition secp256k1.c:162
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_cmp(const secp256k1_context *ctx, const secp256k1_pubkey *pubkey1, const secp256k1_pubkey *pubkey2) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Definition secp256k1.c:269
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)
Definition secp256k1.c:528
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
Definition secp256k1.c:107
SECP256K1_API void secp256k1_context_set_illegal_callback(secp256k1_context *ctx, void(*fun)(const char *message, void *data), const void *data) SECP256K1_ARG_NONNULL(1)
Definition secp256k1.c:153
#define SECP256K1_API
Definition secp256k1.h:154
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)
Definition secp256k1.c:514
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_parse(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *input, size_t inputlen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Definition secp256k1.c:228
int(* secp256k1_nonce_function)(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int attempt)
Definition secp256k1.h:103
SECP256K1_API int secp256k1_ecdsa_signature_parse_der(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *input, size_t inputlen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Definition secp256k1.c:319
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)
Definition secp256k1.c:551
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_tagged_sha256(const secp256k1_context *ctx, unsigned char *hash32, const unsigned char *tag, size_t taglen, const unsigned char *msg, size_t msglen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(5)
Definition secp256k1.c:740
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify(const secp256k1_context *ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msghash32, const secp256k1_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Definition secp256k1.c:400
#define SECP256K1_DEPRECATED(_msg)
Definition secp256k1.h:180
SECP256K1_API int secp256k1_ecdsa_signature_normalize(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sigout, const secp256k1_ecdsa_signature *sigin) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(3)
Definition secp256k1.c:381
SECP256K1_API secp256k1_context * secp256k1_context_clone(const secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT
Definition secp256k1.c:128
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Definition secp256k1.c:642
SECP256K1_API const secp256k1_nonce_function secp256k1_nonce_function_rfc6979
Definition secp256k1.c:455
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)
Definition secp256k1.c:356
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_negate(const secp256k1_context *ctx, secp256k1_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
Definition secp256k1.c:588
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_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) SECP256K1_DEPRECATED("Use secp256k1_ec_seckey_tweak_add instead")
Definition secp256k1.c:631
SECP256K1_API void secp256k1_scratch_space_destroy(const secp256k1_context *ctx, secp256k1_scratch_space *scratch) SECP256K1_ARG_NONNULL(1)
Definition secp256k1.c:176
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_negate(const secp256k1_context *ctx, unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_DEPRECATED("Use secp256k1_ec_seckey_negate instead")
Definition secp256k1.c:584
#define SECP256K1_WARN_UNUSED_RESULT
Definition secp256k1.h:164
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)
Definition secp256k1.c:615
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Definition secp256k1.c:683
SECP256K1_API int secp256k1_ecdsa_signature_serialize_compact(const secp256k1_context *ctx, unsigned char *output64, const secp256k1_ecdsa_signature *sig) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Definition secp256k1.c:368
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_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) SECP256K1_DEPRECATED("Use secp256k1_ec_seckey_tweak_mul instead")
Definition secp256k1.c:679
CK_BYTE_PTR pubkey
pInfo flags