pub struct HomomorphicElGamal { /* private fields */ }Expand description
Wrapper for ElGamal that enables operator overrides This allows using standard operators like +, -, *, / on ciphertexts
Implementations§
Source§impl HomomorphicElGamal
impl HomomorphicElGamal
Sourcepub fn inner_mut(&mut self) -> &mut ElGamal
pub fn inner_mut(&mut self) -> &mut ElGamal
Get a mutable reference to the underlying ElGamal instance
Sourcepub fn encrypt(&self, plaintext: &BigUint) -> Result<Ciphertext>
pub fn encrypt(&self, plaintext: &BigUint) -> Result<Ciphertext>
Encrypt a plaintext
Sourcepub fn decrypt(
&self,
ciphertext: &Ciphertext,
private_key: &PrivateKey,
) -> Result<BigUint>
pub fn decrypt( &self, ciphertext: &Ciphertext, private_key: &PrivateKey, ) -> Result<BigUint>
Decrypt a ciphertext
Source§impl HomomorphicElGamal
impl HomomorphicElGamal
Sourcepub fn add(&self, ct1: &Ciphertext, ct2: &Ciphertext) -> Result<Ciphertext>
pub fn add(&self, ct1: &Ciphertext, ct2: &Ciphertext) -> Result<Ciphertext>
Add two ciphertexts (semantic meaning depends on mode)
Sourcepub fn sub(&self, ct1: &Ciphertext, ct2: &Ciphertext) -> Result<Ciphertext>
pub fn sub(&self, ct1: &Ciphertext, ct2: &Ciphertext) -> Result<Ciphertext>
Subtract two ciphertexts (additive mode only)
Sourcepub fn mul(&self, ct1: &Ciphertext, ct2: &Ciphertext) -> Result<Ciphertext>
pub fn mul(&self, ct1: &Ciphertext, ct2: &Ciphertext) -> Result<Ciphertext>
Multiply two ciphertexts (semantic meaning depends on mode)
Sourcepub fn div(&self, ct1: &Ciphertext, ct2: &Ciphertext) -> Result<Ciphertext>
pub fn div(&self, ct1: &Ciphertext, ct2: &Ciphertext) -> Result<Ciphertext>
Divide two ciphertexts (multiplicative mode only)
Sourcepub fn neg(&self, ct: &Ciphertext) -> Result<Ciphertext>
pub fn neg(&self, ct: &Ciphertext) -> Result<Ciphertext>
Negate a ciphertext (additive mode only)
Sourcepub fn add_scalar(
&self,
ct: &Ciphertext,
scalar: &BigUint,
) -> Result<Ciphertext>
pub fn add_scalar( &self, ct: &Ciphertext, scalar: &BigUint, ) -> Result<Ciphertext>
Scalar addition (additive mode only)
Sourcepub fn sub_scalar(
&self,
ct: &Ciphertext,
scalar: &BigUint,
) -> Result<Ciphertext>
pub fn sub_scalar( &self, ct: &Ciphertext, scalar: &BigUint, ) -> Result<Ciphertext>
Scalar subtraction (additive mode only)
Sourcepub fn mul_scalar(
&self,
ct: &Ciphertext,
scalar: &BigUint,
) -> Result<Ciphertext>
pub fn mul_scalar( &self, ct: &Ciphertext, scalar: &BigUint, ) -> Result<Ciphertext>
Scalar multiplication (both modes)
Sourcepub fn div_scalar(
&self,
ct: &Ciphertext,
scalar: &BigUint,
) -> Result<Ciphertext>
pub fn div_scalar( &self, ct: &Ciphertext, scalar: &BigUint, ) -> Result<Ciphertext>
Scalar division (multiplicative mode only)
Trait Implementations§
Source§impl Clone for HomomorphicElGamal
impl Clone for HomomorphicElGamal
Source§fn clone(&self) -> HomomorphicElGamal
fn clone(&self) -> HomomorphicElGamal
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HomomorphicElGamal
impl RefUnwindSafe for HomomorphicElGamal
impl Send for HomomorphicElGamal
impl Sync for HomomorphicElGamal
impl Unpin for HomomorphicElGamal
impl UnsafeUnpin for HomomorphicElGamal
impl UnwindSafe for HomomorphicElGamal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more