Timelock Encryption
This library enables timelock encryption using the Boneh-Franklin IBE scheme. Specifically, it allows timelock encryption to be instantiated on top of a verifiable randomness beacon, such as the Ideal Network or drand. The library is implemented with arkworks
Currently the scheme supports several flavors of beacons, including the Drand 'quicknet', which uses BLS381 keys, and the Ideal Network beacon, which uses BLS377 keys. Both beacons use a BLS variant with tiny 48 byte signatures and 96 byte public keys, with signatures being elements of $\mathbb{G}_1$ and public keys in $\mathbb{G}_2$.
This flavor of timelock encryption is a hybrid encryption scheme, using AES_GCM to efficiently encrypt and decrypt and size ciphertexts, while secret keys are encrypted for identities of future beacon pulses.
Usage
The library is flexible and can support various flavors of encryption schemes. Officially, only AES_GCM is supported at the moment, but we will support AGE encryption within the library in the near future. You can implement your own by implementing the BlockCipherProvider trait.
Encrypt a Message
This is an example of using the Ideal Network beacon to encrypt message. This same can be accomplished against Drand's quicknet. See the tlock tests here for more examples.
// gather public parameters for the randomenss beacon
let pk = decode.expect;
let p_pub = deserialize_compressed.unwrap;
// construct an identity
// choose a future round number of the randomness beacon
let round_number: u64 = 10;
let identity = new;
// generate an ephemeral secret key 32-byte secret keyff
let esk = ;
// encrypt using the identity
let ct = ::.unwrap;
Decrypt a Message
Early decryption
Message can be encrypted at any time using the ephemeral secret key used to encrypt it, along with the same encryption scheme:
// use the same esk as in `encrypt`
let early_result = decrypt.unwrap;
Timelock Decryption
Messages can also be decrypted with a signature produced by a beacon on top of the 'identity' used to construct it:
// first get a valid siganture from the beacon
let signature = decode.expect;
let result: DecryptionResult = .unwrap;
Build
From the root, run cargo build
Test
Unit tests
From the root, run cargo test
Coverage
We use tarpaulin for test coverage. From the root, run:
cargo tarpaulin --rustflags="-C opt-level=0"
Benchmarks
cargo benchmark
License
Apache-2.0