Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for SECP256K1 v0.4.1 #131

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
802fb77
(feat) secp256k1 v0.4.0
MementoRC Dec 19, 2023
35c8680
(feat) CFFI for new support
MementoRC Dec 20, 2023
93b69b8
(fix) Could not figure out why egg_info adds absolute paths. Prune them
MementoRC Dec 20, 2023
778887e
(feat) Use TOML project definition. Version bump to 19.0.0
MementoRC Dec 20, 2023
6a9380d
(feat) Use TOML project definition. Version bump to 19.0.0
MementoRC Dec 20, 2023
d88e47d
(feat) tox with python 3.12
MementoRC Dec 20, 2023
bfaa1b0
(fix) copy-paste fumble
MementoRC Dec 20, 2023
bfcc546
(fix) missing EOL
MementoRC Dec 20, 2023
4242b8c
(fix) relaxed setuptools constraint
MementoRC Dec 20, 2023
4aa3b09
(fix) issues with mkdocstring
MementoRC Dec 20, 2023
a2654cd
(ref) remove unnecessary dependence
MementoRC Dec 20, 2023
e56a4d6
(ref) remove deprecated functions
MementoRC Dec 20, 2023
90f33ab
(fea) selectable download using pkg-config
MementoRC Dec 20, 2023
9022b08
(fix) path to header for windows
MementoRC Dec 20, 2023
cdc504a
(fix) don't remember why zzz
MementoRC Dec 20, 2023
50be3d5
(fix) bypass download for windows?
MementoRC Dec 20, 2023
948709e
(fix) bypass download for windows. lint check
MementoRC Dec 20, 2023
b8de00c
(fix) use pkgconfig to resolve lib location in windows?
MementoRC Dec 20, 2023
c633c65
(fix) odd ruff fail
MementoRC Dec 20, 2023
ff76128
(dbg) trying to figure out the windows annoyance
MementoRC Dec 20, 2023
45fc8ad
(dbg) trying to figure out the windows annoyance
MementoRC Dec 21, 2023
5e03265
(fix) ffi.dlopen() needs full lib name under windows?
MementoRC Dec 21, 2023
e6ad6a4
(dbg) linking on windows requires to prepend with 'lib', how to do that?
MementoRC Dec 21, 2023
bd0afe0
(fix) linking on windows requires to prepend with 'lib'
MementoRC Dec 21, 2023
5dffd77
(fix) catch PackageNotFoundError when detecting system libsecp256k1
MementoRC Dec 21, 2023
5183f60
(fix) wrong PackageNotFoundError?
MementoRC Dec 21, 2023
3b2bddc
(dbg) libname on windows
MementoRC Dec 21, 2023
e668925
(fix) build for linking shared libsecp256k1 on windows
MementoRC Dec 22, 2023
caf243c
Apply suggestions from code review
ofek Dec 24, 2023
42ddb17
(ref) Move library to API (instead of ABI)
MementoRC Dec 25, 2023
e8f063d
Merge remote-tracking branch 'origin/feat/update_v0.4.0' into feat/up…
MementoRC Dec 25, 2023
2d67b16
(fix) There's an issue with import pkgconfig on windows ...
MementoRC Dec 25, 2023
3e113bf
(fix) There's an issue with import pkgconfig on windows ...
MementoRC Dec 25, 2023
fb6c6a5
(fix) Turning in circles around windows ...
MementoRC Dec 25, 2023
62c0867
(fix) Turning in circles around windows ...
MementoRC Dec 25, 2023
a2a0f8d
(fix) The issue is when building with setup.py (not TOML)
MementoRC Dec 25, 2023
f80097e
(fix) remove pkgconfig, usr pkg-config instead?
MementoRC Dec 26, 2023
cd4239f
(fix) fmt
MementoRC Dec 26, 2023
79e3ca3
(fix) subprocess fails if command exists with 1
MementoRC Dec 26, 2023
20438f3
(fix) back to guessing game :\
MementoRC Dec 26, 2023
8a80653
(ref) Let's have a pkg name, UNKNOWN-0.0.0 is too mysterious
MementoRC Dec 26, 2023
67ff706
(fea) Update to SECP256K1 v0.4.1
MementoRC Dec 26, 2023
ec5f8ff
(fea) which part of "IMPORTANT: Keep in sync" did I not understand?
MementoRC Dec 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include coincurve/py.typed
include setup_support.py
recursive-include _cffi_build *.py *.h
prune /*
graft libsecp256k1
2 changes: 2 additions & 0 deletions _cffi_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def _mk_ffi(sources, name='_libsecp256k1', **kwargs):
Source('secp256k1_extrakeys.h', '#include <secp256k1_extrakeys.h>'),
Source('secp256k1_recovery.h', '#include <secp256k1_recovery.h>'),
Source('secp256k1_schnorrsig.h', '#include <secp256k1_schnorrsig.h>'),
Source('secp256k1_ellswift.h', '#include <secp256k1_ellswift.h>'),
Source('secp256k1_preallocated.h', '#include <secp256k1_preallocated.h>'),
]

ffi = _mk_ffi(modules, libraries=['secp256k1'])
254 changes: 131 additions & 123 deletions _cffi_build/secp256k1.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
typedef struct secp256k1_context_struct secp256k1_context;
typedef struct secp256k1_scratch_space_struct secp256k1_scratch_space;

typedef struct {
unsigned char data[64];
} secp256k1_pubkey;

typedef struct {
unsigned char data[64];
} secp256k1_ecdsa_signature;

typedef int (*secp256k1_nonce_function)(
unsigned char *nonce32,
const unsigned char *msg32,
Expand All @@ -17,172 +14,183 @@ typedef int (*secp256k1_nonce_function)(
void *data,
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_CONTEXT_NONE ...

#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 ...
#define SECP256K1_TAG_PUBKEY_HYBRID_EVEN ...
#define SECP256K1_TAG_PUBKEY_HYBRID_ODD ...

void secp256k1_selftest(void);

secp256k1_context* secp256k1_context_create(
extern const secp256k1_context *secp256k1_context_static;
extern const secp256k1_context *secp256k1_context_no_precomp
;
extern void secp256k1_selftest(void);
extern secp256k1_context *secp256k1_context_create(
unsigned int flags
);

secp256k1_context* secp256k1_context_clone(
const secp256k1_context* ctx
);

void secp256k1_context_destroy(
secp256k1_context* ctx
);

void secp256k1_context_set_illegal_callback(
secp256k1_context* ctx,
void (*fun)(const char* message, void* data),
const void* data
);

void secp256k1_context_set_error_callback(
secp256k1_context* ctx,
void (*fun)(const char* message, void* data),
const void* data
);

secp256k1_scratch_space* secp256k1_scratch_space_create(
const secp256k1_context* ctx,
) ;
extern secp256k1_context *secp256k1_context_clone(
const secp256k1_context *ctx
) ;
extern void secp256k1_context_destroy(
secp256k1_context *ctx
) ;
extern void secp256k1_context_set_illegal_callback(
secp256k1_context *ctx,
void (*fun)(const char *message, void *data),
const void *data
) ;
extern void secp256k1_context_set_error_callback(
secp256k1_context *ctx,
void (*fun)(const char *message, void *data),
const void *data
) ;
extern secp256k1_scratch_space *secp256k1_scratch_space_create(
const secp256k1_context *ctx,
size_t size
);

int secp256k1_ec_pubkey_parse(
const secp256k1_context* ctx,
secp256k1_pubkey* pubkey,
) ;
extern void secp256k1_scratch_space_destroy(
const secp256k1_context *ctx,
secp256k1_scratch_space *scratch
) ;
extern int secp256k1_ec_pubkey_parse(
const secp256k1_context *ctx,
secp256k1_pubkey *pubkey,
const unsigned char *input,
size_t inputlen
);

int secp256k1_ec_pubkey_serialize(
const secp256k1_context* ctx,
) ;
extern int secp256k1_ec_pubkey_serialize(
const secp256k1_context *ctx,
unsigned char *output,
size_t *outputlen,
const secp256k1_pubkey* pubkey,
const secp256k1_pubkey *pubkey,
unsigned int flags
);

int secp256k1_ecdsa_signature_parse_compact(
const secp256k1_context* ctx,
secp256k1_ecdsa_signature* sig,
) ;
extern int secp256k1_ec_pubkey_cmp(
const secp256k1_context *ctx,
const secp256k1_pubkey *pubkey1,
const secp256k1_pubkey *pubkey2
) ;
extern int secp256k1_ecdsa_signature_parse_compact(
const secp256k1_context *ctx,
secp256k1_ecdsa_signature *sig,
const unsigned char *input64
);

int secp256k1_ecdsa_signature_parse_der(
const secp256k1_context* ctx,
secp256k1_ecdsa_signature* sig,
) ;
extern int secp256k1_ecdsa_signature_parse_der(
const secp256k1_context *ctx,
secp256k1_ecdsa_signature *sig,
const unsigned char *input,
size_t inputlen
);

int secp256k1_ecdsa_signature_serialize_der(
const secp256k1_context* ctx,
) ;
extern int secp256k1_ecdsa_signature_serialize_der(
const secp256k1_context *ctx,
unsigned char *output,
size_t *outputlen,
const secp256k1_ecdsa_signature* sig
);

int secp256k1_ecdsa_signature_serialize_compact(
const secp256k1_context* ctx,
const secp256k1_ecdsa_signature *sig
) ;
extern int secp256k1_ecdsa_signature_serialize_compact(
const secp256k1_context *ctx,
unsigned char *output64,
const secp256k1_ecdsa_signature* sig
);

int secp256k1_ecdsa_verify(
const secp256k1_context* ctx,
const secp256k1_ecdsa_signature *sig
) ;
extern int secp256k1_ecdsa_verify(
const secp256k1_context *ctx,
const secp256k1_ecdsa_signature *sig,
const unsigned char *msg32,
const unsigned char *msghash32,
const secp256k1_pubkey *pubkey
);

int secp256k1_ecdsa_signature_normalize(
const secp256k1_context* ctx,
) ;
extern int secp256k1_ecdsa_signature_normalize(
const secp256k1_context *ctx,
secp256k1_ecdsa_signature *sigout,
const secp256k1_ecdsa_signature *sigin
);

) ;
extern const secp256k1_nonce_function secp256k1_nonce_function_rfc6979;

extern const secp256k1_nonce_function secp256k1_nonce_function_default;

int secp256k1_ecdsa_sign(
const secp256k1_context* ctx,
extern int secp256k1_ecdsa_sign(
const secp256k1_context *ctx,
secp256k1_ecdsa_signature *sig,
const unsigned char *msg32,
const unsigned char *msghash32,
const unsigned char *seckey,
secp256k1_nonce_function noncefp,
const void *ndata
);

int secp256k1_ec_seckey_verify(
const secp256k1_context* ctx,
) ;
extern int secp256k1_ec_seckey_verify(
const secp256k1_context *ctx,
const unsigned char *seckey
);

int secp256k1_ec_pubkey_create(
const secp256k1_context* ctx,
) ;
extern int secp256k1_ec_pubkey_create(
const secp256k1_context *ctx,
secp256k1_pubkey *pubkey,
const unsigned char *seckey
);

int secp256k1_ec_privkey_tweak_add(
const secp256k1_context* ctx,
) ;
extern int secp256k1_ec_seckey_negate(
const secp256k1_context *ctx,
unsigned char *seckey
) ;
extern int secp256k1_ec_privkey_negate(
const secp256k1_context *ctx,
unsigned char *seckey
)
;
extern int secp256k1_ec_pubkey_negate(
const secp256k1_context *ctx,
secp256k1_pubkey *pubkey
) ;
extern int secp256k1_ec_seckey_tweak_add(
const secp256k1_context *ctx,
unsigned char *seckey,
const unsigned char *tweak
);

int secp256k1_ec_pubkey_tweak_add(
const secp256k1_context* ctx,
const unsigned char *tweak32
) ;
extern int secp256k1_ec_privkey_tweak_add(
const secp256k1_context *ctx,
unsigned char *seckey,
const unsigned char *tweak32
)
;
extern int secp256k1_ec_pubkey_tweak_add(
const secp256k1_context *ctx,
secp256k1_pubkey *pubkey,
const unsigned char *tweak
);

int secp256k1_ec_privkey_tweak_mul(
const secp256k1_context* ctx,
const unsigned char *tweak32
) ;
extern int secp256k1_ec_seckey_tweak_mul(
const secp256k1_context *ctx,
unsigned char *seckey,
const unsigned char *tweak
);

int secp256k1_ec_pubkey_tweak_mul(
const secp256k1_context* ctx,
const unsigned char *tweak32
) ;
extern int secp256k1_ec_privkey_tweak_mul(
const secp256k1_context *ctx,
unsigned char *seckey,
const unsigned char *tweak32
)
;
extern int secp256k1_ec_pubkey_tweak_mul(
const secp256k1_context *ctx,
secp256k1_pubkey *pubkey,
const unsigned char *tweak
);

int secp256k1_context_randomize(
secp256k1_context* ctx,
const unsigned char *tweak32
) ;
extern int secp256k1_context_randomize(
secp256k1_context *ctx,
const unsigned char *seed32
);

int secp256k1_ec_pubkey_combine(
const secp256k1_context* ctx,
) ;
extern int secp256k1_ec_pubkey_combine(
const secp256k1_context *ctx,
secp256k1_pubkey *out,
const secp256k1_pubkey * const * ins,
const secp256k1_pubkey * const *ins,
size_t n
);
) ;
extern 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
) ;
20 changes: 14 additions & 6 deletions _cffi_build/secp256k1_ecdh.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
int secp256k1_ecdh(
const secp256k1_context* ctx,
unsigned char *result,
const secp256k1_pubkey *pubkey,
const unsigned char *privkey,
void *hashfp,
typedef int (*secp256k1_ecdh_hash_function)(
unsigned char *output,
const unsigned char *x32,
const unsigned char *y32,
void *data
);
extern const secp256k1_ecdh_hash_function secp256k1_ecdh_hash_function_sha256;
extern const secp256k1_ecdh_hash_function secp256k1_ecdh_hash_function_default;
extern 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
) ;
36 changes: 36 additions & 0 deletions _cffi_build/secp256k1_ellswift.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
typedef int (*secp256k1_ellswift_xdh_hash_function)(
unsigned char *output,
const unsigned char *x32,
const unsigned char *ell_a64,
const unsigned char *ell_b64,
void *data
);
extern const secp256k1_ellswift_xdh_hash_function secp256k1_ellswift_xdh_hash_function_prefix;
extern const secp256k1_ellswift_xdh_hash_function secp256k1_ellswift_xdh_hash_function_bip324;
extern int secp256k1_ellswift_encode(
const secp256k1_context *ctx,
unsigned char *ell64,
const secp256k1_pubkey *pubkey,
const unsigned char *rnd32
) ;
extern int secp256k1_ellswift_decode(
const secp256k1_context *ctx,
secp256k1_pubkey *pubkey,
const unsigned char *ell64
) ;
extern int secp256k1_ellswift_create(
const secp256k1_context *ctx,
unsigned char *ell64,
const unsigned char *seckey32,
const unsigned char *auxrnd32
) ;
extern 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
) ;
Loading
Loading