MPVSS - A Simple Publicly Verifiable Secret Sharing Library
The library implements a simple PVSS scheme in Rust with support for multiple cryptographic groups through a generic trait abstraction.
What is PVSS?
Secret sharing means a dealer can break a secret into secret shares among a group of participants which can reconstruct the secret only by collaboratively joining their parts of the secret. The library also implements threshold cryptography so that the dealer can decide whether all of the receiving participants need to collaborate or if a smaller subgroup of participants is sufficient to reconstruct the secret.
In addition to the plain secret sharing scheme PVSS adds verifiability in the following way: All the parts the secret is split into are encrypted with the receivers' public keys respectively. The dealer publishes all the encrypted shares along with a non-interactive zero-knowledge proof that allows everbody (not only the receiving participants) to verify that the decrypted shares indeed can be used to reconstruct the secret. The participants then decrypt all their shares and exchange them along with another non-interactive zero-knowledge proof that allows the receiving participant to verify that the share is actually the result of the decryption.
Thus PVSS can be used to share a secret among a group of participants so that either the secret can be reconstructed by the participants who all play fair or a participant that received a faked share can identify the malicious party.
Build
# Build all features
Test
# Run all tests
Examples
# MODP group examples (default)
# secp256k1 elliptic curve examples
Usage
Initialization
First, create a cryptographic group instance (e.g., ModpGroup) and initialize participants with key pairs.
use ModpGroup;
use Participant;
let secret_message = Stringfrom;
// Create the group (returns Arc<ModpGroup>)
let group = new;
// Create dealer and participants with the group
let mut dealer = with_arc;
dealer.initialize;
let mut p1 = with_arc;
let mut p2 = with_arc;
let mut p3 = with_arc;
p1.initialize;
p2.initialize;
p3.initialize;
Distribution & Verification
The dealer splits the secret into shares, encrypts them and creates a proof so that everybody can verify that the shares (once decrypted) can be used to reconstruct the secret. The threshold determines how many shares are necessary for the reconstruction. The encrypted shares and the proof are then bundled together.
// Dealer that shares the secret among p1, p2 and p3.
let distribute_shares_box = dealer.distribute_secret;
// p1 verifies distribution shares box containing encryted shares and proof of zero-knowlege. [p2 and p3 do this as well.]
assert_eq!;
assert_eq!;
assert_eq!;
Exchange & Verification
The participants extract their shares from the distribution shares box and decrypt them. They bundle them together with a proof that allows the receiver to verify that the share is indeed the result of the decryption.
// Generate random witness for share extraction
use RandBigInt;
let mut rng = thread_rng;
let w: BigInt = rng
.gen_biguint_below
.to_bigint
.unwrap;
// p1 extracts the share. [p2 and p3 do this as well.]
let s1 = p1
.extract_secret_share
.unwrap;
// p1, p2 and p3 exchange their descrypted shares.
// ...
let s2 = p2
.extract_secret_share
.unwrap;
let s3 = p3
.extract_secret_share
.unwrap;
// p1 verifies the share received from p2. [Actually everybody verifies every received share.]
assert_eq!;
assert_eq!;
assert_eq!;
Reconstruction
Once a participant collected at least threshold shares the secret can be reconstructed.
let share_boxs = ;
let r1 = p1.reconstruct.unwrap;
let r2 = p2.reconstruct.unwrap;
let r3 = p3.reconstruct.unwrap;
let r1_str = string_from_secret;
assert_eq!;
let r2_str = string_from_secret;
assert_eq!;
let r3_str = string_from_secret;
assert_eq!;
Generic Group Support
The library supports multiple cryptographic groups through a generic Group trait:
ModpGroup: 2048-bit MODP group (RFC 3526) - Default implementationSecp256k1Group: secp256k1 elliptic curve (Bitcoin's curve) - Always available
The Participant<G> struct is generic over the group type, allowing the same PVSS operations to work with different cryptographic backends. The Rust compiler automatically selects the correct implementation based on the group type, so you use the same method names for all groups.
secp256k1 Usage
To use secp256k1 elliptic curve cryptography:
use Secp256k1Group;
use Participant;
use Group; // Import Group trait for method access
let secret_message = Stringfrom;
// Create the group (returns Arc<Secp256k1Group>)
let group = new;
// Create dealer and participants with the group
let mut dealer = with_arc;
dealer.initialize;
let mut p1 = with_arc;
let mut p2 = with_arc;
let mut p3 = with_arc;
p1.initialize;
p2.initialize;
p3.initialize;
// Distribution - same method names as MODP
let distribute_shares_box = dealer.distribute_secret;
// Verification - same method names
assert_eq!;
// Share extraction
let w = group.generate_private_key; // No need for BigInt RNG with secp256k1
let s1 = p1.extract_secret_share.unwrap;
// Reconstruction - same method names
let share_boxs = ;
let r1 = p1.reconstruct.unwrap;
Key Differences for secp256k1:
- Elements are EC points (
k256::AffinePoint) instead ofBigInt - Scalars are
k256::Scalar(32 bytes) instead ofBigInt - Method names are the same as MODP (no suffix needed)
- Private keys are generated via
group.generate_private_key()instead of manual BigInt RNG Scalar::from_reprexpects big-endian byte representation
Related References:
-
Berry Schoenmakers. A Simple Publicly Verifiable Secret Sharing Scheme and its Application to Electronic Voting
-
Adi Shamir. How to share a secret
-
Tal Rabin. Verifiable Secret Sharing and Multiparty Protocols with Honest Majority
-
Markus Stadler. Publicly Verifiable Secret Sharing
-
bitcoinwiki-org. Publicly Verifiable Secret Sharing
Non-Related References
Because the ploynomial commitments does not Pedersen commitment and DLEQ is only computaional secure, not information-theoretic secure in this project.
-
crypto-stackexchange. What is a Pedersen commitment?
-
Torben Pryds Pedersen. Non-Interactive and Information-Theoretic Secure Verifiable Secret Sharing
-
Chunming Tang. Dingyi Pei. Non-Interactive and Information-Theoretic Secure Publicly Verifiable Secret Sharing
License
Dual-licensed to be compatible with the Rust project.
Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.