[][src]Struct hbbft::sync_key_gen::SyncKeyGen

pub struct SyncKeyGen<N> { /* fields omitted */ }

A synchronous algorithm for dealerless distributed key generation.

It requires that all nodes handle all messages in the exact same order.

Methods

impl<N: NodeIdT> SyncKeyGen<N>[src]

pub fn new<R: Rng>(
    our_id: N,
    sec_key: SecretKey,
    pub_keys: BTreeMap<N, PublicKey>,
    threshold: usize,
    rng: &mut R
) -> Result<(SyncKeyGen<N>, Option<Part>), Error>
[src]

Creates a new SyncKeyGen instance, together with the Part message that should be multicast to all nodes.

If we are not a validator but only an observer, no Part message is produced and no messages need to be sent.

pub fn public_keys(&self) -> &BTreeMap<N, PublicKey>[src]

Returns the map of participating nodes and their public keys.

pub fn handle_part<R: Rng>(
    &mut self,
    sender_id: &N,
    part: Part,
    rng: &mut R
) -> Result<PartOutcome, Error>
[src]

Handles a Part message. If it is valid, returns an Ack message to be broadcast.

If we are only an observer, None is returned instead and no messages need to be sent.

All participating nodes must handle the exact same sequence of messages. Note that handle_part also needs to explicitly be called with this instance's own Part.

pub fn handle_ack(
    &mut self,
    sender_id: &N,
    ack: Ack
) -> Result<AckOutcome, Error>
[src]

Handles an Ack message.

All participating nodes must handle the exact same sequence of messages. Note that handle_ack also needs to explicitly be called with this instance's own Acks.

pub fn count_complete(&self) -> usize[src]

Returns the number of complete parts. If this is at least threshold + 1, the keys can be generated, but it is possible to wait for more to increase security.

pub fn is_node_ready(&self, proposer_id: &N) -> bool[src]

Returns true if the part of the given node is complete.

pub fn is_ready(&self) -> bool[src]

Returns true if enough parts are complete to safely generate the new key.

pub fn generate(&self) -> Result<(PublicKeySet, Option<SecretKeyShare>), Error>[src]

Returns the new secret key share and the public key set.

These are only secure if is_ready returned true. Otherwise it is not guaranteed that none of the nodes knows the secret master key.

If we are only an observer node, no secret key share is returned.

All participating nodes must have handled the exact same sequence of Part and Ack messages before calling this method. Otherwise their key shares will not match.

pub fn into_network_info(self) -> Result<NetworkInfo<N>, Error>[src]

Consumes the instance, generates the key set and returns a new NetworkInfo with the new keys.

All participating nodes must have handled the exact same sequence of Part and Ack messages before calling this method. Otherwise their key shares will not match.

pub fn num_nodes(&self) -> usize[src]

Returns the number of nodes participating in the key generation.

Trait Implementations

impl<N: Debug> Debug for SyncKeyGen<N>[src]

Auto Trait Implementations

impl<N> Send for SyncKeyGen<N> where
    N: Send

impl<N> Sync for SyncKeyGen<N> where
    N: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.