pub struct SecretKey<G: Group>(/* private fields */);
Expand description
Secret key for ElGamal encryption and related protocols. This is a thin wrapper around
the Group
scalar.
Implementations§
Source§impl<G: Group> SecretKey<G>
impl<G: Group> SecretKey<G>
Sourcepub fn decrypt_to_element(&self, encrypted: Ciphertext<G>) -> G::Element
pub fn decrypt_to_element(&self, encrypted: Ciphertext<G>) -> G::Element
Decrypts the provided ciphertext and returns the produced group element.
As the ciphertext does not include a MAC or another way to assert integrity, this operation cannot fail. If the ciphertext is not produced properly (e.g., it targets another receiver), the returned group element will be garbage.
Sourcepub fn decrypt(
&self,
encrypted: Ciphertext<G>,
lookup_table: &DiscreteLogTable<G>,
) -> Option<u64>
pub fn decrypt( &self, encrypted: Ciphertext<G>, lookup_table: &DiscreteLogTable<G>, ) -> Option<u64>
Decrypts the provided ciphertext and returns the original encrypted value.
lookup_table
is used to find encrypted values based on the original decrypted
group element. That is, it must contain all valid plaintext values. If the value
is not in the table, this method will return None
.
Trait Implementations§
Source§impl<G: Group> AddAssign for SecretKey<G>
impl<G: Group> AddAssign for SecretKey<G>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moreSource§impl<'de, G: Group> Deserialize<'de> for SecretKey<G>
impl<'de, G: Group> Deserialize<'de> for SecretKey<G>
Source§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
Auto Trait Implementations§
impl<G> Freeze for SecretKey<G>
impl<G> RefUnwindSafe for SecretKey<G>
impl<G> Send for SecretKey<G>
impl<G> Sync for SecretKey<G>
impl<G> Unpin for SecretKey<G>
impl<G> UnwindSafe for SecretKey<G>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)