tally
shamir's secret sharing over gf(256).
git clone https://owenrusk.dev/tally.git
commit 49397b48b5b9c69fe020cc885882e7dc5c40eb71 parent 8e5f0edddfd1e53101fa9a863a578b373ec4a4b4 author Owen Rusk <owen@papermothgames.com> date 2026-03-11 20:05:33 -0500
tests: one share on its own looks like noise
| tests/test_shamir.py | +10 | -0 |
diff --git a/tests/test_shamir.py b/tests/test_shamir.py index e8cfcec..572c044 100644 --- a/tests/test_shamir.py +++ b/tests/test_shamir.py @@ -2,6 +2,7 @@ import itertools import os import random import unittest +from collections import Counter from tally import shamir @@ -52,6 +53,15 @@ class ShamirTest(unittest.TestCase): with self.subTest(k=k, n=n): self.assertNotEqual(shamir.combine(shares[: k - 1]), secret) + def test_one_share_of_two_looks_like_noise(self) -> None: + # every byte of the secret is 0. a single share should still be all over the place + secret = bytes(6000) + for x, data in shamir.split(secret, 2, 3): + counts = Counter(data) + with self.subTest(x=x): + self.assertEqual(len(counts), 256) + self.assertLess(max(counts.values()), 3 * len(secret) // 256) + def test_bad_k_and_n(self) -> None: for k, n in [(1, 3), (4, 3), (2, 256), (0, 0)]: with self.assertRaises(ValueError):