bzte

Crates.iobzte
lib.rsbzte
version0.1.1
sourcesrc
created_at2022-02-02 00:52:25.337012
updated_at2023-02-05 19:39:15.042877
descriptionBaek-Zheng threshold cryptosystem on top of BLS12-381
homepagehttps://github.com/Silur/bzte
repositoryhttps://github.com/Silur/bzte
max_upload_size
id525491
size18,292
(Silur)

documentation

https://docs.rs/bzte

README

bzte

A rust implementation of the Baek-Zhang threshold cryptosystem on top of BLS12-381 using arkworks

Why threshold encrypt?

The advantage of threshold encryption over splitting a single symmetric encryption key using SSS is that at the end of SSS, a single vulnerable secret key emerges that all parties could observe at the end of the proto col. However with a TPKE scheme, combining the shares do not result in any sensitive information besides the dec rypted plaintext at the end. This makes reusing the same key shares for multiple messages safely, using only one trusted setup (or a trustless DKG).

Usage

use bzte::{keygen};

let (pk, sks) = keygen(10, 5);
let m = sha256(b"thats my kung fu"); // only supports messages up to 256 bits!
let c = pk.encrypt(&m).unwrap();
assert!(pk.verify_ciphertext(&c));
let shares: Vec<G1> = sks.iter().map(|sk| sk.decrypt_share(&c).unwrap()).collect();
for (i, share) in shares.iter().enumerate() {
  assert!(pk.verify_share(i, *share, &c));
}

let mut partial_shares: HashMap<usize, G1> = HashMap::new();
for i in 0..5 {
  partial_shares.insert(i, shares[i]);
}
let check = pk.combine_shares(&c, &partial_shares).unwrap();
assert_eq!(check, m);

To serialiaize/deserialize keys or the ciphertext, use the provided .to_bytes()/.from_bytes() methods respec tively.

Disclaimer

This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See http://www.wassenaar.org/ for more information.

Commit count: 16

cargo fmt