Skip to main content

arcanum_threshold/
lib.rs

1//! # Arcanum Threshold Cryptography
2//!
3//! Threshold cryptographic schemes for distributed key management and signing.
4//!
5//! ## Secret Sharing
6//!
7//! - **Shamir**: Basic (t, n) secret sharing
8//! - **Feldman**: Verifiable secret sharing with public commitments
9//! - **Pedersen**: Information-theoretically hiding verifiable secret sharing
10//!
11//! ## Threshold Signatures (FROST)
12//!
13//! FROST (Flexible Round-Optimized Schnorr Threshold) signatures:
14//!
15//! - **FROST-Ed25519**: Ed25519-compatible threshold signatures
16//! - **FROST-secp256k1**: Bitcoin/Ethereum compatible signatures
17//!
18//! ## Distributed Key Generation (DKG)
19//!
20//! Generate group keys without trusted dealer:
21//!
22//! - **Pedersen DKG**: Two-round DKG with information-theoretic security
23//! - **FROST DKG**: Integrated key generation for FROST signing
24//!
25//! ## Proactive Refresh
26//!
27//! Limit the window of compromise with periodic share refresh:
28//!
29//! - **Centralized refresh**: Dealer refreshes all shares at once
30//! - **Distributed refresh**: Participants cooperatively refresh without dealer
31//!
32//! After refresh, old shares are incompatible with new shares, preventing
33//! attackers from combining shares collected over different time periods.
34//!
35//! ## Example
36//!
37//! ```ignore
38//! use arcanum_threshold::prelude::*;
39//!
40//! // Create 3-of-5 Shamir sharing
41//! let secret = b"my secret key";
42//! let shares = ShamirScheme::split(secret, 3, 5)?;
43//!
44//! // Reconstruct from any 3 shares
45//! let recovered = ShamirScheme::combine(&shares[..3])?;
46//! assert_eq!(secret.as_slice(), recovered.as_slice());
47//! ```
48
49#![deny(unsafe_code)]
50#![warn(missing_docs, rust_2018_idioms)]
51#![allow(
52    clippy::needless_range_loop,
53    clippy::needless_borrow,
54    clippy::needless_borrows_for_generic_args
55)]
56
57mod error;
58
59#[cfg(feature = "shamir")]
60pub mod shamir;
61
62#[cfg(feature = "frost")]
63pub mod frost;
64
65#[cfg(feature = "dkg")]
66pub mod dkg;
67
68#[cfg(feature = "proactive")]
69pub mod proactive;
70
71pub use error::{Result, ThresholdError};
72
73#[cfg(feature = "shamir")]
74pub use shamir::{ShamirScheme, Share};
75
76#[cfg(feature = "frost")]
77pub use frost::{FrostSigner, FrostVerifier, SigningShare, VerifyingShare};
78
79#[cfg(feature = "dkg")]
80pub use dkg::{DkgParticipant, DkgRound1, DkgRound2};
81
82#[cfg(feature = "proactive")]
83pub use proactive::{ProactiveRefresh, RefreshShares};
84
85/// Prelude for convenient imports.
86pub mod prelude {
87    pub use crate::error::{Result, ThresholdError};
88
89    #[cfg(feature = "shamir")]
90    pub use crate::shamir::{ShamirScheme, Share};
91
92    #[cfg(feature = "frost")]
93    pub use crate::frost::{FrostSigner, FrostVerifier};
94
95    #[cfg(feature = "dkg")]
96    pub use crate::dkg::{DkgParticipant, DkgRound1, DkgRound2};
97
98    #[cfg(feature = "proactive")]
99    pub use crate::proactive::{ProactiveRefresh, RefreshShares};
100}
101
102/// Re-export identifier type for participants.
103pub type Identifier = u16;