From 048bfefe65121d11a11bc5f2bdf78744a9178200 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Sat, 10 Sep 2022 23:50:16 -0700 Subject: [PATCH] update to new build infra, python 3, and add instructions.. --- python/README.md | 27 +++++++++++++++++++++++++++ python/edgold/ed448.py | 19 +++++++------------ python/setup.py | 9 ++++++--- 3 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 python/README.md diff --git a/python/README.md b/python/README.md new file mode 100644 index 0000000..0a1d7ac --- /dev/null +++ b/python/README.md @@ -0,0 +1,27 @@ +Installation +------------ + +The easiest way to install is to run the command: +``` +pip install 'git+https://git.code.sf.net/p/ed448goldilocks/code#egg=edgold&subdirectory=python' +``` + +Usage +----- + +This wraps the Ed448 code into a simple to use class, EDDSA448. The +easiest way to geenrate a new key is to use the generate class method. + +Example: +``` +from edgold.ed448 import EDDSA448 + +key = EDDSA448.generate() +privkey = key.export(key('raw') +msg = b'This is a message to sign' +sig = key.sign(msg) + +pubkey = key.public_key().export_key('raw') +key = EDDSA448(pub=pubkey) +key.verify(sig, msg) +``` diff --git a/python/edgold/ed448.py b/python/edgold/ed448.py index 7cde068..7cafa63 100644 --- a/python/edgold/ed448.py +++ b/python/edgold/ed448.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2017 John-Mark Gurney. +# Copyright 2017, 2022 John-Mark Gurney. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -33,10 +33,11 @@ of signing due to the complexity of integration w/ the library, and that things should be more simple to use.''' __author__ = 'John-Mark Gurney' -__copyright__ = 'Copyright 2017 John-Mark Gurney''' -__license__ = 'BSD' -__version__ = '0.1' -__status__ = 'alpha' +__copyright__ = 'Copyright 2017, 2022 John-Mark Gurney''' +__license__ = 'BSD-2-Clause' +__version__ = '1.0' + +__all__ = [ 'EDDSA448', 'generate' ] import array import os @@ -94,13 +95,7 @@ def _makeba(s): return r def _makestr(a): - # XXX - because python3 sucks, and unittest doesn't offer - # ability to silence stupid warnings, hide the tostring - # DeprecationWarning. - with warnings.catch_warnings(): - warnings.simplefilter('ignore') - return array.array('B', a).tostring() - + return bytes(a) def _ed448_privkey(): return _makeba(os.urandom(DECAF_EDDSA_448_PRIVATE_BYTES)) diff --git a/python/setup.py b/python/setup.py index ade3b4a..dcaeeb0 100644 --- a/python/setup.py +++ b/python/setup.py @@ -4,19 +4,22 @@ from distutils.command.build import build from distutils.core import setup import os +import sys + +libext = dict(darwin='.dylib').get(sys.platform, '.so') class my_build(build): def run(self): build.run(self) if not self.dry_run: - os.spawnlp(os.P_WAIT, 'sh', 'sh', '-c', 'cd .. && gmake lib') - self.copy_file(os.path.join('..', 'build', 'lib', 'libdecaf.so'), os.path.join(self.build_lib, 'edgold')) + os.spawnlp(os.P_WAIT, 'sh', 'sh', '-c', 'cd .. && mkdir build && cd build && cmake .. && make') + self.copy_file(os.path.join('..', 'build', 'src', 'libdecaf.0' + libext), os.path.join(self.build_lib, 'edgold', 'libdecaf.so')) cmdclass = {} cmdclass['build'] = my_build setup(name='edgold', - version='0.1', + version='1.0', description='The Ed ECC Goldilocks Python wrapper', author='John-Mark Gurney', author_email='jmg@funkthat.com',