[][src]Struct threshold_crypto::PublicKeySet

pub struct PublicKeySet { /* fields omitted */ }

A public key and an associated set of public key shares.

Methods

impl PublicKeySet[src]

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

Returns the threshold t: any set of t + 1 signature shares can be combined into a full signature.

pub fn public_key(&self) -> PublicKey[src]

Returns the public key.

pub fn public_key_share<T: IntoFr>(&self, i: T) -> PublicKeyShare[src]

Returns the i-th public key share.

pub fn combine_signatures<'a, T, I>(&self, shares: I) -> Result<Signature> where
    I: IntoIterator<Item = (T, &'a SignatureShare)>,
    T: IntoFr
[src]

Combines the shares into a signature that can be verified with the main public key.

The validity of the shares is not checked: If one of them is invalid, the resulting signature also is. Only returns an error if there is a duplicate index or too few shares.

Validity of signature shares should be checked beforehand, or validity of the result afterwards:

let sk_set = SecretKeySet::random(3, &mut rand::thread_rng());
let sk_shares: Vec<_> = (0..6).map(|i| sk_set.secret_key_share(i)).collect();
let pk_set = sk_set.public_keys();
let msg = "Happy birthday! If this is signed, at least four people remembered!";

// Create four signature shares for the message.
let sig_shares: BTreeMap<_, _> = (0..4).map(|i| (i, sk_shares[i].sign(msg))).collect();

// Validate the signature shares.
for (i, sig_share) in &sig_shares {
    assert!(pk_set.public_key_share(*i).verify(sig_share, msg));
}

// Combine them to produce the main signature.
let sig = pk_set.combine_signatures(&sig_shares).expect("not enough shares");

// Validate the main signature. If the shares were valid, this can't fail.
assert!(pk_set.public_key().verify(&sig, msg));

pub fn decrypt<'a, T, I>(&self, shares: I, ct: &Ciphertext) -> Result<Vec<u8>> where
    I: IntoIterator<Item = (T, &'a DecryptionShare)>,
    T: IntoFr
[src]

Combines the shares to decrypt the ciphertext.

Trait Implementations

impl Clone for PublicKeySet[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Ord for PublicKeySet[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl From<Commitment> for PublicKeySet[src]

impl PartialOrd<PublicKeySet> for PublicKeySet[src]

impl PartialEq<PublicKeySet> for PublicKeySet[src]

impl Eq for PublicKeySet[src]

impl Debug for PublicKeySet[src]

impl Hash for PublicKeySet[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Serialize for PublicKeySet[src]

impl<'de> Deserialize<'de> for PublicKeySet[src]

Auto Trait Implementations

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]