Struct blsttc::PublicKeySet [−][src]
pub struct PublicKeySet { /* fields omitted */ }
Expand description
A public key and an associated set of public key shares.
Implementations
Returns the threshold t
: any set of t + 1
signature shares can be combined into a full
signature.
Returns the public key.
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,
pub fn combine_signatures<'a, T, I>(&self, shares: I) -> Result<Signature> where
I: IntoIterator<Item = (T, &'a SignatureShare)>,
T: IntoFr,
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,
pub fn decrypt<'a, T, I>(&self, shares: I, ct: &Ciphertext) -> Result<Vec<u8>> where
I: IntoIterator<Item = (T, &'a DecryptionShare)>,
T: IntoFr,
Combines the shares to decrypt the ciphertext.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for PublicKeySet
impl Send for PublicKeySet
impl Sync for PublicKeySet
impl Unpin for PublicKeySet
impl UnwindSafe for PublicKeySet
Blanket Implementations
Mutably borrows from an owned value. Read more