Quantum Secret Sharing Lab — Shamir Thresholds, the Qutrit (2,3) Code & the No-Cloning Fence — by Darion Kellar
Educational secret sharing lab in ONE pure-Python file: Shamir's (3, 5) scheme over GF(257) with deterministic labelled coefficients (122, 228) whose five shares — (1, 135), (2, 170), (3, 147), (4, 66), (5, 184) — reconstruct the secret 42 from all 10 three-share subsets by exact Lagrange interpolation, and whose privacy is counted on GF(13): hold one share of a (2, 3) scheme or two of a (3, 5) scheme and every candidate secret has exactly 1 completing polynomial, a flat census tally. The qutrit (2, 3) code encodes α|0⟩ + β|1⟩ + γ|2⟩ as α|000⟩ + β|111⟩ + γ|222⟩ in an explicit 27-dim statevector: every single share's partial trace is diag(|α|², |β|², |γ|²) to 5.551e-17, phase-only-different secrets give identical single shares, and the decoder — a basis permutation of controlled subtractions mod 3, written as an index map — recovers the secret with worst error 0.000e+00 over a four-secret grid. The no-cloning fence computes two candidate (2, 2) encoders: the computational one hides phase (leak 0.000) and leaks amplitude (basis distance 1.000, |0⟩ vs |+⟩ 0.500); the Bell-basis one hides basis secrets (0.000) and leaks phase completely (1.000, cross term exactly X/2). The GHZ bit scheme puts the bit in the X-parity (⟨XXX⟩ = (−1)^b, ⟨XYY⟩ = ⟨YXY⟩ = ⟨YYX⟩ = −1, single-party p(+) = 0.500000) and prices cheater detection exactly: a substituted |+++⟩ passes each Y-audit with probability 1/2, so detection after m audits is 1 − 2^−m (0.999023 at m = 10). A from-scratch distance-weighted kNN access classifier labels situations from the lab's own measured numbers.
Pure Python standard library. Zero dependencies. Zero network. Honest scope: nothing here protects a real secret — the demo coefficients are deterministic on purpose (a real dealer must use true randomness), the qutrit decoder is exhibited on the lab's joint statevector in the teaching form of the scheme, and the no-cloning fence is a computed demonstration on two candidate encoders, not a proof. No key is custodied, no data is secured, no quantum hardware exists here. Every real-secret / custody / QKD-product / deployment / guarantee use is a permanent HOLD gate (14 total).
🧰 Tech Stack Badges & Full Architecture Tech Stack
🐍 Python 3.12, pure standard library (math, cmath, hashlib, json, sys) — zero dependencies, zero network, deterministic (double-run byte-identical)
🔢 Shamir core from scratch: GF(p) polynomial shares, Lagrange interpolation at x = 0 with modular inverses, and a privacy census that enumerates every coefficient tuple over GF(13) and counts completions per candidate secret — perfect privacy is a tally, not a slogan
⚛️ Statevector core from scratch: partial traces by stride index arithmetic on 27-dim (qutrit), 8-dim (GHZ) and 4-dim (qubit) spaces, a decoder written as a pure basis permutation (controlled subtractions mod 3 as index maps), Pauli products by Kronecker multiplication, trace distances in closed form
🚧 No-cloning fence: two candidate linear encoders graded by computed single-share density matrices — cross terms Tr_B |a0⟩⟨a1| evaluated entry by entry, leaks reported as exact trace distances (0.000 / 0.500 / 1.000)
🧠 TinyML kNN access classifier (from scratch, stdlib, distance-weighted): reconstructable / locked-below-threshold / phase-blind-share / cheater-exposed from shares present + threshold + measured phase information + failed checks, labels from the lab's own access policy
🪑 Council seats: Gemini Argon 4 DECIDER (names-only, tighten-only) + Muse advisor (never overrides HOLD) + Google Flow plan-only (rendered = False, live = 0)
🚫 Not applicable — honestly. No blockchain, no Web3, no tokens: the "infrastructure" in this lab is one offline file holding a finite field, a 27-dim statevector, and a parity table. Key custody and wallet schemes are permanent HOLD gates, not features. No fake badges here.
🚫 No low-level code — honestly. No C, no C++, no GPU, no compiled extensions: this is one interpreted Python file on purpose, so every share, density matrix, and parity can be read, checked, and diffed. Performance here means honest algorithms — full enumeration where the field is small enough to count everything (169 coefficient tuples), permutations instead of matrix exponentials — all deterministic and byte-identical between runs.
🚫 None — honestly. No cloud provider is used or needed: the lab runs fully offline on your own machine or in a local Docker container. Docker Hub appears only as the registry the publish workflow pushes the image to.
Shamir, exhaustive — (3, 5) over GF(257), secret 42, coefficients [122, 228] from a labelled hash (printed, reproducible — and labelled as the opposite of what a real dealer must do); all C(5,3) = 10 subsets reconstruct exactly by Lagrange interpolation at x = 0.
The privacy census — full enumeration over GF(13): 1 held share of a (2, 3) scheme → 13 completions, exactly 1 per candidate secret; 2 held shares of a (3, 5) scheme → the same flat tally. Perfect privacy as a count.
Qutrit single shares, traced — partial trace of the 27-dim code state gives diag(|α|², |β|², |γ|²) for every party and every grid secret, max deviation 5.551e-17; populations leak, phases do not.
Phase blindness, stated as a number — phase-only-different secrets produce identical single-share density matrices (max dev 5.551e-17) while their global states differ by more than 0.5 in amplitude: the phase lives only in the whole.
A decoder that cannot drift — controlled subtractions mod 3 as a pure index permutation: worst recovery error 0.000e+00 across the grid and across control shares, other shares left in |0⟩ exactly.
The no-cloning fence — candidate 1 (computational): cross term 0, phase leak 0.000, basis distance 1.000. Candidate 2 (Bell): cross term X/2, basis distance 0.000, phase leak 1.000. Both are perfect isometries; hiding is what fails, in numbers.
GHZ parity bookkeeping — ⟨XXX⟩ = (−1)^b carries the bit; ⟨XYY⟩ = ⟨YXY⟩ = ⟨YYX⟩ = −1 are the audit observables; ⟨ZZZ⟩ = 0; every value computed from the 8-dim statevector, and each audit product verified involutory (O² = I).
Cheater economics — substituted |+++⟩ passes each Y-audit with probability exactly 0.5 (a quadratic form on the statevector, not a sample); detection 1 − 2^−m reaches 0.999023 at m = 10 and 0.999999 at m = 20; the honest state fails with probability 0.
TinyML kNN classifier — reconstructable / locked-below-threshold / phase-blind-share / cheater-exposed from (shares present, threshold met, measured phase information, failed checks); agreement with the lab's access policy asserted on every scenario and all 60 training-grid points.
Advisory seats — Gemini Argon 4 DECIDER (names-only, tighten-only, sha256 trace), Muse advisor (can never override HOLD), Google Flow plan-only (rendered = False, live = 0).