diff --git a/_cffi_build/build.py b/_cffi_build/build.py index ea5c66c..ff1d10a 100644 --- a/_cffi_build/build.py +++ b/_cffi_build/build.py @@ -27,6 +27,7 @@ modules = [ Source('secp256k1.h', '#include '), Source('secp256k1_ecdh.h', '#include '), Source('secp256k1_recovery.h', '#include '), + Source('lax_der_privatekey_parsing.h', '#include '), ] ffi = _mk_ffi(modules, libraries=['secp256k1']) diff --git a/_cffi_build/lax_der_privatekey_parsing.h b/_cffi_build/lax_der_privatekey_parsing.h new file mode 100644 index 0000000..377788b --- /dev/null +++ b/_cffi_build/lax_der_privatekey_parsing.h @@ -0,0 +1,14 @@ +int ec_privkey_export_der( + const secp256k1_context* ctx, + unsigned char *privkey, + size_t *privkeylen, + const unsigned char *seckey, + int compressed +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +int ec_privkey_import_der( + const secp256k1_context* ctx, + unsigned char *seckey, + const unsigned char *privkey, + size_t privkeylen +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); diff --git a/coincurve/_windows_libsecp256k1.py b/coincurve/_windows_libsecp256k1.py index 55ac4ab..eed5cbf 100644 --- a/coincurve/_windows_libsecp256k1.py +++ b/coincurve/_windows_libsecp256k1.py @@ -227,11 +227,29 @@ int secp256k1_ecdh( ); """ +DER_DEFINITIONS = """ +int ec_privkey_export_der( + const secp256k1_context* ctx, + unsigned char *privkey, + size_t *privkeylen, + const unsigned char *seckey, + int compressed +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +int ec_privkey_import_der( + const secp256k1_context* ctx, + unsigned char *seckey, + const unsigned char *privkey, + size_t privkeylen +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); +""" + ffi = FFI() ffi.cdef(BASE_DEFINITIONS) ffi.cdef(RECOVERY_DEFINITIONS) ffi.cdef(ECDH_DEFINITIONS) +ffi.cdef(DER_DEFINITIONS) here = os.path.dirname(os.path.abspath(__file__)) lib = ffi.dlopen(os.path.join(here, 'libsecp256k1.dll')) diff --git a/release.py b/release.py new file mode 100644 index 0000000..663b8e4 --- /dev/null +++ b/release.py @@ -0,0 +1,50 @@ +import os +import subprocess +import sys + +import appdirs + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + os.chdir(here) + + version = sys.argv[-1] + delete = not not sys.argv[-2] == '-d' + delete_only = not not sys.argv[-2] == '--d' + + try: + subprocess.call('git -h') + git_path = 'git' + except: + git_path = None + + # Assume Windows portable Git + if git_path is None: + github_dir = os.path.join(appdirs.user_data_dir(), 'GitHub') + for d in os.listdir(github_dir): + if d.startswith('PortableGit'): + git_path = os.path.join(github_dir, d, 'cmd', 'git.exe') + + if git_path is None: + raise OSError('Unable to find git executable.') + + cmds = [ + '{0} tag -a {1} -m "Version {1}"'.format(git_path, version), + '{} push origin {}'.format(git_path, version) + ] + delete_cmd = '{} tag -d {}'.format(git_path, version) + + if delete: + cmds.insert(0, delete_cmd) + elif delete_only: + cmds = [delete_cmd] + + for cmd in cmds: + subprocess.call(cmd) + + print(cmds) + + +if __name__ == '__main__': + main()