Shamir Secret Sharing is a cryptographic algorithm that allows you to split a secret into multiple parts and distribute them among a group of people. The secret can only be reconstructed when a minimum number of parts are combined together.
Shamir Secret Sharing is a cryptographic algorithm that allows you to split a secret into multiple parts and distribute them among a group of people. The secret can only be reconstructed when a minimum number of parts are combined together.
The algorithm works by generating a polynomial of degree k-1
where k
is the minimum number of parts required to reconstruct the secret. The polynomial is generated in such a way that the constant term is the secret itself. The polynomial is then evaluated at n
different points to generate n
parts. The secret can only be reconstructed when k
parts are combined together.
use shamir::{split, combine};
fn main() {
// Define the secret to be split.
let secret = "Hello, World!";
// Split the secret into 5 shares with a threshold of 3.
let shares = split(secret, 5, 3).unwrap();
// Display the shares.
for (idx, share) in shares.iter().enumerate() {
println!("Share {}: {:?}", idx + 1, share);
}
// Combine the shares to reconstruct the secret.
let reconstructed = combine(&shares[0..3]).unwrap();
println!("Reconstructed: {}", String::from_utf8(reconstructed).unwrap());
}
Contributions, issues and feature requests are welcome. After cloning & setting up project locally, you can just submit a PR to this repo and it will be deployed once it's accepted.
This project is licensed under the MIT License. See the LICENSE file for details.
# Clone this repository
$ git clone
# Go into the repository
$ cd shamir-secret-sharing
# Build the project
$ cargo build