mirror of
https://github.com/mii443/RustySecrets.git
synced 2025-08-22 16:25:32 +00:00
Minor improvement to validation
This commit is contained in:
committed by
Romain Ruetschi
parent
3f215cdb39
commit
71064a686e
@ -34,11 +34,9 @@ pub(crate) fn validate_shares<S: IsShare>(shares: &Vec<S>) -> Result<(u8, usize)
|
|||||||
let mut slen = 0;
|
let mut slen = 0;
|
||||||
|
|
||||||
for share in shares {
|
for share in shares {
|
||||||
let (id, threshold_, slen_) = (
|
let id = share.get_id();
|
||||||
share.get_id(),
|
let threshold_ = share.get_threshold();
|
||||||
share.get_threshold(),
|
let slen_ = share.get_data().len();
|
||||||
share.get_data().len(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Public-facing `Share::share_from_string` performs these three tests, but in case another
|
// Public-facing `Share::share_from_string` performs these three tests, but in case another
|
||||||
// type which implements `IsShare` is implemented later that doesn't do that validation,
|
// type which implements `IsShare` is implemented later that doesn't do that validation,
|
||||||
@ -75,6 +73,8 @@ pub(crate) fn validate_shares<S: IsShare>(shares: &Vec<S>) -> Result<(u8, usize)
|
|||||||
ids.push(id);
|
ids.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only once the threshold is confirmed as consistent should we determine if shares are
|
||||||
|
// missing.
|
||||||
if shares_count < threshold as usize {
|
if shares_count < threshold as usize {
|
||||||
bail!(ErrorKind::MissingShares(shares_count, threshold))
|
bail!(ErrorKind::MissingShares(shares_count, threshold))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user