From dcceac2e87c1f1246d6b5029aaac6fdfa02d97a1 Mon Sep 17 00:00:00 2001 From: Claire's Monster Date: Fri, 26 Jan 2024 09:53:02 -0600 Subject: [PATCH] FIX: windows package fails with: AttributeError: SECP256K1_CONTEXT_SIGN (#137) --- coincurve/_windows_libsecp256k1.py | 33 +++++++++++++----------------- coincurve/keys.py | 4 ++-- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/coincurve/_windows_libsecp256k1.py b/coincurve/_windows_libsecp256k1.py index 07b07961f..34166b877 100644 --- a/coincurve/_windows_libsecp256k1.py +++ b/coincurve/_windows_libsecp256k1.py @@ -23,27 +23,22 @@ unsigned int attempt ); -#define SECP256K1_FLAGS_TYPE_MASK ... -#define SECP256K1_FLAGS_TYPE_CONTEXT ... -#define SECP256K1_FLAGS_TYPE_COMPRESSION ... -#define SECP256K1_FLAGS_BIT_CONTEXT_VERIFY ... -#define SECP256K1_FLAGS_BIT_CONTEXT_SIGN ... -#define SECP256K1_FLAGS_BIT_CONTEXT_DECLASSIFY ... -#define SECP256K1_FLAGS_BIT_COMPRESSION ... +#define SECP256K1_FLAGS_TYPE_MASK 255 +#define SECP256K1_FLAGS_TYPE_CONTEXT 1 +#define SECP256K1_FLAGS_TYPE_COMPRESSION 2 +#define SECP256K1_FLAGS_BIT_CONTEXT_VERIFY 256 +#define SECP256K1_FLAGS_BIT_CONTEXT_SIGN 512 +#define SECP256K1_FLAGS_BIT_CONTEXT_DECLASSIFY 1024 +#define SECP256K1_FLAGS_BIT_COMPRESSION 256 +#define SECP256K1_TAG_PUBKEY_EVEN 2 +#define SECP256K1_TAG_PUBKEY_ODD 3 +#define SECP256K1_TAG_PUBKEY_UNCOMPRESSED 4 -#define SECP256K1_CONTEXT_NONE ... +#define SECP256K1_CONTEXT_NONE 1 +#define SECP256K1_CONTEXT_DECLASSIFY 1025 +#define SECP256K1_EC_COMPRESSED 258 +#define SECP256K1_EC_UNCOMPRESSED 2 -#define SECP256K1_CONTEXT_VERIFY ... -#define SECP256K1_CONTEXT_SIGN ... - -#define SECP256K1_CONTEXT_DECLASSIFY ... - -#define SECP256K1_EC_COMPRESSED ... -#define SECP256K1_EC_UNCOMPRESSED ... - -#define SECP256K1_TAG_PUBKEY_EVEN ... -#define SECP256K1_TAG_PUBKEY_ODD ... -#define SECP256K1_TAG_PUBKEY_UNCOMPRESSED ... extern const secp256k1_context *secp256k1_context_static; extern void secp256k1_selftest(void); extern secp256k1_context *secp256k1_context_create( diff --git a/coincurve/keys.py b/coincurve/keys.py index 3285bd25e..8f8ac9458 100644 --- a/coincurve/keys.py +++ b/coincurve/keys.py @@ -407,7 +407,7 @@ def combine_keys(cls, public_keys, context: Context = GLOBAL_CONTEXT): return PublicKey(public_key, context) - def format(self, compressed: bool = True) -> bytes: # noqa: A003 + def format(self, compressed: bool = True) -> bytes: """ Format the public key. @@ -579,7 +579,7 @@ def from_valid_secret(cls, secret: bytes, context: Context = GLOBAL_CONTEXT): return cls(xonly_pubkey, parity=not not pk_parity[0], context=context) - def format(self) -> bytes: # noqa: A003 + def format(self) -> bytes: """Serialize the public key. :return: The public key serialized as 32 bytes.