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
File details
Details for the file lamport-256-0.1.tar.gz
.
File metadata
- Download URL: lamport-256-0.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb54d356548aac4142bc7cbcd4b9ed58284e59af0cabc9c4df0522736cff9dc5 |
|
MD5 | c518948ffcff16e596b0353b5a877295 |
|
BLAKE2b-256 | 40bc71fce700473f777cb014d66e0755b312af54a90aaa64e7d946683974db86 |
File details
Details for the file lamport_256-0.1-py3-none-any.whl
.
File metadata
- Download URL: lamport_256-0.1-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b481a21a9c4f8d30cc3dca53e992dee4016fffa5d87fd3d8b486eb41723f4807 |
|
MD5 | 15ab731c2647b841e9ce8ffcd64ab15c |
|
BLAKE2b-256 | 578a92129c16ba68c602492aa4970a52fbf24e1164b1692a6df710849aaca5b1 |