#[cfg(not(feature = "elgamal3"))]
use crate::data::traits::Encryptable;
use crate::data::traits::{Encrypted, Pseudonymizable, Rekeyable, Transcryptable};
use crate::factors::{PseudonymizationInfo, RerandomizeFactor, TranscryptionInfo};
use rand_core::{CryptoRng, Rng};
pub fn pseudonymize<E>(encrypted: &E, info: &PseudonymizationInfo) -> E
where
E: Pseudonymizable,
{
encrypted.pseudonymize(info)
}
pub fn rekey<E>(encrypted: &E, info: &E::RekeyInfo) -> E
where
E: Rekeyable,
{
encrypted.rekey(info)
}
pub fn transcrypt<E>(encrypted: &E, info: &TranscryptionInfo) -> E
where
E: Transcryptable,
{
encrypted.transcrypt(info)
}
#[cfg(feature = "elgamal3")]
pub fn rerandomize<R, E>(encrypted: &E, rng: &mut R) -> E
where
E: Encrypted,
R: Rng + CryptoRng,
{
encrypted.rerandomize(rng)
}
#[cfg(not(feature = "elgamal3"))]
pub fn rerandomize<R, E>(
encrypted: &E,
public_key: &<E::UnencryptedType as Encryptable>::PublicKeyType,
rng: &mut R,
) -> E
where
E: Encrypted,
R: Rng + CryptoRng,
{
encrypted.rerandomize(public_key, rng)
}
#[cfg(feature = "elgamal3")]
pub fn rerandomize_known<E>(encrypted: &E, factor: &RerandomizeFactor) -> E
where
E: Encrypted,
{
encrypted.rerandomize_known(factor)
}
#[cfg(not(feature = "elgamal3"))]
pub fn rerandomize_known<E>(
encrypted: &E,
public_key: &<E::UnencryptedType as Encryptable>::PublicKeyType,
factor: &RerandomizeFactor,
) -> E
where
E: Encrypted,
{
encrypted.rerandomize_known(public_key, factor)
}