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§
Sourcetype Input
type Input
Input is the type used to multiply additive ciphertexts or exponentiate multiplicative ciphertexts.
Sourcetype Ciphertext: Associable<Self>
type Ciphertext: Associable<Self>
The type of an encrypted plaintext, i.e. a ciphertext.
Sourcetype Randomness
type Randomness
The type of the randomness used.
Required Methods§
Sourcefn encrypt_without_randomness(
&self,
plaintext: &Self::Plaintext,
) -> Self::Ciphertext
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.
Sourcefn randomize<R: SecureRng>(
&self,
ciphertext: Self::Ciphertext,
rng: &mut GeneralRng<R>,
) -> Self::Ciphertext
fn randomize<R: SecureRng>( &self, ciphertext: Self::Ciphertext, rng: &mut GeneralRng<R>, ) -> Self::Ciphertext
Randomizes the ciphertext with the supplied rng.
Sourcefn randomize_with(
&self,
ciphertext: Self::Ciphertext,
randomness: &Self::Randomness,
) -> Self::Ciphertext
fn randomize_with( &self, ciphertext: Self::Ciphertext, randomness: &Self::Randomness, ) -> Self::Ciphertext
Randomizes the ciphertext with the user supplied randomness.
Provided Methods§
Sourcefn encrypt<'pk, R: SecureRng>(
&'pk self,
plaintext: &Self::Plaintext,
rng: &mut GeneralRng<R>,
) -> AssociatedCiphertext<'pk, Self::Ciphertext, Self>
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.
Sourcefn encrypt_raw<R: SecureRng>(
&self,
plaintext: &Self::Plaintext,
rng: &mut GeneralRng<R>,
) -> Self::Ciphertext
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.