aboutsummaryrefslogtreecommitdiff
path: root/src/secp256k1/include/secp256k1.h
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-07-18 15:25:05 +0100
committerfanquake <fanquake@gmail.com>2023-07-18 15:25:05 +0100
commit8ee662984fccf055901ecba0bf81dbf47ed734e7 (patch)
tree52c86d39e3dbf04be4e50cd84a120f4563819d6b /src/secp256k1/include/secp256k1.h
parent673acab223c0f896767b1ae784659df9f95452ae (diff)
parentff061fde183f68d3b77db24b5742f54e58952de6 (diff)
downloadbitcoin-8ee662984fccf055901ecba0bf81dbf47ed734e7.tar.xz
Update secp256k1 subtree to latest upstream master
Diffstat (limited to 'src/secp256k1/include/secp256k1.h')
-rw-r--r--src/secp256k1/include/secp256k1.h63
1 files changed, 35 insertions, 28 deletions
diff --git a/src/secp256k1/include/secp256k1.h b/src/secp256k1/include/secp256k1.h
index a7a2be7a3a..936f0b42b7 100644
--- a/src/secp256k1/include/secp256k1.h
+++ b/src/secp256k1/include/secp256k1.h
@@ -133,28 +133,35 @@ typedef int (*secp256k1_nonce_function)(
# define SECP256K1_NO_BUILD
#endif
-/* Symbol visibility. See libtool manual, section "Windows DLLs". */
-#if defined(_WIN32) && !defined(__GNUC__)
-# ifdef SECP256K1_BUILD
-# ifdef DLL_EXPORT
-# define SECP256K1_API __declspec (dllexport)
-# define SECP256K1_API_VAR extern __declspec (dllexport)
+/* Symbol visibility. */
+#if defined(_WIN32)
+ /* GCC for Windows (e.g., MinGW) accepts the __declspec syntax
+ * for MSVC compatibility. A __declspec declaration implies (but is not
+ * exactly equivalent to) __attribute__ ((visibility("default"))), and so we
+ * actually want __declspec even on GCC, see "Microsoft Windows Function
+ * Attributes" in the GCC manual and the recommendations in
+ * https://gcc.gnu.org/wiki/Visibility. */
+# if defined(SECP256K1_BUILD)
+# if defined(DLL_EXPORT) || defined(SECP256K1_DLL_EXPORT)
+ /* Building libsecp256k1 as a DLL.
+ * 1. If using Libtool, it defines DLL_EXPORT automatically.
+ * 2. In other cases, SECP256K1_DLL_EXPORT must be defined. */
+# define SECP256K1_API extern __declspec (dllexport)
# endif
-# elif defined _MSC_VER
-# define SECP256K1_API
-# define SECP256K1_API_VAR extern __declspec (dllimport)
-# elif defined DLL_EXPORT
-# define SECP256K1_API __declspec (dllimport)
-# define SECP256K1_API_VAR extern __declspec (dllimport)
+ /* The user must define SECP256K1_STATIC when consuming libsecp256k1 as a static
+ * library on Windows. */
+# elif !defined(SECP256K1_STATIC)
+ /* Consuming libsecp256k1 as a DLL. */
+# define SECP256K1_API extern __declspec (dllimport)
# endif
#endif
#ifndef SECP256K1_API
# if defined(__GNUC__) && (__GNUC__ >= 4) && defined(SECP256K1_BUILD)
-# define SECP256K1_API __attribute__ ((visibility ("default")))
-# define SECP256K1_API_VAR extern __attribute__ ((visibility ("default")))
+ /* Building libsecp256k1 on non-Windows using GCC or compatible. */
+# define SECP256K1_API extern __attribute__ ((visibility ("default")))
# else
-# define SECP256K1_API
-# define SECP256K1_API_VAR extern
+ /* All cases not captured above. */
+# define SECP256K1_API extern
# endif
#endif
@@ -226,10 +233,10 @@ typedef int (*secp256k1_nonce_function)(
*
* It is highly recommended to call secp256k1_selftest before using this context.
*/
-SECP256K1_API_VAR const secp256k1_context *secp256k1_context_static;
+SECP256K1_API const secp256k1_context *secp256k1_context_static;
/** Deprecated alias for secp256k1_context_static. */
-SECP256K1_API_VAR const secp256k1_context *secp256k1_context_no_precomp
+SECP256K1_API const secp256k1_context *secp256k1_context_no_precomp
SECP256K1_DEPRECATED("Use secp256k1_context_static instead");
/** Perform basic self tests (to be used in conjunction with secp256k1_context_static)
@@ -626,10 +633,10 @@ SECP256K1_API int secp256k1_ecdsa_signature_normalize(
* If a data pointer is passed, it is assumed to be a pointer to 32 bytes of
* extra entropy.
*/
-SECP256K1_API_VAR const secp256k1_nonce_function secp256k1_nonce_function_rfc6979;
+SECP256K1_API const secp256k1_nonce_function secp256k1_nonce_function_rfc6979;
/** A default safe nonce generation function (currently equal to secp256k1_nonce_function_rfc6979). */
-SECP256K1_API_VAR const secp256k1_nonce_function secp256k1_nonce_function_default;
+SECP256K1_API const secp256k1_nonce_function secp256k1_nonce_function_default;
/** Create an ECDSA signature.
*
@@ -733,10 +740,10 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_negate(
* invalid according to secp256k1_ec_seckey_verify, this
* function returns 0. seckey will be set to some unspecified
* value if this function returns 0.
- * In: tweak32: pointer to a 32-byte tweak. If the tweak is invalid according to
- * secp256k1_ec_seckey_verify, this function returns 0. For
- * uniformly random 32-byte arrays the chance of being invalid
- * is negligible (around 1 in 2^128).
+ * In: tweak32: pointer to a 32-byte tweak, which must be valid according to
+ * secp256k1_ec_seckey_verify or 32 zero bytes. For uniformly
+ * random 32-byte tweaks, the chance of being invalid is
+ * negligible (around 1 in 2^128).
*/
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_tweak_add(
const secp256k1_context *ctx,
@@ -761,10 +768,10 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add(
* Args: ctx: pointer to a context object.
* In/Out: pubkey: pointer to a public key object. pubkey will be set to an
* invalid value if this function returns 0.
- * In: tweak32: pointer to a 32-byte tweak. If the tweak is invalid according to
- * secp256k1_ec_seckey_verify, this function returns 0. For
- * uniformly random 32-byte arrays the chance of being invalid
- * is negligible (around 1 in 2^128).
+ * In: tweak32: pointer to a 32-byte tweak, which must be valid according to
+ * secp256k1_ec_seckey_verify or 32 zero bytes. For uniformly
+ * random 32-byte tweaks, the chance of being invalid is
+ * negligible (around 1 in 2^128).
*/
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(
const secp256k1_context *ctx,