Trait scicrypt::AsymmetricCryptosystem [−][src]
pub trait AsymmetricCryptosystem { type Plaintext; type Ciphertext; type PublicKey; type SecretKey; fn generate_keys<R: RngCore + CryptoRng>(
&self,
rng: &mut SecureRng<R>
) -> (Self::PublicKey, Self::SecretKey); fn encrypt<R: RngCore + CryptoRng>(
&self,
plaintext: &Self::Plaintext,
public_key: &Self::PublicKey,
rng: &mut SecureRng<R>
) -> Self::Ciphertext; fn decrypt(
&self,
rich_ciphertext: &RichCiphertext<'_, Self::Ciphertext, Self::PublicKey>,
secret_key: &Self::SecretKey
) -> Self::Plaintext; }
Expand description
An asymmetric cryptosystem is a system of methods to encrypt plaintexts into ciphertexts, and decrypt those ciphertexts back into plaintexts. Anyone who has access to the public key can perform encryptions, but only those with the secret key can decrypt.
The struct that implements an AsymmetricCryptosystem
will hold the general parameters of that
cryptosystem. Depending on the cryptosystem, those parameters could play an important role in
deciding the level of security. As such, each cryptosystem should clearly indicate these.
Associated Types
type Ciphertext
type Ciphertext
The type of the encrypted plaintexts.
Required methods
Generate a public and private key pair using a cryptographic RNG.
Encrypt the plaintext using the public key and a cryptographic RNG.
fn decrypt(
&self,
rich_ciphertext: &RichCiphertext<'_, Self::Ciphertext, Self::PublicKey>,
secret_key: &Self::SecretKey
) -> Self::Plaintext
fn decrypt(
&self,
rich_ciphertext: &RichCiphertext<'_, Self::Ciphertext, Self::PublicKey>,
secret_key: &Self::SecretKey
) -> Self::Plaintext
Decrypt the ciphertext using the secret key and its related public key.