sss-rs

Build Status

A purely functional (as in, working) and likely inefficient implementation of a Secret Sharing Scheme in Rust

Not intended to be used in production code.

New Example with the current API

``` let dir = "./"; let stem = "test"; let numshares = 3; let secret: Vec = vec![5, 4, 9, 1, 2, 128, 43]; let sharer = Sharer::builder(secret) .sharesrequired(numshares) .sharestocreate(numshares) .coefficientbits(32) .build() .unwrap(); sharer.sharetofiles(dir, stem).unwrap(); let recon = Sharer::reconstructor(dir, stem, numshares, PrimeLocation::Default).unwrap(); asserteq!(secret, *reconsecret);

```

Old Example (makes use of raw_share functions)

``` let mut rand = SmallRng::seedfromu64(123u64); let secret: u8 = 23; // The secret to be split into shares let sharesrequired = 3; // The number of shares required to reconstruct the secret let sharestocreate = 3; // The number of shares to create, can be greater than the required let bitsizeco: usize = rand.genrange(32, 65); // The number of bits for the generated coefficients let primebits: usize = rand.genrange(bitsizeco + 128, 257); // The number of bits for the prime let mut prime: BigInt = rand.genprime(primebits).into(); // The prime number used for finite field while prime < BigUint::from(secret) { // In case the prime is less than the secret, generate new ones until one is greater prime = rand.genprime(primebits).into(); }

let shares: Vec = createsharesfromsecret( secret, &prime sharesrequired, sharestocreate, bitsizeco).unwrap(); let secretrecon = reconstructsecret(shares, &prime, shares_required).unwrap();

asserteq!(secret, secretrecon); ```

TODO:

- Currently limited to 4GB files, and memory usage issues especially when working with many shares.
    - Break up the reading in from files in chunks of N bytes to avoid high memory usage and overcome
      the file size limitation.
- The shuffle operation was left out of the new API, mainly because it would not function after the 
  above change is implemented. May re-implement a way to shuffle the data in-file. For now this 
  will be benched.