Trait aleph_bft::Keychain

source ·
pub trait Keychain: Index + Clone + Send + Sync + 'static {
    type Signature: Signature;

    // Required methods
    fn node_count(&self) -> NodeCount;
    fn sign(&self, msg: &[u8]) -> Self::Signature;
    fn verify(
        &self,
        msg: &[u8],
        sgn: &Self::Signature,
        index: NodeIndex
    ) -> bool;
}
Expand description

Abstraction of the signing data and verifying signatures.

A typical implementation of Keychain would be a collection of N public keys, an index i and a single private key corresponding to the public key number i. The meaning of sign is then to produce a signature s using the given private key, and verify(msg, s, j) is to verify whether the signature s under the message msg is correct with respect to the public key of the jth node.

Required Associated Types§

Required Methods§

source

fn node_count(&self) -> NodeCount

Returns the total number of known public keys.

source

fn sign(&self, msg: &[u8]) -> Self::Signature

Signs a message msg.

source

fn verify(&self, msg: &[u8], sgn: &Self::Signature, index: NodeIndex) -> bool

Verifies whether a node with index correctly signed the message msg. Should always return false for indices outside the node range.

Object Safety§

This trait is not object safe.

Implementors§