You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
571 B

  1. # shamirsecretsharing-rs
  2. Shamir's Secret Sharing in Rust
  3. ## Usage
  4. ```rust
  5. // create 6 shares from k, given the rand p
  6. // where to recover will be needed 3 shares
  7. let s = create(3, 6, &p, &k);
  8. // now set 3 of the 6 shares, to be used to recover the secret
  9. let mut shares_to_use: Vec<[BigInt;2]> = Vec::new();
  10. shares_to_use.push(s[2].clone());
  11. shares_to_use.push(s[1].clone());
  12. shares_to_use.push(s[0].clone());
  13. // recover the secret using Lagrange Interpolation
  14. let r = lagrange_interpolation(&p, shares_to_use);
  15. assert_eq!(k, r);
  16. // r is the secret recovered (k)
  17. ```