//! libss is a Rust libary for secret sharing
//!
//! The shamir module contains an implementation of [Shamir Secret Sharing](https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing) over GF(2**8)
//!
//! gf256 is a module which contains a representation of field elements in GF(2**8).
extern crate quickcheck;
extern crate rand;
extern crate subtle;
use ;
/// gf256 is a module for field elements over the field GF(2**8) with irreducible polynomial x^8+x^4+x^3+x+1
///
/// *WARNING* this library was not audited by an expert in this area and does not guarantee constant-time cryptographic implmentation
/// But, This module uses the Rust crate `subtle` to move towards this goal and one day hopes to acheive these guarantees
///
/// # Examples
///
/// All elements are their own additive inverse
/// GF256::zero() is the additive identity
///
/// ```
/// use libss::gf256::GF256;
/// use libss::Field;
///
/// let x = GF256(80);
/// let x_plus_x = x + x;
///
/// assert_eq!(x_plus_x, GF256::zero());
/// ```
///
/// All elements except zero have inverses
///
/// ```
/// use libss::gf256::GF256;
/// use libss::Field;
///
/// let x = GF256(80);
/// let x_mul_x = x.inverse().unwrap() * x;
///
/// assert_eq!(x_mul_x, GF256::one());
/// ```
/// 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);
/// ```
///
/// The Field trait is taken from [zkcrypto/ff](https://github.com/zkcrypto/ff/blob/master/src/lib.rs)
/// This trait represents an element of a field.