Secret sharing
Split a secret into shares and recover it from a threshold of them.
from oxcrypto.secret_sharing.shamir import SHAMIR
shares = SHAMIR.GF256.split(b"secret", threshold=2, shares=3)
assert SHAMIR.GF256.combine(shares[:2]) == b"secret"split takes the secret positionally and keyword-only threshold (at least
2) and shares (at least threshold). Any threshold distinct shares
recover the secret with combine. Fewer shares recover an unrelated value;
combine cannot detect that. Invalid parameters, duplicate shares and
malformed shares raise ValueError. Shares are random and come from the
operating system's random source through getrandom.
Algorithms
- Shamir Shamir secret sharing of byte strings over GF(256).
- Feldman Feldman verifiable secret sharing of P-256 and secp256k1 scalars.
- Pedersen Pedersen verifiable secret sharing of P-256 and secp256k1 scalars.
All three use vsss-rs 6.0.1 (Apache-2.0 OR MIT, stable). None is
standardized by the IETF or NIST. The vsss-rs README thanks LIT Protocol and
Turnkey for funding audits, but no audit report is published, so treat it as
no published audit.
Zeroization
The functions keep no state: every call returns bytes and drops its Rust
values before returning. Shares and secrets that oxcrypto copies into its own
buffers are zeroized when dropped. Read from the vsss-rs 6.0.1 source
(oxcrypto has not verified it independently), these short-lived copies made
during a call are not wiped:
- the polynomial coefficients, which hold the secret and the random
coefficients (
DefaultShareisCopy, so it has no zeroizing drop); - for Feldman and Pedersen, the share vectors vsss-rs returns before oxcrypto
encodes them:
IdentifierPrimeFielddoes not implementZeroize, so oxcrypto cannot wipe them; - the Pedersen blinder and scalar temporaries in the group arithmetic.
None of these outlive the call. The Shamir byte shares returned by vsss-rs are wiped by oxcrypto after encoding.
Note
Python bytes passed in or returned (secrets and shares) are immutable and
are not wiped, and Python may copy them.