Skip to content
mikelodder7Public

About

Verifiable Secret Sharing Schemes

Resources

Security policy

Stars

94 stars

Watchers

4 watching

Forks

Repository files navigation

Verifiable Secret Sharing Schemes

Crate Docs Coverage Apache 2.0

vsss-rs implements Shamir secret sharing and the Feldman and Pedersen verifiable secret sharing schemes. It supports no_std, fixed-size storage, allocator-backed storage, prime fields, groups, and byte-oriented GF(16) and GF(256) sharing.

It also provides post-quantum options: Π_LA hash-based verifiable secret sharing and a public hash commitment, both over any digest::Digest, and an experimental lattice-based publicly verifiable scheme.

The library is production-ready and in production use. Thank you to LIT Protocol and Turnkey for funding security audits of this library. The audits predate the hash-commitment, pi-la, and lattice-pvss features, which have not been audited.

Schemes

Scheme Verification Split result
Shamir None Secret shares
Feldman Public commitments Secret shares and Feldman verifiers
Pedersen Hiding commitments Secret shares, blinder shares, blinder, and verifier sets
Π_LA (pi-la) Hash commitments, post-quantum Secret shares and a PiLaProof
Lattice PVSS (lattice-pvss, experimental) Public, post-quantum, ~110-bit Encrypted shares and a PvssProof

Combining shares is identical across Shamir, Feldman, Pedersen, and Π_LA and is provided by ReadableShareSet::combine.

Quick start

Add the crate and an RNG:

[dependencies]
rand = "0.10"
vsss-rs = "7"

Split and combine a byte string with GF(256):

use rand::{SeedableRng, rngs::StdRng};
use vsss_rs::Gf256;

fn main() -> Result<(), vsss_rs::Error> {
    let mut rng = StdRng::from_seed([7u8; 32]);
    let shares = Gf256::split_bytes(2, 3, b"secret", &mut rng)?;
    let recovered = Gf256::combine_bytes(&shares[..2])?;

    assert_eq!(recovered, b"secret");
    Ok(())
}

Split and combine a prime-field element with Shamir:

use elliptic_curve::{Generate, ff::PrimeField};
use p256::{NonZeroScalar, Scalar, SecretKey};
use rand::{SeedableRng, rngs::StdRng};
use vsss_rs::{IdentifierPrimeField, PrimeFieldShare, ReadableShareSet, shamir};

fn main() -> Result<(), vsss_rs::Error> {
    let mut rng = StdRng::from_seed([1u8; 32]);
    let key = SecretKey::generate_from_rng(&mut rng);
    let secret = IdentifierPrimeField(*key.to_nonzero_scalar().as_ref());
    let shares =
        shamir::split_secret::<PrimeFieldShare<Scalar>>(2, 3, &secret, &mut rng)?;
    let recovered = shares.combine()?;
    let recovered = NonZeroScalar::from_repr(recovered.0.to_repr()).unwrap();

    assert_eq!(SecretKey::from(recovered).to_bytes(), key.to_bytes());
    Ok(())
}

The curve example additionally needs:

[dependencies]
elliptic-curve = "0.14"
p256 = { version = "0.14", features = ["arithmetic"] }

See the crate documentation for Feldman, Pedersen, K256, BLS12-381, Curve25519, Ed25519, Ed448, and X25519 examples.

Post-quantum sharing

Feldman and Pedersen commitments rely on discrete logarithms, which a quantum computer can break. Π_LA verifies shares with hash commitments instead, so it needs only a hash. Any digest::Digest works: SHA-2, SHA-3, BLAKE2, or BLAKE3 (with its traits-preview feature). Use a digest of at least 256 bits.

use k256::Scalar;
use rand::{SeedableRng, rngs::StdRng};
use sha2::Sha256;
use vsss_rs::{IdentifierPrimeField, PrimeFieldShare, ReadableShareSet, pi_la};

fn main() -> Result<(), vsss_rs::Error> {
    let mut rng = StdRng::from_seed([3u8; 32]);
    let secret = IdentifierPrimeField(Scalar::from(42u64));
    let dealt = pi_la::split_secret::<Sha256, PrimeFieldShare<Scalar>, _>(
        2, 3, &secret, &mut rng,
    )?;

    // Each participant checks its own share against the public proof.
    for share in &dealt.shares {
        dealt.proof.verify_share::<Sha256, _>(2, share)?;
    }
    assert_eq!((&dealt.shares[..2]).combine()?, secret);
    Ok(())
}

The hash commitment is also usable on its own:

use rand::{SeedableRng, rngs::StdRng};
use sha2::Sha256;
use vsss_rs::HashCommitment;

fn main() -> Result<(), vsss_rs::Error> {
    let mut rng = StdRng::from_seed([4u8; 32]);
    let (commitment, opening) =
        HashCommitment::commit::<Sha256>(b"my-app", b"message", &mut rng);
    commitment.verify::<Sha256>(b"my-app", b"message", &opening)?;
    Ok(())
}

Both examples need:

[dependencies]
k256 = { version = "0.14", features = ["arithmetic"] }
sha2 = "0.11"
vsss-rs = { version = "7", features = ["pi-la"] }

The lattice-pvss feature adds a publicly verifiable scheme where shares are encrypted to each receiver under an NTRU-lattice identity-based encryption. It is experimental and unaudited, is not constant-time, and has about 110-bit classical security (below 128). See the lattice module documentation before using it.

