Roll out the new boilerplate
This commit is contained in:
25
hypercore_crypto/__init__.py
Normal file
25
hypercore_crypto/__init__.py
Normal file
@ -0,0 +1,25 @@
|
||||
"""hypercore-crypto module."""
|
||||
|
||||
from hypercore_crypto.crypto import ( # noqa
|
||||
blake2b,
|
||||
data,
|
||||
discovery_key,
|
||||
encode_unsigned_int64,
|
||||
leaf,
|
||||
parent,
|
||||
random_bytes,
|
||||
sign,
|
||||
tree,
|
||||
verify,
|
||||
)
|
||||
|
||||
try:
|
||||
import pkg_resources
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
__version__ = pkg_resources.get_distribution('hypercore_crypto').version
|
||||
except Exception:
|
||||
__version__ = 'unknown'
|
69
hypercore_crypto/crypto.py
Normal file
69
hypercore_crypto/crypto.py
Normal file
@ -0,0 +1,69 @@
|
||||
"""Cryptography primitives for Hypercore."""
|
||||
|
||||
from nacl.bindings import (
|
||||
crypto_sign_keypair,
|
||||
crypto_sign_PUBLICKEYBYTES,
|
||||
crypto_sign_SECRETKEYBYTES,
|
||||
crypto_sign_seed_keypair,
|
||||
)
|
||||
|
||||
# https://en.wikipedia.org/wiki/Merkle_tree#Second_preimage_attack
|
||||
LEAF_TYPE = bytearray([0])
|
||||
PARENT_TYPE = bytearray([1])
|
||||
ROOT_TYPE = bytearray([2])
|
||||
HYPERCORE = bytearray('hypercore', encoding='utf-8')
|
||||
|
||||
|
||||
# TODO(decentral1se): don't forget to type this
|
||||
def key_pair(seed=None):
|
||||
"""The signed public/secret key length."""
|
||||
|
||||
public_key = bytearray(crypto_sign_PUBLICKEYBYTES)
|
||||
secret_key = bytearray(crypto_sign_SECRETKEYBYTES)
|
||||
|
||||
if seed:
|
||||
crypto_sign_seed_keypair(public_key, secret_key, seed)
|
||||
else:
|
||||
crypto_sign_keypair(public_key, secret_key)
|
||||
|
||||
return {'public-key': public_key, 'secret-key': secret_key}
|
||||
|
||||
|
||||
def sign():
|
||||
pass
|
||||
|
||||
|
||||
def verify():
|
||||
pass
|
||||
|
||||
|
||||
def data():
|
||||
pass
|
||||
|
||||
|
||||
def leaf():
|
||||
pass
|
||||
|
||||
|
||||
def parent():
|
||||
pass
|
||||
|
||||
|
||||
def tree():
|
||||
pass
|
||||
|
||||
|
||||
def random_bytes():
|
||||
pass
|
||||
|
||||
|
||||
def discovery_key():
|
||||
pass
|
||||
|
||||
|
||||
def encode_unsigned_int64():
|
||||
pass
|
||||
|
||||
|
||||
def blake2b():
|
||||
pass
|
Reference in New Issue
Block a user