Struct fast_paillier::EncryptionKey
source · pub struct EncryptionKey { /* private fields */ }
Expand description
Paillier encryption key
Implementations§
source§impl EncryptionKey
impl EncryptionKey
sourcepub fn encrypt_with(
&self,
x: &Plaintext,
nonce: &Nonce
) -> Result<Ciphertext, Error>
pub fn encrypt_with( &self, x: &Plaintext, nonce: &Nonce ) -> Result<Ciphertext, Error>
Encrypts the plaintext x
in {-N/2, .., N_2}
with nonce
in Z*_n
Returns error if inputs are not in specified range
sourcepub fn encrypt_with_random(
&self,
rng: &mut (impl RngCore + CryptoRng),
x: &Plaintext
) -> Result<(Ciphertext, Nonce), Error>
pub fn encrypt_with_random( &self, rng: &mut (impl RngCore + CryptoRng), x: &Plaintext ) -> Result<(Ciphertext, Nonce), Error>
Encrypts the plaintext x
in {-N/2, .., N_2}
Nonce is sampled randomly using rng
.
Returns error if plaintext is not in specified range
sourcepub fn oadd(
&self,
c1: &Ciphertext,
c2: &Ciphertext
) -> Result<Ciphertext, Error>
pub fn oadd( &self, c1: &Ciphertext, c2: &Ciphertext ) -> Result<Ciphertext, Error>
Homomorphic addition of two ciphertexts
oadd(Enc(a1), Enc(a2)) = Enc(a1 + a2)
sourcepub fn osub(
&self,
c1: &Ciphertext,
c2: &Ciphertext
) -> Result<Ciphertext, Error>
pub fn osub( &self, c1: &Ciphertext, c2: &Ciphertext ) -> Result<Ciphertext, Error>
Homomorphic subtraction of two ciphertexts
osub(Enc(a1), Enc(a2)) = Enc(a1 - a2)
sourcepub fn omul(
&self,
scalar: &Integer,
ciphertext: &Ciphertext
) -> Result<Ciphertext, Error>
pub fn omul( &self, scalar: &Integer, ciphertext: &Ciphertext ) -> Result<Ciphertext, Error>
Homomorphic multiplication of scalar at ciphertext
omul(a, Enc(c)) = Enc(a * c)
sourcepub fn oneg(&self, ciphertext: &Ciphertext) -> Result<Ciphertext, Error>
pub fn oneg(&self, ciphertext: &Ciphertext) -> Result<Ciphertext, Error>
Homomorphic negation of a ciphertext
oneg(Enc(a)) = Enc(-a)
sourcepub fn in_signed_group(&self, x: &Integer) -> bool
pub fn in_signed_group(&self, x: &Integer) -> bool
Checks whether x
is {-N/2, .., N/2}
Trait Implementations§
source§impl AnyEncryptionKey for EncryptionKey
impl AnyEncryptionKey for EncryptionKey
source§fn encrypt_with(
&self,
x: &Plaintext,
nonce: &Nonce
) -> Result<Ciphertext, Error>
fn encrypt_with( &self, x: &Plaintext, nonce: &Nonce ) -> Result<Ciphertext, Error>
source§fn oadd(&self, c1: &Ciphertext, c2: &Ciphertext) -> Result<Ciphertext, Error>
fn oadd(&self, c1: &Ciphertext, c2: &Ciphertext) -> Result<Ciphertext, Error>
Homomorphic addition of two ciphertexts Read more
source§fn osub(&self, c1: &Ciphertext, c2: &Ciphertext) -> Result<Ciphertext, Error>
fn osub(&self, c1: &Ciphertext, c2: &Ciphertext) -> Result<Ciphertext, Error>
Homomorphic subtraction of two ciphertexts Read more
source§fn omul(
&self,
scalar: &Integer,
ciphertext: &Ciphertext
) -> Result<Ciphertext, Error>
fn omul( &self, scalar: &Integer, ciphertext: &Ciphertext ) -> Result<Ciphertext, Error>
Homomorphic multiplication of scalar at ciphertext Read more
source§fn oneg(&self, ciphertext: &Ciphertext) -> Result<Ciphertext, Error>
fn oneg(&self, ciphertext: &Ciphertext) -> Result<Ciphertext, Error>
Homomorphic negation of a ciphertext Read more
source§fn in_signed_group(&self, x: &Integer) -> bool
fn in_signed_group(&self, x: &Integer) -> bool
Checks whether
x
is {-N/2, .., N/2}
source§impl Clone for EncryptionKey
impl Clone for EncryptionKey
source§fn clone(&self) -> EncryptionKey
fn clone(&self) -> EncryptionKey
Returns a copy of the value. Read more
1.0.0 · 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 RefUnwindSafe for EncryptionKey
impl Send for EncryptionKey
impl Sync for EncryptionKey
impl Unpin for EncryptionKey
impl UnwindSafe for EncryptionKey
Blanket Implementations§
source§impl<E> AnyEncryptionKeyExt for Ewhere
E: AnyEncryptionKey,
impl<E> AnyEncryptionKeyExt for Ewhere
E: AnyEncryptionKey,
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.