From 89974c529a8c50f83dc0413128e66655cd020fde Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Wed, 10 May 2023 06:29:19 -0400 Subject: [PATCH] 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. --- coordinator/src/tributary/mod.rs | 2 +- crypto/dkg/src/tests/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coordinator/src/tributary/mod.rs b/coordinator/src/tributary/mod.rs index 433ed4be..12da3220 100644 --- a/coordinator/src/tributary/mod.rs +++ b/coordinator/src/tributary/mod.rs @@ -88,7 +88,7 @@ impl TributarySpec { } pub fn t(&self) -> u16 { - (2 * (self.n() / 3)) + 1 + ((2 * self.n()) / 3) + 1 } pub fn i(&self, key: ::G) -> Option { diff --git a/crypto/dkg/src/tests/mod.rs b/crypto/dkg/src/tests/mod.rs index 99386315..8de9a683 100644 --- a/crypto/dkg/src/tests/mod.rs +++ b/crypto/dkg/src/tests/mod.rs @@ -22,7 +22,7 @@ use promote::test_generator_promotion; /// Constant amount of participants to use when testing. pub const PARTICIPANTS: u16 = 5; /// 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. pub fn clone_without(