More specific validation error when share thresholds mismatch

This commit is contained in:
Noah Vesely
2018-03-27 14:47:02 -06:00
committed by Romain Ruetschi
parent cb13a9b5db
commit df091b07c1
2 changed files with 6 additions and 1 deletions

View File

@ -59,6 +59,11 @@ error_chain! {
display("The shares are incompatible with each other.") display("The shares are incompatible with each other.")
} }
IncompatibleThresholds(sets: Vec<HashSet<u8>>) {
description("The shares are incompatible with each other because they do not all have the same threshold.")
display("The shares are incompatible with each other because they do not all have the same threshold.")
}
MissingShares(provided: usize, required: u8) { MissingShares(provided: usize, required: u8) {
description("The number of shares provided is insufficient to recover the secret.") description("The number of shares provided is insufficient to recover the secret.")
display("{} shares are required to recover the secret, found only {}.", required, provided) display("{} shares are required to recover the secret, found only {}.", required, provided)

View File

@ -67,7 +67,7 @@ pub(crate) fn validate_shares<S: IsShare>(shares: Vec<S>) -> Result<(u8, Vec<S>)
1 => {} // All shares have the same roothash. 1 => {} // All shares have the same roothash.
_ => { _ => {
bail! { bail! {
ErrorKind::IncompatibleSets( ErrorKind::IncompatibleThresholds(
k_compatibility_sets k_compatibility_sets
.values() .values()
.map(|x| x.to_owned()) .map(|x| x.to_owned())