From df091b07c1bf4faebabf4d65351ddeb7ab287bdb Mon Sep 17 00:00:00 2001 From: Noah Vesely Date: Tue, 27 Mar 2018 14:47:02 -0600 Subject: [PATCH] More specific validation error when share thresholds mismatch --- src/errors.rs | 5 +++++ src/share/validation.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/errors.rs b/src/errors.rs index b5d1bee..9c300ff 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -59,6 +59,11 @@ error_chain! { display("The shares are incompatible with each other.") } + IncompatibleThresholds(sets: Vec>) { + 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) { description("The number of shares provided is insufficient to recover the secret.") display("{} shares are required to recover the secret, found only {}.", required, provided) diff --git a/src/share/validation.rs b/src/share/validation.rs index 143f5dd..a94b4dd 100644 --- a/src/share/validation.rs +++ b/src/share/validation.rs @@ -67,7 +67,7 @@ pub(crate) fn validate_shares(shares: Vec) -> Result<(u8, Vec) 1 => {} // All shares have the same roothash. _ => { bail! { - ErrorKind::IncompatibleSets( + ErrorKind::IncompatibleThresholds( k_compatibility_sets .values() .map(|x| x.to_owned())