Preliminary implementation of deterministic secret sharing

#32
This commit is contained in:
Romain Ruetschi
2018-02-11 22:17:07 +01:00
committed by GitHub
parent d857157efd
commit 40f6190a9b
93 changed files with 6075 additions and 1573 deletions

View File

@ -3,92 +3,87 @@ extern crate rusty_secrets;
use rusty_secrets::sss::recover_secret;
#[test]
#[should_panic(expected = "No shares were provided.")]
#[should_panic(expected = "EmptyShares")]
fn test_recover_no_shares() {
let shares = vec![];
recover_secret(shares, false).unwrap();
for signed in &[true, false] {
let shares = vec![];
recover_secret(&shares, *signed).unwrap();
}
}
#[test]
#[should_panic(expected = "No shares were provided.")]
fn test_recover_no_shares_signed() {
let shares = vec![];
recover_secret(shares, true).unwrap();
}
#[test]
#[should_panic(expected = "This share is incorrectly formatted.")]
#[should_panic(expected = "ShareParsingError")]
fn test_recover_2_parts_share() {
let share1 = "2-1-CgmKQZHMO+5n5pU".to_string();
let share2 = "2-2".to_string();
let shares = vec![share1, share2];
recover_secret(shares, false).unwrap();
recover_secret(&shares, false).unwrap();
}
#[test]
#[should_panic(expected = "Integer parsing error")]
#[should_panic(expected = "IntegerParsingError")]
fn test_recover_incorrect_share_num() {
let share1 = "2-1-CgnlCxRNtnkzENE".to_string();
let share2 = "2-DEFINITLY_NAN-CgkAnUgP3lfwjyM".to_string();
let shares = vec![share1, share2];
recover_secret(shares, false).unwrap();
recover_secret(&shares, false).unwrap();
}
#[test]
#[should_panic(expected = "This share is incorrectly formatted.")]
#[should_panic(expected = "ShareParsingError")]
fn test_recover_0_share_num() {
let share1 = "2-0-1YAYwmOHqZ69jA".to_string();
let share2 = "2-1-YJZQDGm22Y77Gw".to_string();
let shares = vec![share1, share2];
recover_secret(shares, false).unwrap();
recover_secret(&shares, false).unwrap();
}
#[test]
#[should_panic(expected = "This share is incorrectly formatted.")]
#[should_panic(expected = "ShareParsingError")]
fn test_recover_invalid_b64() {
let share1 = "2-1-CgnlCxRNtnkzENE".to_string();
let share2 = "2-1-YJZQDG((((m22Y)))77Gw".to_string();
let share2 = "2-2-YJZQDG((((m22Y)))77Gw".to_string();
let shares = vec![share1, share2];
recover_secret(shares, false).unwrap();
recover_secret(&shares, false).unwrap();
}
#[test]
#[should_panic(expected = "This share number has already been used by a previous share.")]
#[should_panic(expected = "DuplicateShareId")]
fn test_recover_duplicate_shares_number() {
let share1 = "2-1-CgnlCxRNtnkzENE".to_string();
let share2 = "2-1-CgkAnUgP3lfwjyM".to_string();
let shares = vec![share1, share2];
recover_secret(shares, false).unwrap();
recover_secret(&shares, false).unwrap();
}
#[test]
#[should_panic(expected = "The data encoded in this share is the same as the one found in a previous share.")]
#[should_panic(expected = "DuplicateShareData")]
fn test_recover_duplicate_shares_data() {
let share1 = "2-1-CgnlCxRNtnkzENE".to_string();
let share2 = "2-2-CgnlCxRNtnkzENE".to_string();
let shares = vec![share1, share2];
recover_secret(shares, false).unwrap();
recover_secret(&shares, false).unwrap();
}
#[test]
#[should_panic(expected = "The number of shares provided is insufficient to recover the secret.")]
#[should_panic(expected = "MissingShares")]
fn test_recover_too_few_shares() {
let share1 = "3-1-ChbcCdSZOaMn6DM1jFca2P6/0WRlP7AK".to_string();
let share2 = "3-2-ChbG46L1zRszs0PPn63XnnupmZTcgYJ3".to_string();
let shares = vec![share1, share2];
recover_secret(shares, false).unwrap();
recover_secret(&shares, false).unwrap();
}