Shares and identifiers

The Share trait separates a share into an identifier and a value. The crate provides:

  • (Identifier, Value) for tuple-based shares.
  • DefaultShare<Identifier, Value> for shares with named fields.
  • PrimeFieldShare<F> for field-valued shares.
  • GroupShare<G> for group-valued shares.
  • Gf16::split_bytes and Gf256::split_bytes for byte strings.

Identifiers implement ShareIdentifier; values implement ShareElement. Custom field or group representations can be integrated by implementing these traits.

Participant identifiers default to sequential nonzero values beginning at one. ParticipantIdGenerator supports:

  • Sequential { start, increment, count }
  • List { list }
  • Random { seed, count } with the random-participant-ids feature

Use split_secret_with_participant_generators for generators, split_secret_with_participant_ids_iter for an iterator of identifiers, or split_secret_with_participant_ids_stream for an asynchronous stream.

Combining shares

Collections implementing ReadableShareSet provide combine and combine_in_place. Allocator-backed callers can also use:

  • combine_iter
  • combine_iter_in_place
  • combine_stream
  • combine_stream_in_place

Stream combination consumes exactly the requested number of shares and returns Error::NotEnoughShares if the stream ends early. The selected shares are retained until interpolation completes because every Lagrange coefficient depends on the complete identifier set.

GF(16) and GF(256) provide equivalent combine_bytes_iter and combine_bytes_stream methods.

no_std and storage

The crate is #![no_std]. Without an allocator, fixed arrays, generic_array::GenericArray, and hybrid_array::Array can hold polynomials, shares, and verifier sets. The vsss_fixed_array_impl! macro can define a complete fixed-size Shamir/Feldman/Pedersen implementation.

Enable alloc for Vec-backed APIs in a no_std environment. The std feature implies alloc.

For a minimal GF(16)/GF(256 build:

[dependencies]
vsss-rs = { version = "7", default-features = false, features = ["alloc"] }

Features

Feature Default Adds
alloc Through std Vec/Box APIs for allocator-enabled environments
std Yes Standard-library support in dependencies
bigint Yes crypto-bigint, num-bigint, and bigint share elements
primitive Yes Primitive integer share elements
curve Through curve-serde Prime-field and group-backed share elements
curve-serde Yes curve, Serde, and curve serialization helpers
random-participant-ids Yes SHAKE-based random participant identifiers
serde Through curve-serde Serialization for supported types
hash-commitment No Post-quantum hiding and binding hash commitments (HashCommitment, HashOpening) over any digest::Digest; implies alloc
pi-la No Π_LA hash-based, post-quantum verifiable secret sharing over any digest::Digest; implies alloc, curve, and hash-commitment
lattice-pvss No Experimental and unaudited. Post-quantum publicly verifiable secret sharing (Kate et al., ePrint 2026/813, Sec. 5) over an NTRU lattice IBE with ~110-bit classical security (below 128); not constant-time; implies std, bigint, and pi-la
stream No Async identifier splitting and exact-count share combination; implies alloc
zeroize Yes Zeroization for supported share elements
legacy-curve-tests No Compatibility-only tests for older curve combinations

Big integer share elements

With bigint, the crate supports:

  • IdentifierUint<LIMBS> and ValueUint<LIMBS>
  • IdentifierBoxedUint<BITS> and ValueBoxedUint<BITS> with alloc
  • IdentifierResidue<MOD, LIMBS> and ValueResidue<MOD, LIMBS>
  • IdentifierConstMontyResidue<MOD, LIMBS> and ValueConstMontyResidue<MOD, LIMBS>
  • Runtime-modulus IdentifierMontyResidue<LIMBS> and ValueMontyResidue<LIMBS> helpers

Runtime-modulus Montgomery values do not implement ShareElement, because their zero and one values require runtime parameters.

Security

Share counts and identifiers are public inputs. Field and group operations used for secret material are designed to avoid secret-dependent control flow and table lookups. Applications remain responsible for authenticating transported shares and, when using Feldman, Pedersen, or Π_LA, verifying shares before combining them.

Feldman and Pedersen are not post-quantum. Π_LA and HashCommitment rely only on the hash, so their security follows the digest you choose. For the whole flow to be post-quantum, shares must also travel over post-quantum channels. The lattice-pvss feature is experimental, unaudited, not constant-time, and at about 110-bit classical security below the rest of the crate.

Please follow the private reporting process in SECURITY.md rather than opening a public issue.

License

Licensed under either of the following, at your option:

Unless explicitly stated otherwise, contributions intentionally submitted for inclusion are licensed under the same terms without additional conditions.

References

  1. How to Share a Secret — Adi Shamir, 1979
  2. A Practical Scheme for Non-interactive Verifiable Secret Sharing — Paul Feldman, 1987
  3. Non-Interactive and Information-Theoretic Secure Verifiable Secret Sharing — Torben Pedersen, 1991
  4. Π: A Unified Framework for Computational Verifiable Secret Sharing — Karim Baghery, PKC 2025
  5. Practical Post-Quantum Secure Publicly Verifiable Secret Sharing and Applications — Kate, Mukherjee, Saleem, Sarkar, and Sinha, 2026

About

Verifiable Secret Sharing Schemes

Resources

Security policy

Stars

94 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages