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.
```
let dir = "./";
let stem = "test";
let numshares = 3;
let secret: Vec
```
``` 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
asserteq!(secret, secretrecon); ```
- 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.