sss-rs
contains Rust bindings for my Shamir secret sharing library.
This library allows users to split secret data into a number of different
shares. With the possession of some or all of these shares, the original secret
can be restored.
An example use case is a beer brewery which has a vault which contains their precious super secret recipe. The 5 board members of this brewery do not trust all the others well enough that they won't secretly break into the vault and sell the recipe to a competitor. So they split the code into 5 shares, and allow 4 shares to restore the original code. Now they are sure that the majority of the staff will know when the vault is opened, but they can still open the vault when one of the staff members is abroad or sick at home.
toml
[dependencies]
shamirsecretsharing = { git = "https://github.com/dsprenkels/sss-rs" }
Secrets are always supplied as &[u8]
slices with a length of 64 items. Shares
are generated from a piece of secret data using the sss::create_shares
function and shares can be afterwards be combined using sss::combine_shares
.
Shares are always 113 bytes long. Both sss::create_shares
and
sss::combine_shares
return a Result<_, SSSError>
type. Errors will only
happen when invalid parameters are supplied. When given valid parameters, these
function will always return Ok(_)
. In the case of invalid parameters the
error will be able to tell you what went wrong.
```rust use shamirsecretsharing::*;
// Create a some shares over the secret data [42, 42, 42, ...]
let data = vec![42; DATASIZE];
let count = 5;
let treshold = 4;
let mut shares = createshares(&data, count, treshold).unwrap();
// Lose a share (for demonstrational purposes) shares.remove(3);
// We still have 4 shares, so we should still be able to restore the secret let restored = combineshares(&shares).unwrap(); asserteq!(restored, Some(data));
// If we lose another share the secret is lost shares.remove(0); let restored2 = combineshares(&shares).unwrap(); asserteq!(restored2, None); ```
Feel free to send me an email on my Github associated e-mail address.