Skip to content

Commit

Permalink
Add a test for issue #43.
Browse files Browse the repository at this point in the history
Regardless of threshold, all polynomials are lines due to small syntactic error
  • Loading branch information
romac committed Mar 3, 2018
1 parent 7f9289e commit 1ad79dc
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/recovery_errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate rusty_secrets;

use rusty_secrets::sss::recover_secret;
use rusty_secrets::sss::{recover_secret, split_secret};

#[test]
#[should_panic(expected = "EmptyShares")]
Expand Down Expand Up @@ -87,3 +87,25 @@ fn test_recover_too_few_shares() {

recover_secret(&shares, false).unwrap();
}

// See https://github.com/SpinResearch/RustySecrets/issues/43
#[test]
fn test_recover_too_few_shares_bug() {
let original = b"Test for issue #43".to_vec();
let shares = split_secret(4, 5, &original, false).unwrap();
let mut share_1 = shares[0].clone().into_bytes();
let mut share_2 = shares[3].clone().into_bytes();

share_1[0] = '2' as u8;
share_2[0] = '2' as u8;

let sub_shares = vec![
String::from_utf8_lossy(&share_1).into_owned(),
String::from_utf8_lossy(&share_2).into_owned(),
];

match recover_secret(&sub_shares, false) {
Err(_) => assert!(true),
Ok(recovered) => assert_ne!(original, recovered),
}
}

0 comments on commit 1ad79dc

Please # to comment.