[][src]Struct rust_elgamal::DecryptionKey

pub struct DecryptionKey { /* fields omitted */ }

An ElGamal decryption key (also called a private key in other implementations).

Implementations

impl DecryptionKey[src]

pub fn new<R: RngCore + CryptoRng>(rng: &mut R) -> Self[src]

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);

pub fn decrypt(&self, ct: Ciphertext) -> RistrettoPoint[src]

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);

pub fn encryption_key(&self) -> &EncryptionKey[src]

Retrieve the encryption key corresponding to this decryption key.

Trait Implementations

impl AsRef<Scalar> for DecryptionKey[src]

impl Clone for DecryptionKey[src]

impl Copy for DecryptionKey[src]

impl Debug for DecryptionKey[src]

impl Eq for DecryptionKey[src]

impl From<DecryptionKey> for EncryptionKey[src]

impl From<Scalar> for DecryptionKey[src]

impl PartialEq<DecryptionKey> for DecryptionKey[src]

impl StructuralEq for DecryptionKey[src]

impl StructuralPartialEq for DecryptionKey[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.