Function shamirsecretsharing::hazmat::create_keyshares[][src]

pub fn create_keyshares(
    key: &[u8],
    n: u8,
    k: u8
) -> Result<Vec<Vec<u8>>, SSSError>

Create a set of key shares

  • key must be a &[u8] slice of length DATA_SIZE (32)
  • n is the number of shares that is to be generated
  • k 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 KEYSHARE_SIZE u8 items.

Example

use shamirsecretsharing::hazmat::*;

// With a `key` vector containing a uniform key

// Create a some key shares of the secret key
let count = 5;
let treshold = 4;
let keyshares = create_keyshares(&key, count, treshold);
match keyshares {
    Ok(keyshares) => println!("Created some keyshares: {:?}", keyshares),
    Err(err) => panic!("Oops! Something went wrong: {}", err),
}