Browse Source

try things

tb
ofek 7 years ago
parent
commit
6d7bb51363
  1. 1
      _cffi_build/build.py
  2. 14
      _cffi_build/lax_der_privatekey_parsing.h
  3. 18
      coincurve/_windows_libsecp256k1.py
  4. 50
      release.py

1
_cffi_build/build.py

@ -27,6 +27,7 @@ modules = [
Source('secp256k1.h', '#include <secp256k1.h>'),
Source('secp256k1_ecdh.h', '#include <secp256k1_ecdh.h>'),
Source('secp256k1_recovery.h', '#include <secp256k1_recovery.h>'),
Source('lax_der_privatekey_parsing.h', '#include <lax_der_privatekey_parsing.h>'),
]
ffi = _mk_ffi(modules, libraries=['secp256k1'])

14
_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);

18
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'))

50
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()
Loading…
Cancel
Save