nubls 0.1.0

A BLS (Boneh-Lynn-Shacham) signature implementation written in pure Rust that offers support for threshold signatures with Shamir's Secret Sharing, and a Proxy Re-Signature (PRS) algorithm designed by NuCypher called Penumbral.
Documentation
use crate::bls::Signature;
use crate::keys::PublicKey;

/// A trait that describes a key that can be used for threshold cryptography
/// protocols. The key that has this trait implemented on it can be split into
/// `n` fragments where `m` fragments (the threshold) must be recovered to
/// re-assemble the full key.
///
/// This is done by implementing a secret sharing scheme such as Shamir's Secret Sharing.
pub trait ThresholdKey: Sized {
    /// The `split` method splits the Threshold key into `n` fragments with
    /// a threshold of `m` fragments required to re-assemble the full key.
    ///
    /// Returns the `n` fragments in a `Vec`.
    fn split(&self, m: usize, n: usize) -> Vec<Self>;

    /// The `recover` function returns the re-assembled key given the threshold
    /// `m` fragments.
    fn recover(fragments: &[Self]) -> Self;

    /// The `is_fragment` method returns a `bool` when the `PrivateKey` is
    /// used for a threshold computation.
    fn is_fragment(&self) -> bool;
}

/// A trait that describes a signature from a threshold signing protocol.
/// Given a threshold set of signature fragments, a full signature can be assembled
/// and verified by its corresponding threshold key.
pub trait ThresholdSignature: Sized {
    /// The `assemble` function assembles a signature given a `Vec` containing a
    /// threshold amount of signatures.
    /// The fully-assembled signature can be verified by its corresponding
    /// threshold key.
    fn assemble(fragments: &[Self]) -> Self;

    /// The `is_fragment` method returns a `bool` when the `PrivateKey` is
    /// used for a threshold computation.
    fn is_fragment(&self) -> bool;
}

/// A trait that describes the Penumbral Proxy Re-Signature protocol.
/// Given a Re-Signature key, a BLS signature can be re-signed from Bob's
/// key to Alice's key.
pub trait PRSKey: Sized {
    /// Generates a re-signing key from Bob's designated key to the `self` key.
    fn resigning_key(&self, bob_pubkey: &PublicKey) -> Self;

    /// Returns the designated PRS key that Bob signs with.
    /// Signatures made under this key can be re-signed from Bob to Alice given
    /// a re-signing key generated by Alice.
    fn designated_key(&self, alice_pubkey: &PublicKey) -> Self;

    /// Performs a re-signature with the re-signing key to transform a
    /// Signature under Bob's designated key to Alice's key.
    fn resign(&self, signature: &Signature) -> Signature;
}