Trait scicrypt_traits::cryptosystems::EncryptionKey
source · [−]pub trait EncryptionKey: Sized + Debug + PartialEq {
type Input;
type Plaintext;
type Ciphertext: Associable<Self>;
type Randomness;
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;
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
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.