@@ -119,6 +119,20 @@ typedef int (*secp256k1_nonce_function)(
119119# define SECP256K1_INLINE inline
120120# endif
121121
122+ #ifndef SECP256K1_API
123+ # if defined(_WIN32 )
124+ # ifdef SECP256K1_BUILD
125+ # define SECP256K1_API __declspec(dllexport)
126+ # else
127+ # define SECP256K1_API
128+ # endif
129+ # elif defined(__GNUC__ ) && defined(SECP256K1_BUILD )
130+ # define SECP256K1_API __attribute__ ((visibility ("default")))
131+ # else
132+ # define SECP256K1_API
133+ # endif
134+ #endif
135+
122136/**Warning attributes
123137 * NONNULL is not used if SECP256K1_BUILD is set to avoid the compiler optimizing out
124138 * some paranoid null checks. */
@@ -145,7 +159,7 @@ typedef int (*secp256k1_nonce_function)(
145159 * Returns: a newly created context object.
146160 * In: flags: which parts of the context to initialize.
147161 */
148- secp256k1_context * secp256k1_context_create (
162+ SECP256K1_API secp256k1_context * secp256k1_context_create (
149163 unsigned int flags
150164) SECP256K1_WARN_UNUSED_RESULT ;
151165
@@ -154,7 +168,7 @@ secp256k1_context* secp256k1_context_create(
154168 * Returns: a newly created context object.
155169 * Args: ctx: an existing context to copy (cannot be NULL)
156170 */
157- secp256k1_context * secp256k1_context_clone (
171+ SECP256K1_API secp256k1_context * secp256k1_context_clone (
158172 const secp256k1_context * ctx
159173) SECP256K1_ARG_NONNULL (1 ) SECP256K1_WARN_UNUSED_RESULT ;
160174
@@ -163,7 +177,7 @@ secp256k1_context* secp256k1_context_clone(
163177 * The context pointer may not be used afterwards.
164178 * Args: ctx: an existing context to destroy (cannot be NULL)
165179 */
166- void secp256k1_context_destroy (
180+ SECP256K1_API void secp256k1_context_destroy (
167181 secp256k1_context * ctx
168182);
169183
@@ -187,7 +201,7 @@ void secp256k1_context_destroy(
187201 * (NULL restores a default handler that calls abort).
188202 * data: the opaque pointer to pass to fun above.
189203 */
190- void secp256k1_context_set_illegal_callback (
204+ SECP256K1_API void secp256k1_context_set_illegal_callback (
191205 secp256k1_context * ctx ,
192206 void (* fun )(const char * message , void * data ),
193207 const void * data
@@ -209,7 +223,7 @@ void secp256k1_context_set_illegal_callback(
209223 * handler that calls abort).
210224 * data: the opaque pointer to pass to fun above.
211225 */
212- void secp256k1_context_set_error_callback (
226+ SECP256K1_API void secp256k1_context_set_error_callback (
213227 secp256k1_context * ctx ,
214228 void (* fun )(const char * message , void * data ),
215229 const void * data
@@ -229,7 +243,7 @@ void secp256k1_context_set_error_callback(
229243 * 0x03), uncompressed (65 bytes, header byte 0x04), or hybrid (65 bytes, header
230244 * byte 0x06 or 0x07) format public keys.
231245 */
232- SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_parse (
246+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_parse (
233247 const secp256k1_context * ctx ,
234248 secp256k1_pubkey * pubkey ,
235249 const unsigned char * input ,
@@ -249,7 +263,7 @@ SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_parse(
249263 * flags: SECP256K1_EC_COMPRESSED if serialization should be in
250264 * compressed format.
251265 */
252- int secp256k1_ec_pubkey_serialize (
266+ SECP256K1_API int secp256k1_ec_pubkey_serialize (
253267 const secp256k1_context * ctx ,
254268 unsigned char * output ,
255269 size_t * outputlen ,
@@ -267,7 +281,7 @@ int secp256k1_ec_pubkey_serialize(
267281 *
268282 * Note that this function also supports some violations of DER and even BER.
269283 */
270- int secp256k1_ecdsa_signature_parse_der (
284+ SECP256K1_API int secp256k1_ecdsa_signature_parse_der (
271285 const secp256k1_context * ctx ,
272286 secp256k1_ecdsa_signature * sig ,
273287 const unsigned char * input ,
@@ -285,7 +299,7 @@ int secp256k1_ecdsa_signature_parse_der(
285299 * if 0 was returned).
286300 * In: sig: a pointer to an initialized signature object
287301 */
288- int secp256k1_ecdsa_signature_serialize_der (
302+ SECP256K1_API int secp256k1_ecdsa_signature_serialize_der (
289303 const secp256k1_context * ctx ,
290304 unsigned char * output ,
291305 size_t * outputlen ,
@@ -301,7 +315,7 @@ int secp256k1_ecdsa_signature_serialize_der(
301315 * msg32: the 32-byte message hash being verified (cannot be NULL)
302316 * pubkey: pointer to an initialized public key to verify with (cannot be NULL)
303317 */
304- SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify (
318+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify (
305319 const secp256k1_context * ctx ,
306320 const secp256k1_ecdsa_signature * sig ,
307321 const unsigned char * msg32 ,
@@ -355,7 +369,7 @@ extern const secp256k1_nonce_function secp256k1_nonce_function_default;
355369 * schemes will also accept various non-unique encodings, so care should
356370 * be taken when this property is required for an application.
357371 */
358- int secp256k1_ecdsa_sign (
372+ SECP256K1_API int secp256k1_ecdsa_sign (
359373 const secp256k1_context * ctx ,
360374 secp256k1_ecdsa_signature * sig ,
361375 const unsigned char * msg32 ,
@@ -371,7 +385,7 @@ int secp256k1_ecdsa_sign(
371385 * Args: ctx: pointer to a context object (cannot be NULL)
372386 * In: seckey: pointer to a 32-byte secret key (cannot be NULL)
373387 */
374- SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify (
388+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify (
375389 const secp256k1_context * ctx ,
376390 const unsigned char * seckey
377391) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 );
@@ -384,7 +398,7 @@ SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify(
384398 * Out: pubkey: pointer to the created public key (cannot be NULL)
385399 * In: seckey: pointer to a 32-byte private key (cannot be NULL)
386400 */
387- SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create (
401+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create (
388402 const secp256k1_context * ctx ,
389403 secp256k1_pubkey * pubkey ,
390404 const unsigned char * seckey
@@ -410,7 +424,7 @@ SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create(
410424 * Note that this function does not guarantee correct DER output. It is
411425 * guaranteed to be parsable by secp256k1_ec_privkey_import.
412426 */
413- SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_export (
427+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_export (
414428 const secp256k1_context * ctx ,
415429 unsigned char * privkey ,
416430 size_t * privkeylen ,
@@ -432,7 +446,7 @@ SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_export(
432446 * only if you know in advance it is supposed to contain a secp256k1 private
433447 * key.
434448 */
435- SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_import (
449+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_import (
436450 const secp256k1_context * ctx ,
437451 unsigned char * seckey ,
438452 const unsigned char * privkey ,
@@ -448,7 +462,7 @@ SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_import(
448462 * In/Out: seckey: pointer to a 32-byte private key.
449463 * In: tweak: pointer to a 32-byte tweak.
450464 */
451- SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add (
465+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add (
452466 const secp256k1_context * ctx ,
453467 unsigned char * seckey ,
454468 const unsigned char * tweak
@@ -464,7 +478,7 @@ SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add(
464478 * In/Out: pubkey: pointer to a public key object.
465479 * In: tweak: pointer to a 32-byte tweak.
466480 */
467- SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add (
481+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add (
468482 const secp256k1_context * ctx ,
469483 secp256k1_pubkey * pubkey ,
470484 const unsigned char * tweak
@@ -477,7 +491,7 @@ SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(
477491 * In/Out: seckey: pointer to a 32-byte private key.
478492 * In: tweak: pointer to a 32-byte tweak.
479493 */
480- SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul (
494+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul (
481495 const secp256k1_context * ctx ,
482496 unsigned char * seckey ,
483497 const unsigned char * tweak
@@ -491,7 +505,7 @@ SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul(
491505 * In/Out: pubkey: pointer to a public key obkect.
492506 * In: tweak: pointer to a 32-byte tweak.
493507 */
494- SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul (
508+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul (
495509 const secp256k1_context * ctx ,
496510 secp256k1_pubkey * pubkey ,
497511 const unsigned char * tweak
@@ -503,7 +517,7 @@ SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul(
503517 * Args: ctx: pointer to a context object (cannot be NULL)
504518 * In: seed32: pointer to a 32-byte random seed (NULL resets to initial state)
505519 */
506- SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize (
520+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize (
507521 secp256k1_context * ctx ,
508522 const unsigned char * seed32
509523) SECP256K1_ARG_NONNULL (1 );
@@ -519,7 +533,7 @@ SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize(
519533 * Use secp256k1_ec_pubkey_compress and secp256k1_ec_pubkey_decompress if the
520534 * uncompressed format is needed.
521535 */
522- SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine (
536+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine (
523537 const secp256k1_context * ctx ,
524538 secp256k1_pubkey * out ,
525539 const secp256k1_pubkey * const * ins ,
0 commit comments