[][src]Module libss::shamir

Shamir is a module for shamir secret sharing.

Example

The following code splits a secret (a slice of bytes) into n shares of which k are required to recover the secret.

extern crate rand;

use rand::{thread_rng,Rng};
use libss::shamir::Shamir;

let k = 3;
let n = 5;
let size = 32;

// Generate a random secret
let mut random_secret = Vec::with_capacity(size);
(0..size).for_each(|_| random_secret.push(thread_rng().gen::<u8>()));

// Split this random secret into n shares, of which k are needed to recover the secret
let shares = Shamir::split(&random_secret, k, n).unwrap();

// Combine the shares to recover the secret
let combined = Shamir::combine(&shares);
assert_eq!(combined, random_secret);

Structs

Shamir

A set of functions for Shamir Secret Sharing

Share

Represents a set of points which make up a share of a secret