Correct 2/3rds definitions throughout the codebase

The prior formula failed for some values, such as 20.
20 / 3 = 6, * 2 = 12, + 1 = 13. 13 is 65%, not >= 67.
This commit is contained in:
Luke Parker 2023-05-10 06:29:19 -04:00
parent ffea02dfbf
commit 89974c529a
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View file

@ -88,7 +88,7 @@ impl TributarySpec {
} }
pub fn t(&self) -> u16 { pub fn t(&self) -> u16 {
(2 * (self.n() / 3)) + 1 ((2 * self.n()) / 3) + 1
} }
pub fn i(&self, key: <Ristretto as Ciphersuite>::G) -> Option<Participant> { pub fn i(&self, key: <Ristretto as Ciphersuite>::G) -> Option<Participant> {

View file

@ -22,7 +22,7 @@ use promote::test_generator_promotion;
/// Constant amount of participants to use when testing. /// Constant amount of participants to use when testing.
pub const PARTICIPANTS: u16 = 5; pub const PARTICIPANTS: u16 = 5;
/// Constant threshold of participants to use when testing. /// Constant threshold of participants to use when testing.
pub const THRESHOLD: u16 = ((PARTICIPANTS / 3) * 2) + 1; pub const THRESHOLD: u16 = ((PARTICIPANTS * 2) / 3) + 1;
/// Clone a map without a specific value. /// Clone a map without a specific value.
pub fn clone_without<K: Clone + std::cmp::Eq + std::hash::Hash, V: Clone>( pub fn clone_without<K: Clone + std::cmp::Eq + std::hash::Hash, V: Clone>(