Struct safe_zk_token_sdk::encryption::elgamal::ElGamalCiphertext
source · 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
§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
§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
§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<ElGamalCiphertext> for ElGamalCiphertext
impl Add<ElGamalCiphertext> for ElGamalCiphertext
§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(ct: ElGamalCiphertext) -> Self
fn from(ct: 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
§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
§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
§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
§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
§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
§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
§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
*
operator.source§impl Mul<Scalar> for ElGamalCiphertext
impl Mul<Scalar> for ElGamalCiphertext
§type Output = ElGamalCiphertext
type Output = ElGamalCiphertext
The resulting type after applying the
*
operator.source§impl PartialEq<ElGamalCiphertext> for ElGamalCiphertext
impl PartialEq<ElGamalCiphertext> for ElGamalCiphertext
source§fn eq(&self, other: &ElGamalCiphertext) -> bool
fn eq(&self, other: &ElGamalCiphertext) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.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
§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
§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
§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<ElGamalCiphertext> for ElGamalCiphertext
impl Sub<ElGamalCiphertext> for ElGamalCiphertext
§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
§type Error = ProofError
type Error = ProofError
The type returned in the event of a conversion error.