Module scicrypt::cryptosystems::integer_el_gamal
source · [−]Expand description
Implementation of the ElGamal cryptosystem over a safe prime group. Here is an example of how to generates a key pair and encrypt a plaintext integer using the ElGamal public key.
use scicrypt_traits::randomness::GeneralRng;
use scicrypt_he::cryptosystems::integer_el_gamal::IntegerElGamal;
use scicrypt_traits::security::BitsOfSecurity;
use scicrypt_traits::cryptosystems::{AsymmetricCryptosystem, EncryptionKey};
use rand_core::OsRng;
use scicrypt_bigint::UnsignedInteger;
let mut rng = GeneralRng::new(OsRng);
let el_gamal = IntegerElGamal::setup(&Default::default());
let (public_key, secret_key) = el_gamal.generate_keys(&mut rng);
let ciphertext = public_key.encrypt(&UnsignedInteger::from(5), &mut rng);
Structs
Multiplicatively homomorphic ElGamal over a safe prime group where the generator is 4.
ElGamal ciphertext of integers.
Public key containing the ElGamal encryption key and the modulus of the group.
Decryption key for Integer-based ElGamal