tally
shamir's secret sharing over gf(256).
git clone https://owenrusk.dev/tally.git
commit b5aff2ecb7500636473960b19110116ad7e0da48 parent 3a7c7f55b7b1f890f198418b9aff14cf03aaa15b author Owen Rusk <owen@papermothgames.com> date 2024-07-17 16:05:51 -0500
join: say so when the same share is given twice it used to fall over with a traceback from combine.
| tally/cli.py | +5 | -0 |
diff --git a/tally/cli.py b/tally/cli.py
index a77bee1..f5a9c37 100644
--- a/tally/cli.py
+++ b/tally/cli.py
@@ -25,6 +25,11 @@ def cmd_join(args: argparse.Namespace) -> int:
if len({s.id for s in shares}) > 1:
raise ShareError("these shares come from different splits")
k = shares[0].k
+ seen: dict[int, int] = {}
+ for i, s in enumerate(shares, 1):
+ if s.x in seen:
+ raise ShareError(f"shares {seen[s.x]} and {i} are both share {s.x} of the split")
+ seen[s.x] = i
if len(shares) < k:
raise ShareError(f"need {k} shares, got {len(shares)}")
secret = shamir.combine([(s.x, s.data) for s in shares[:k]])