An implementation of a secret sharing scheme in Rust. This is not meant to be a serious/optimized implementation, it's more of a fun project to further my Rust knowledge.
```
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.
- Add optional verification that allows for checking if a secret has been properly reconstructed.
- One way to do this would be to take the hash of the first N bytes of the secret and place it at the end of the secret. The chances of incorrect reconstruction leading to the first N bytes
hashing to the incorrectly reconstructed hash placed at the end would be astronomically low.
- While working with individual bytes makes things much easier, it would be far more efficient to
work with larger chunks of data.