This crate provides bindings to my Shamir secret sharing library.
hazmat module is for experts. The functions in the
hazmat module miss some security
guarantees, so do not use them unless you really know what you are doing.
Encapsulated in the
combine_shares will return an
Option<_> which will be
Some(data) if the data could be restored. If the data could not be restored,
Ok(None). This means that could mean either of:
- More shares were needed to reach the treshold.
- Shares of different sets (corresponding to different secrets) were supplied or some of the shares were tampered with.
use shamirsecretsharing::*; // Create a some shares over the secret data `[42, 42, 42, ...]` let data = vec![42; DATA_SIZE]; let count = 5; let treshold = 4; let mut shares = create_shares(&data, count, treshold).unwrap(); // Lose a share (for demonstrational purposes) shares.remove(3); // We still have 4 shares, so we should still be able to restore the secret let restored = combine_shares(&shares).unwrap(); assert_eq!(restored, Some(data)); // If we lose another share the secret is lost shares.remove(0); let restored2 = combine_shares(&shares).unwrap(); assert_eq!(restored2, None);
This library supports can generate sets with at most
count and a
Hazardous materials (key-sharing)
Custom error types for errors originating from this crate
The size of the input data to
Regular share size from shares produced by
Combine a set of shares and return the original secret
Create a set of shares