pub struct ElGamalCiphertext {
pub commitment: PedersenCommitment,
pub handle: DecryptHandle,
}
Expand description
Ciphertext for the ElGamal encryption scheme.
Fields§
§commitment: PedersenCommitment
§handle: DecryptHandle
Implementations§
source§impl ElGamalCiphertext
impl ElGamalCiphertext
pub fn add_amount<T: Into<Scalar>>(&self, amount: T) -> Self
pub fn subtract_amount<T: Into<Scalar>>(&self, amount: T) -> Self
pub fn to_bytes(&self) -> [u8; 64]
pub fn from_bytes(bytes: &[u8]) -> Option<ElGamalCiphertext>
sourcepub fn decrypt(&self, secret: &ElGamalSecretKey) -> DiscreteLog
pub fn decrypt(&self, secret: &ElGamalSecretKey) -> DiscreteLog
Decrypts the ciphertext using an ElGamal secret key.
The output of this function is of type DiscreteLog
. To recover, the originally encrypted
amount, use DiscreteLog::decode
.
sourcepub fn decrypt_u32(&self, secret: &ElGamalSecretKey) -> Option<u64>
pub fn decrypt_u32(&self, secret: &ElGamalSecretKey) -> Option<u64>
Decrypts the ciphertext using an ElGamal secret key assuming that the message is a positive 32-bit number.
If the originally encrypted amount is not a positive 32-bit number, then the function
returns None
.
Trait Implementations§
source§impl<'a, 'b> Add<&'b ElGamalCiphertext> for &'a ElGamalCiphertext
impl<'a, 'b> Add<&'b ElGamalCiphertext> for &'a ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
+
operator.source§fn add(self, ciphertext: &'b ElGamalCiphertext) -> ElGamalCiphertext
fn add(self, ciphertext: &'b ElGamalCiphertext) -> ElGamalCiphertext
Performs the
+
operation. Read moresource§impl<'b> Add<&'b ElGamalCiphertext> for ElGamalCiphertext
impl<'b> Add<&'b ElGamalCiphertext> for ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
+
operator.source§fn add(self, rhs: &'b ElGamalCiphertext) -> ElGamalCiphertext
fn add(self, rhs: &'b ElGamalCiphertext) -> ElGamalCiphertext
Performs the
+
operation. Read moresource§impl<'a> Add<ElGamalCiphertext> for &'a ElGamalCiphertext
impl<'a> Add<ElGamalCiphertext> for &'a ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
+
operator.source§fn add(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
fn add(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
Performs the
+
operation. Read moresource§impl Add for ElGamalCiphertext
impl Add for ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
+
operator.source§fn add(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
fn add(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
Performs the
+
operation. Read moresource§impl Clone for ElGamalCiphertext
impl Clone for ElGamalCiphertext
source§fn clone(&self) -> ElGamalCiphertext
fn clone(&self) -> ElGamalCiphertext
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 moresource§impl Debug for ElGamalCiphertext
impl Debug for ElGamalCiphertext
source§impl Default for ElGamalCiphertext
impl Default for ElGamalCiphertext
source§fn default() -> ElGamalCiphertext
fn default() -> ElGamalCiphertext
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for ElGamalCiphertext
impl<'de> Deserialize<'de> for ElGamalCiphertext
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for ElGamalCiphertext
impl Display for ElGamalCiphertext
source§impl From<ElGamalCiphertext> for ElGamalCiphertext
impl From<ElGamalCiphertext> for ElGamalCiphertext
source§fn from(decoded_ciphertext: ElGamalCiphertext) -> Self
fn from(decoded_ciphertext: ElGamalCiphertext) -> Self
Converts to this type from the input type.
source§impl<'a, 'b> Mul<&'b ElGamalCiphertext> for &'a Scalar
impl<'a, 'b> Mul<&'b ElGamalCiphertext> for &'a Scalar
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
*
operator.source§fn mul(self, ciphertext: &'b ElGamalCiphertext) -> ElGamalCiphertext
fn mul(self, ciphertext: &'b ElGamalCiphertext) -> ElGamalCiphertext
Performs the
*
operation. Read moresource§impl<'b> Mul<&'b ElGamalCiphertext> for Scalar
impl<'b> Mul<&'b ElGamalCiphertext> for Scalar
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
*
operator.source§fn mul(self, rhs: &'b ElGamalCiphertext) -> ElGamalCiphertext
fn mul(self, rhs: &'b ElGamalCiphertext) -> ElGamalCiphertext
Performs the
*
operation. Read moresource§impl<'a, 'b> Mul<&'b Scalar> for &'a ElGamalCiphertext
impl<'a, 'b> Mul<&'b Scalar> for &'a ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
*
operator.source§impl<'b> Mul<&'b Scalar> for ElGamalCiphertext
impl<'b> Mul<&'b Scalar> for ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
*
operator.source§impl<'a> Mul<ElGamalCiphertext> for &'a Scalar
impl<'a> Mul<ElGamalCiphertext> for &'a Scalar
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
*
operator.source§fn mul(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
fn mul(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
Performs the
*
operation. Read moresource§impl Mul<ElGamalCiphertext> for Scalar
impl Mul<ElGamalCiphertext> for Scalar
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
*
operator.source§fn mul(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
fn mul(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
Performs the
*
operation. Read moresource§impl<'a> Mul<Scalar> for &'a ElGamalCiphertext
impl<'a> Mul<Scalar> for &'a ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
*
operator.source§impl Mul<Scalar> for ElGamalCiphertext
impl Mul<Scalar> for ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
*
operator.source§impl PartialEq for ElGamalCiphertext
impl PartialEq for ElGamalCiphertext
source§impl Serialize for ElGamalCiphertext
impl Serialize for ElGamalCiphertext
source§impl<'a, 'b> Sub<&'b ElGamalCiphertext> for &'a ElGamalCiphertext
impl<'a, 'b> Sub<&'b ElGamalCiphertext> for &'a ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
-
operator.source§fn sub(self, ciphertext: &'b ElGamalCiphertext) -> ElGamalCiphertext
fn sub(self, ciphertext: &'b ElGamalCiphertext) -> ElGamalCiphertext
Performs the
-
operation. Read moresource§impl<'b> Sub<&'b ElGamalCiphertext> for ElGamalCiphertext
impl<'b> Sub<&'b ElGamalCiphertext> for ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
-
operator.source§fn sub(self, rhs: &'b ElGamalCiphertext) -> ElGamalCiphertext
fn sub(self, rhs: &'b ElGamalCiphertext) -> ElGamalCiphertext
Performs the
-
operation. Read moresource§impl<'a> Sub<ElGamalCiphertext> for &'a ElGamalCiphertext
impl<'a> Sub<ElGamalCiphertext> for &'a ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
-
operator.source§fn sub(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
fn sub(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
Performs the
-
operation. Read moresource§impl Sub for ElGamalCiphertext
impl Sub for ElGamalCiphertext
source§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
-
operator.source§fn sub(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
fn sub(self, rhs: ElGamalCiphertext) -> ElGamalCiphertext
Performs the
-
operation. Read moresource§impl TryFrom<ElGamalCiphertext> for ElGamalCiphertext
impl TryFrom<ElGamalCiphertext> for ElGamalCiphertext
source§type Error = ElGamalError
type Error = ElGamalError
The type returned in the event of a conversion error.
impl Copy for ElGamalCiphertext
impl Eq for ElGamalCiphertext
impl StructuralPartialEq for ElGamalCiphertext
Auto Trait Implementations§
impl Freeze for ElGamalCiphertext
impl RefUnwindSafe for ElGamalCiphertext
impl Send for ElGamalCiphertext
impl Sync for ElGamalCiphertext
impl Unpin for ElGamalCiphertext
impl UnwindSafe for ElGamalCiphertext
Blanket Implementations§
source§impl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, _digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
source§impl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more