Expand description
Fast, small and secure Shamir’s Secret Sharing library crate
Usage example (std):
use blahaj::{ Sharks, Share };
// Set a minimum threshold of 10 shares
let sharks = Sharks(10);
// Obtain an iterator over the shares for secret [1, 2, 3, 4]
let dealer = sharks.dealer(&[1, 2, 3, 4]);
// Get 10 shares
let shares: Vec<Share> = dealer.take(10).collect();
// Recover the original secret!
let secret = sharks.recover(shares.as_slice()).unwrap();
assert_eq!(secret, vec![1, 2, 3, 4]);
Usage example (no std):
use blahaj::{ Sharks, Share };
use rand_chacha::rand_core::SeedableRng;
// Set a minimum threshold of 10 shares
let sharks = Sharks(10);
// Obtain an iterator over the shares for secret [1, 2, 3, 4]
let mut rng = rand_chacha::ChaCha8Rng::from_seed([0x90; 32]);
let dealer = sharks.dealer_rng(&[1, 2, 3, 4], &mut rng);
// Get 10 shares
let shares: Vec<Share> = dealer.take(10).collect();
// Recover the original secret!
let secret = sharks.recover(shares.as_slice()).unwrap();
assert_eq!(secret, vec![1, 2, 3, 4]);
Structs§
- A share used to reconstruct the secret. Can be serialized to and from a byte array.
- Tuple struct which implements methods to generate shares and recover secrets over a 256 bits Galois Field. Its only parameter is the minimum shares threshold.