[−][src]Struct threshold_crypto::PublicKeySet
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]
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,
[src]
I: IntoIterator<Item = (T, &'a DecryptionShare)>,
T: IntoFr,
Combines the shares to decrypt the ciphertext.
Trait Implementations
impl Clone for PublicKeySet
[src]
fn clone(&self) -> 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 cmp(&self, other: &PublicKeySet) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl From<Commitment> for PublicKeySet
[src]
fn from(commit: Commitment) -> PublicKeySet
[src]
impl PartialOrd<PublicKeySet> for PublicKeySet
[src]
fn partial_cmp(&self, other: &PublicKeySet) -> Option<Ordering>
[src]
fn lt(&self, other: &PublicKeySet) -> bool
[src]
fn le(&self, other: &PublicKeySet) -> bool
[src]
fn gt(&self, other: &PublicKeySet) -> bool
[src]
fn ge(&self, other: &PublicKeySet) -> bool
[src]
impl PartialEq<PublicKeySet> for PublicKeySet
[src]
fn eq(&self, other: &PublicKeySet) -> bool
[src]
fn ne(&self, other: &PublicKeySet) -> bool
[src]
impl Eq for PublicKeySet
[src]
impl Debug for PublicKeySet
[src]
impl Hash for PublicKeySet
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Serialize for PublicKeySet
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for PublicKeySet
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl Sync for PublicKeySet
impl Send for PublicKeySet
impl Unpin for PublicKeySet
impl RefUnwindSafe for PublicKeySet
impl UnwindSafe for PublicKeySet
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,