Simple single use Lamport signature scheme
Project description
lamport-256
Simple single use Lamport signature scheme in python
Great for building toy blockchains and the like.
DO NOT use in a security conscious production environment!
Usage:
Library
To install run
> pip install lamport-256
Import
import lamport_256
Generate a private/public key pair
key_pair = lamport_256.generate_keys()
private_key = key_pair.priv
public_key = key_pair.pub
from here on out the library functions will appear as if they were imported directly e.g.
from lamport_256 import sign_message
Sign a message
signature = sign_message(private_key, 'Hello, World')
Verify a message
if not verify_signature(public_key, 'Hello, World', signature):
raise Exception('Invalid signature')
Dump keys to files
# together
export_key_pair(key_pair, 'pub.key', 'priv.key') #filenames can be named anything you'd like
# or individually:
export_key(key_pair.priv, 'priv.key')
Read keys from file
# together
key_pair = parse_key_pair('location/of/pub.key', 'location/of/priv.key')
# or individually:
pub = parse_key('pub.key')
CLI
Although you can simply run python location/to/lamport_256.py generate_keys
, it's best to create an alias to run the python script.
# In your .bashrc or equivalent
alias lamp='python location/of/lamport_256.py'
Now you can run the script more concisely
lamp generate_keys
To specify where to save keys use the appropriate options
lamp generate_keys --priv location/to/save/key --pub location/to/save/key
Sign a message
lamp sign --priv location/of/private/key --msg 'Hello, world' > signature.txt
# or pass the message in as a file
lamp sign --priv location/of/private/key --msg location/of/message > signature.txt
Verify a signature
lamp verify --pub location/of/public/key --msg 'message' --sig location/of/signature
# you can pass the message as a file here as well
lamp verify --pub location/of/public/key --msg location/of/message --sig location/of/signature
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for lamport_256-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b481a21a9c4f8d30cc3dca53e992dee4016fffa5d87fd3d8b486eb41723f4807 |
|
MD5 | 15ab731c2647b841e9ce8ffcd64ab15c |
|
BLAKE2b-256 | 578a92129c16ba68c602492aa4970a52fbf24e1164b1692a6df710849aaca5b1 |