Browse Source

update to new build infra, python 3, and add instructions..

pyupdate
John-Mark Gurney 2 years ago
parent
commit
048bfefe65
3 changed files with 40 additions and 15 deletions
  1. +27
    -0
      python/README.md
  2. +7
    -12
      python/edgold/ed448.py
  3. +6
    -3
      python/setup.py

+ 27
- 0
python/README.md View File

@@ -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)
```

+ 7
- 12
python/edgold/ed448.py View File

@@ -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))


+ 6
- 3
python/setup.py View File

@@ -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',


Loading…
Cancel
Save