pub struct DecryptionKey { /* private fields */ }
Expand description
An ElGamal decryption key (also called a private key in other implementations).
Implementations§
Source§impl DecryptionKey
impl DecryptionKey
Sourcepub fn new<R: RngCore + CryptoRng>(rng: &mut R) -> Self
pub fn new<R: RngCore + CryptoRng>(rng: &mut R) -> Self
Generate a new ElGamal decryption key using the randomness source rng
, together with
its corresponding encryption key.
§Example
use rand::rngs::StdRng;
use rand::SeedableRng;
use rust_elgamal::DecryptionKey;
let mut rng = StdRng::from_entropy();
let dec_key = DecryptionKey::new(&mut rng);
Sourcepub fn decrypt(&self, ct: Ciphertext) -> RistrettoPoint
pub fn decrypt(&self, ct: Ciphertext) -> RistrettoPoint
Decrypt the ciphertext ct
.
§Example
use rand::rngs::StdRng;
use rand::SeedableRng;
use rust_elgamal::{DecryptionKey, GENERATOR_TABLE, Scalar};
let mut rng = StdRng::from_entropy();
let dec_key = DecryptionKey::new(&mut rng);
let m = &Scalar::from(5u32) * &GENERATOR_TABLE;
let ct = dec_key.encryption_key().encrypt(m, &mut rng);
let decrypted = dec_key.decrypt(ct);
assert_eq!(m, decrypted);
Sourcepub fn encryption_key(&self) -> &EncryptionKey
pub fn encryption_key(&self) -> &EncryptionKey
Retrieve the encryption key corresponding to this decryption key.
Trait Implementations§
Source§impl AsRef<Scalar> for DecryptionKey
impl AsRef<Scalar> for DecryptionKey
Source§impl Clone for DecryptionKey
impl Clone for DecryptionKey
Source§fn clone(&self) -> DecryptionKey
fn clone(&self) -> DecryptionKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for DecryptionKey
impl Debug for DecryptionKey
Source§impl From<DecryptionKey> for EncryptionKey
impl From<DecryptionKey> for EncryptionKey
Source§fn from(dk: DecryptionKey) -> Self
fn from(dk: DecryptionKey) -> Self
Converts to this type from the input type.
Source§impl From<Scalar> for DecryptionKey
impl From<Scalar> for DecryptionKey
Source§impl PartialEq for DecryptionKey
impl PartialEq for DecryptionKey
impl Copy for DecryptionKey
impl Eq for DecryptionKey
impl StructuralPartialEq for DecryptionKey
Auto Trait Implementations§
impl Freeze for DecryptionKey
impl RefUnwindSafe for DecryptionKey
impl Send for DecryptionKey
impl Sync for DecryptionKey
impl Unpin for DecryptionKey
impl UnwindSafe for DecryptionKey
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