Struct threshold_secret_sharing::shamir::ShamirSecretSharing [] [src]

pub struct ShamirSecretSharing {
    pub threshold: usize,
    pub share_count: usize,
    pub prime: i64,
}

Parameters for the Shamir scheme, specifying privacy threshold and total number of shares.

There are very few constraints except for the obvious ones:

  • prime must be a prime large enough to hold the secrets we plan to share
  • share_count must be at least threshold + 1 (the reconstruction limit)

Example:

use threshold_secret_sharing::shamir;
   let tss = shamir::ShamirSecretSharing {
       threshold: 9,
       share_count: 20,
       prime: 41
   };

   let secret = 5;
   let all_shares = tss.share(secret);

   let reconstruct_share_count = tss.reconstruct_limit();

   let indices: Vec<usize> = (0..reconstruct_share_count).collect();
   let shares: &[i64] = &all_shares[0..reconstruct_share_count];
   let recovered_secret = tss.reconstruct(&indices, shares);

   println!("The recovered secret is {}", recovered_secret);
   assert_eq!(recovered_secret, secret);

Fields

Maximum number of shares that can be known without exposing the secret.

Number of shares to split the secret into.

Prime defining the Zp field in which computation is taking place.

Methods

impl ShamirSecretSharing
[src]

Minimum number of shares required to reconstruct secret.

For this scheme this is always threshold + 1.

Generate share_count shares from secret.

Reconstruct secret from a large enough subset of the shares.

indices are the ranks of the known shares as output by the share method, while values are the actual values of these shares. Both must have the same number of elements, and at least reconstruct_limit.

Trait Implementations

impl Debug for ShamirSecretSharing
[src]

Formats the value using the given formatter.