pub struct ShamirSS {
pub p: u64,
pub t: usize,
pub n: usize,
}Expand description
Shamir (t, n) secret sharing over a prime field F_p.
§WARNING
Educational implementation. Uses small prime fields, unsuitable for production.
Fields§
§p: u64Field prime p
t: usizeThreshold t: minimum shares needed to reconstruct
n: usizeTotal shares n
Implementations§
Source§impl ShamirSS
impl ShamirSS
Sourcepub fn split(&self, secret: u64, coeffs: &[u64]) -> Vec<(u64, u64)>
pub fn split(&self, secret: u64, coeffs: &[u64]) -> Vec<(u64, u64)>
Split secret s into n shares using a random degree-(t-1) polynomial.
Coefficients a[0]=s, a[1..t] come from coeffs (length t-1).
§WARNING
In production, coefficients must be uniformly random elements of F_p.
Sourcepub fn reconstruct(&self, shares: &[(u64, u64)]) -> u64
pub fn reconstruct(&self, shares: &[(u64, u64)]) -> u64
Reconstruct secret from any t shares using Lagrange interpolation mod p.
shares: slice of (x_i, y_i) pairs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ShamirSS
impl RefUnwindSafe for ShamirSS
impl Send for ShamirSS
impl Sync for ShamirSS
impl Unpin for ShamirSS
impl UnsafeUnpin for ShamirSS
impl UnwindSafe for ShamirSS
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more