secret_sharing/lib.rs
1//! Secret-sharing primitives implemented from the papers in
2//! `pubs/` and `bib/references.bib`.
3//!
4//! Schemes from `pubs/`:
5//! - `trivial`: Karnin–Greene–Hellman §I trivial n-of-n additive split
6//! (`v_n = s − Σ v_i mod q`), plus a byte-XOR convenience for `q = 2`.
7//! - `shamir`: Shamir 1979 (k, n) threshold scheme via polynomial
8//! interpolation over GF(p), and the Karnin–Greene–Hellman §IV
9//! multi-secret extension that places ℓ ≤ k secrets in the low-order
10//! coefficients of the same polynomial.
11//! - `bytes`: byte-string Shamir — chunk an arbitrary-length secret
12//! into field-sized blocks and run Shamir per block, with a
13//! self-describing wire format for each share.
14//! - `kgh`: the genuine Karnin–Greene–Hellman §II matrix scheme
15//! (`v_i = u·A_i`) for vector secrets `s ∈ GF(p)^m`, instantiated
16//! with the Vandermonde matrix bank from KGH eq. (16).
17//! - `ramp`: McEliece–Sarwate 1981 ramp / data-compressed Reed–Solomon
18//! variant — the secret occupies k positions of a Reed–Solomon
19//! codeword and only the remaining positions are distributed.
20//! - `decode`: McEliece–Sarwate 1981 errors-and-erasures recovery via
21//! the Berlekamp–Welch algorithm — reconstructs from m shares with
22//! up to t tampered shares whenever `m − 2t ≥ k` in polynomial time.
23//!
24//! Additional schemes from `bib/references.bib`:
25//! - `blakley`: Blakley 1979 geometric (k, n) threshold via random
26//! hyperplanes through a fixed point in GF(p)^k.
27//! - `blakley_meadows`: Blakley–Meadows 1984 (k, L, n) ramp version of
28//! Blakley's hyperplane scheme.
29//! - `mignotte`: Mignotte 1983 CRT scheme — `(m_1, …, m_n)` pairwise
30//! coprime with the secret in the gap `(α, β)` between `k − 1`-largest
31//! and `k`-smallest products. Reconstruction-uniqueness rather than
32//! information-theoretic secrecy.
33//! - `asmuth_bloom`: Asmuth–Bloom 1983 modular CRT scheme — like
34//! Mignotte but with an extra public modulus `m_0` and stricter
35//! parameters that recover information-theoretic secrecy below
36//! threshold.
37//! - `ida`: Rabin 1989 Information Dispersal Algorithm — Reed–Solomon
38//! erasure coding for files; provides `|F|/k`-sized shares with `k`
39//! to reconstruct, but no secrecy.
40//! - `yamamoto`: Yamamoto 1986 (k, L, n) ramp — secret of L elements,
41//! k shares for full recovery, k−L for nothing, intermediate counts
42//! leak proportionally. Generalises both Shamir (L=1) and the McEliece
43//! ramp (L=k).
44//! - `ito`: Ito–Saito–Nishizeki 1989 cumulative-array scheme realising
45//! any monotone access structure described by its maximal forbidden
46//! coalitions.
47//! - `benaloh_leichter`: Benaloh–Leichter 1988 monotone-formula scheme —
48//! recursive AND-additive, OR-replicating distribution along a
49//! formula tree.
50//! - `kothari`: Kothari 1984 generalised linear `(k, n)` threshold over
51//! any user-supplied k×n matrix satisfying the spreading condition.
52//! - `karchmer_wigderson`: Karchmer–Wigderson 1993 monotone span
53//! programs — captures every linear SSS in one matrix-and-labels
54//! form. Subsumes van Dijk 1994's "linear construction" by
55//! equivalent formulation.
56//! - `brickell`: Brickell 1989 ideal vector-space SSS — one vector per
57//! player; specialisation of `karchmer_wigderson`.
58//! - `massey`: Massey 1993 linear-code SSS via minimal codewords — the
59//! secret occupies column 0 of a generator matrix `G`, qualifying
60//! coalitions are those whose columns span column 0.
61//! - `visual`: Naor–Shamir 1994 visual cryptography — `(n, n)` scheme
62//! over black-and-white images with bitwise-OR reconstruction.
63//! - `vss`: Rabin–Ben-Or 1989 information-theoretic verifiable secret
64//! sharing via bivariate polynomials with pairwise cross-checks.
65//! - `cgma_vss`: Chor–Goldwasser–Micali–Awerbuch 1985 computational
66//! VSS instantiated with discrete-log (Feldman) commitments.
67//! - `proactive`: Herzberg, Jarecki, Krawczyk, Yung 1995 proactive
68//! refresh — re-shares an existing share set without changing the
69//! secret.
70//!
71//! All polynomial arithmetic runs over a user-supplied prime field
72//! (`PrimeField`) backed by the local `BigUint` (`crate::bigint`) and
73//! its `MontgomeryCtx` for fast modular exponentiation. Two convenience
74//! moduli are provided: the Mersenne primes `mersenne127` (2^127 − 1)
75//! and `mersenne521` (2^521 − 1).
76//!
77//! The crate is fully self-contained: `Cargo.toml` declares no
78//! dependencies. Big-integer arithmetic, the `Csprng` trait, and a
79//! ChaCha20-based generator (`csprng::ChaCha20Rng`) all live inside
80//! this crate.
81//!
82//! Bibliography entries deliberately not implemented:
83//! - Beimel 2011 *Secret-sharing schemes: A survey* — a survey, no
84//! single scheme to instantiate.
85//! - Franklin–Yung 1992 *Communication complexity of secure
86//! computation* — communication-complexity bounds, not a constructive
87//! scheme.
88//! - Watanabe–Shikata 2014 *Timed-release secret sharing* — requires an
89//! external time-release oracle that has no library-only realisation.
90//! - Zou et al. 2014 *An information theoretic approach to secret
91//! sharing* — capacity-region analysis, not a constructive scheme.
92//!
93//! These have been removed from `bib/references.bib`.
94
95pub mod asmuth_bloom;
96pub mod benaloh_leichter;
97pub mod bigint;
98pub mod blakley;
99pub mod blakley_meadows;
100pub mod brickell;
101pub mod bytes;
102pub mod cgma_vss;
103pub mod csprng;
104pub mod decode;
105pub mod field;
106pub mod ida;
107pub mod ito;
108pub mod karchmer_wigderson;
109pub mod kgh;
110pub mod kothari;
111pub mod massey;
112pub mod mignotte;
113pub mod poly;
114pub mod primes;
115pub mod proactive;
116pub mod ramp;
117pub mod secure;
118pub mod shamir;
119pub mod trivial;
120pub mod visual;
121pub mod vss;
122pub mod yamamoto;
123
124pub use bigint::{BigUint, MontgomeryCtx};
125pub use csprng::{ChaCha20Rng, Csprng};
126
127pub use field::{mersenne127, mersenne521, PrimeField};
128pub use shamir::Share;