feat: add sharmir demo

This commit is contained in:
2023-01-01 20:54:02 +08:00
parent 93a8832b36
commit c8837b21f6
4 changed files with 122 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
use shamir::SecretData;
fn main() {
let secret_data = SecretData::with_secret("Hello World!", 3);
let share1 = secret_data.get_share(1).unwrap();
let share2 = secret_data.get_share(2).unwrap();
let share3 = secret_data.get_share(3).unwrap();
let share4 = secret_data.get_share(4).unwrap();
println!("{:?}\n{:?}\n{:?}\n{:?}", share1, share2, share3, share4);
let recovered = SecretData::recover_secret(3, vec![share1, share2, share3]).unwrap();
println!("Recovered: {}", recovered);
}