Struct elastic_elgamal::SecretKey
source · 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