Trait EncryptionKey

Source
pub trait EncryptionKey:
    Sized
    + Debug
    + PartialEq {
    type Input;
    type Plaintext;
    type Ciphertext: Associable<Self>;
    type Randomness;

    // Required methods
    fn encrypt_without_randomness(
        &self,
        plaintext: &Self::Plaintext,
    ) -> Self::Ciphertext;
    fn randomize<R: SecureRng>(
        &self,
        ciphertext: Self::Ciphertext,
        rng: &mut GeneralRng<R>,
    ) -> Self::Ciphertext;
    fn randomize_with(
        &self,
        ciphertext: Self::Ciphertext,
        randomness: &Self::Randomness,
    ) -> Self::Ciphertext;

    // Provided methods
    fn encrypt<'pk, R: SecureRng>(
        &'pk self,
        plaintext: &Self::Plaintext,
        rng: &mut GeneralRng<R>,
    ) -> AssociatedCiphertext<'pk, Self::Ciphertext, Self> { ... }
    fn encrypt_raw<R: SecureRng>(
        &self,
        plaintext: &Self::Plaintext,
        rng: &mut GeneralRng<R>,
    ) -> Self::Ciphertext { ... }
}
Expand description

The encryption key.

Required Associated Types§

Source

type Input

Input is the type used to multiply additive ciphertexts or exponentiate multiplicative ciphertexts.

Source

type Plaintext

The type of the plaintext to be encrypted.

Source

type Ciphertext: Associable<Self>

The type of an encrypted plaintext, i.e. a ciphertext.

Source

type Randomness

The type of the randomness used.

Required Methods§

Source

fn encrypt_without_randomness( &self, plaintext: &Self::Plaintext, ) -> Self::Ciphertext

WARNING: This is not a full encryption. The resulting ciphertext is completely insecure. ‘Encrypts’ the plaintext using the public key deterministically, essentially creating a trivial ciphertext. The encryption is not secure until you call randomize or randomize_with with suitable randomness.

Source

fn randomize<R: SecureRng>( &self, ciphertext: Self::Ciphertext, rng: &mut GeneralRng<R>, ) -> Self::Ciphertext

Randomizes the ciphertext with the supplied rng.

Source

fn randomize_with( &self, ciphertext: Self::Ciphertext, randomness: &Self::Randomness, ) -> Self::Ciphertext

Randomizes the ciphertext with the user supplied randomness.

Provided Methods§

Source

fn encrypt<'pk, R: SecureRng>( &'pk self, plaintext: &Self::Plaintext, rng: &mut GeneralRng<R>, ) -> AssociatedCiphertext<'pk, Self::Ciphertext, Self>

Encrypt the plaintext using the public key and a cryptographic RNG and immediately associate it with the public key.

Source

fn encrypt_raw<R: SecureRng>( &self, plaintext: &Self::Plaintext, rng: &mut GeneralRng<R>, ) -> Self::Ciphertext

Encrypt the plaintext using the public key and a cryptographic RNG.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§