Function shamirsecretsharing::create_shares
[−]
[src]
pub fn create_shares(
data: &[u8],
n: u8,
k: u8
) -> Result<Vec<Vec<u8>>, SSSError>
Create a set of shares
data
must be a&[u8]
slice of lengthDATA_SIZE
(64)n
is the number of shares that is to be generatedk
is the treshold value of how many shares are needed to restore the secret
The value that is returned is a newly allocated vector of vectors. Each of these vectors will
contain SHARE_SIZE
u8
items.
Example
use shamirsecretsharing::*; // Create a some shares over the secret data `[42, 42, 42, ...]` let data = vec![42; DATA_SIZE]; let count = 5; let treshold = 4; let shares = create_shares(&data, count, treshold); match shares { Ok(shares) => println!("Created some shares: {:?}", shares), Err(err) => panic!("Oops! Something went wrong: {}", err), }