dkg_core/
lib.rs

1//! # DKG Core
2//!
3//! The DKG is based on the [Secure Distributed Key Generation for Discrete-Log Based Cryptosystems
4//! ](https://link.springer.com/article/10.1007/s00145-006-0347-3) paper.
5//!
6//! The implementation is a state machine which has Phases 0 to 3. Phase 3 is only reachable if any of the
7//! n parties does not publish its shares in the first phase. If less than t parties participate in any stage,
8//! the DKG fails.
9
10/// Board trait and implementations for publishing data from each DKG phase
11pub mod board;
12pub use board::BoardPublisher;
13
14/// Higher level objects for running a JF-DKG
15pub mod node;
16pub use node::{DKGNodeError, DKGPhase, Phase2Result};
17use threshold_bls::group::Element;
18use threshold_bls::sig::Scheme;
19
20/// Low level primitives and datatypes for implementing DKGs
21pub mod primitives;
22
23#[cfg(test)]
24pub mod test_helpers;
25
26pub fn generate_keypair<S: Scheme>() -> (S::Private, S::Public) {
27    let rng = &mut rand::thread_rng();
28
29    let private = S::Private::rand(rng);
30
31    let mut public = S::Public::one();
32    public.mul(&private);
33
34    (private, public)
35}