This provides python bindings for usage of timelock encryption
Project description
Python Bindings for the Timelock Library
Python bindings for the Timelock library. It enables timelock encryption and decryption with support for Drand's quicknet. In the futurue we will expand the supported networks to include the IDN beacon.
Build
Build with:
pip install --upgrade build
python -m build
Publish
Note that this requires the timelock-wasm-wrapper python package be published as well.
pip install --upgrade twine
twine upload --repository testpypi dist/*
Usage
See the example for an e2e demo.
Encrypt a message
from timelock import Timelock
# Setup encryption input
# The drand quicknet public key
pk_hex = "83cf0f2896adee7eb8b5f01fcad3912212c437e0073e911fb90022d3e760183c8c4b450b6a0a6c3ac6a5776a2d1064510d1fec758c921cc22b0e17e63aaf4bcb5ed66304de9cf809bd274ca73bab4af5a6e9c76a4bc09e76eae8991ef5ece45a"
timelock = Timelock(pk_hex)
# An ephemeral secret key
sk = bytearray([0x01, 0x02, 0x03, 0x04] * 8)
# A "future" round number
round_number = 1000
# The message to encrypt
plaintext = "Hello, Timelock!"
# timelock encrypt
ct = timelock.tle(round_number, plaintext, sk)
Decrypt a Message
# get a signature at some point in the future
signature_hex = "b44679b9a59af2ec876b1a6b1ad52ea9b1615fc3982b19576350f93447cb1125e342b73a8dd2bacbe47e4b6b63ed5e39"
sig = bytearray.fromhex(signature_hex)
# and finally decrypt the message
maybe_plaintext = timelock.tld(ct, sig)
maybe_plaintext = maybe_plaintext.decode("utf-8")
assert plaintext == maybe_plaintext
License
Apahce-2.0
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file timelock-0.0.1.dev0.tar.gz.
File metadata
- Download URL: timelock-0.0.1.dev0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47d23f55e9007f07ced0d6e76751ee8870151ae5ef3765e4af566313dcd28e47
|
|
| MD5 |
a8fb4daad2811471b52a59b3f18faf6b
|
|
| BLAKE2b-256 |
8afd50b2708bacfa0d397228205c493b30d4916b3c4f0ac5ca363ceb6278bb9f
|
File details
Details for the file timelock-0.0.1.dev0-py3-none-any.whl.
File metadata
- Download URL: timelock-0.0.1.dev0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6e9249a2ee06548983af8de887c7aa63fdbaedffae474a493307390f74f72ee
|
|
| MD5 |
2c861bc1ffeab8b89ecffedaa9ce15db
|
|
| BLAKE2b-256 |
2c17670d49f7bacff2c1617bbc93b99b16c87da0bc9b6fe962d349f4de0c9c60
|