owenrusk.dev

tally

shamir's secret sharing over gf(256).

git clone https://owenrusk.dev/tally.git

commit 5b8432e081a883435eb4029a6b16bb91e6c18c35
parent 2ae1ae698df6da622b1d52bfca60ed531e8a20e2
author Owen Rusk <owen@papermothgames.com>
date   2025-03-24 14:10:27 -0500
readme: a worked example
README.md+16-2
diff --git a/README.md b/README.md
index 1140717..6ec20cc 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ reads the secret from the file, or from stdin if there's no file, and prints n s
     tally join SHARE SHARE SHARE
     tally join < shares.txt
 
-takes the shares as arguments, or one per line on stdin, and prints the secret. it refuses fewer than k, and shares from different splits.
+takes the shares as arguments, or one per line on stdin, and prints the secret. it refuses fewer than k, the same share twice, and shares from different splits. shares past the first k are checked against them.
 
 ## share format
 
@@ -42,5 +42,19 @@ case, spaces and dashes don't matter when reading a share back, and o reads as 0
 
 a share gives away k and the secret's length. nothing else.
 
+`t1` won't change. a different format would get a different number.
 
-`t1` won't change. a different format would get a different number.
\ No newline at end of file
+## example
+
+    $ printf 'hello' | tally split -k 2 -n 3
+    t1-37bm-w6r2-05ak-qdek-eg8b-0mzr
+    t1-37bm-w6r2-089d-kh89-b5n7-gd8c
+    t1-37bm-w6r2-0cqr-e75p-8aw2-f5sb
+
+    $ tally join t1-37bm-w6r2-0cqr-e75p-8aw2-f5sb t1-37bm-w6r2-05ak-qdek-eg8b-0mzr
+    hello
+
+    $ tally join t1-37bm-w6r2-0cqr-e75p-8aw2-f5sb
+    tally: need 2 shares, got 1
+
+shares from one split start the same way: that's the id. the secret comes back byte for byte, so `echo` would have split a trailing newline along with it.