Crates.io | shamir-rs |
lib.rs | shamir-rs |
version | |
source | src |
created_at | 2024-12-12 23:35:55.930515 |
updated_at | 2024-12-12 23:35:55.930515 |
description | a rust implementation of Shamir's Secret Sharing scheme |
homepage | |
repository | https://github.com/g4titanx/sss |
max_upload_size | |
id | 1481737 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This Rust library implements Shamir's Secret Sharing scheme, a cryptographic algorithm that allows you to split a secret into multiple shares, where a specified minimum number of shares are required to reconstruct the original secret.
It is based on the original paper "How to Share a Secret" by Adi Shamir (Communications of the ACM, 1979).
n
shares, where any k
shares are sufficient to reconstruct the secretk-1
compromised shares, as they reveal no information about the secretnum_bigint
crateBlockScheme
for handling secrets larger than the prime modulus by splitting them into smaller blocks.HierarchicalScheme
enables assigning different numbers of shares to participants based on their role or importance.RefreshableScheme
supports generating entirely new sets of shares for the same secret, without having to redistribute the secret itself. This can be useful for regularly updating shares to maintain security.Please see the documentation for more details on using these extensions.
Add this to your Cargo.toml
:
[dependencies]
shamir-rs = "0.1.0"
Then, you can use the library like this:
use num_bigint::BigUint;
use shamir_rs::Scheme;
fn main() {
// Choose a prime larger than the secret and total shares
let prime = BigUint::from(257u32);
// Create a new scheme with a minimum threshold of 3 shares to reconstruct, and 5 shares total
let scheme = Scheme::new(3, 5, prime).unwrap();
// The secret to be shared
let secret = BigUint::from(123u32);
// Split the secret into shares
let shares = scheme.split_secret(&secret);
// Reconstruct the secret from a subset of shares
let reconstructed = scheme.reconstruct_secret(&shares[0..3]).unwrap();
assert_eq!(reconstructed, secret);
}