Expand description
§Introduction
This is a pure-Rust implementation of Shamir’s Secret Sharing (SSS) is a cryptographic technique in which a secret is divided into parts, called shares, in such a way that a threshold of several shares are needed to reconstruct the secret. The shares are distributed in a way that makes it impossible for an attacker to know anything about the secret without having a threshold of shares. If the number of shares is less than the threshold, then no information about the secret is revealed.
§Getting Started
[dependencies]
bc-shamir = "0.3.2"
§Usage
§Splitting a secret
let secret = b"my secret belongs to me.";
let threshold = 2;
let share_count = 3;
let mut random_generator = bc_rand::SecureRandomNumberGenerator;
let shares = split_secret(threshold, share_count, secret, &mut random_generator).unwrap();
assert_eq!(shares.len(), share_count);
§Recovering a secret
let indexes = vec![0, 2];
let shares = vec![
vec![47, 165, 102, 232, 218, 99, 6, 94, 39, 6, 253, 215, 12, 88, 64, 32, 105, 40, 222, 146, 93, 197, 48, 129],
vec![221, 174, 116, 201, 90, 99, 136, 33, 64, 215, 60, 84, 207, 28, 74, 10, 111, 243, 43, 224, 48, 64, 199, 172],
];
let secret = recover_secret(&indexes, &shares).unwrap();
assert_eq!(secret, b"my secret belongs to me.");
Enums§
Constants§
- The maximum length of a secret.
- The maximum number of shares that can be generated from a secret.
- The minimum length of a secret.
Functions§
- Recovers the secret from the given shares using the Shamir secret sharing algorithm.
- Splits a secret into shares using the Shamir secret sharing algorithm.