pub struct Share<const POLY: u16> {
pub x: GF256<POLY>,
pub y: Vec<GF256<POLY>>,
}Expand description
A share used to reconstruct the secret. Can be serialized to and from a byte array.
Usage example:
use ssskit::{SecretSharing, Share};
use core::convert::TryFrom;
// Transmit the share bytes to a printer
let sss = SecretSharing::<POLY>(3);
let mut rng = rand_chacha::ChaCha8Rng::from_seed([0x90; 32]);
let dealer = sss.dealer_rng::<ChaCha8Rng>(&[1, 2, 3], &mut rng);
// Get 5 shares and print paper keys
for s in dealer.take(5) {
send_to_printer(Vec::from(&s));
};
// Get share bytes from an external source and recover secret
let shares_bytes: Vec<Vec<u8>> = ask_shares();
let shares: Vec<Share<POLY>> = shares_bytes.iter().map(|s| Share::<POLY>::try_from(s.as_slice()).unwrap()).collect();
let secret = sss.recover(&shares).unwrap();Fields§
§x: GF256<POLY>§y: Vec<GF256<POLY>>Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more