pub struct GroupedElGamalCiphertext<const N: usize> {
pub commitment: PedersenCommitment,
pub handles: [DecryptHandle; N],
}
Expand description
A grouped ElGamal ciphertext.
The type is defined with a generic constant parameter that specifies the number of decryption handles that the ciphertext holds.
Fields§
§commitment: PedersenCommitment
§handles: [DecryptHandle; N]
Implementations§
Source§impl<const N: usize> GroupedElGamalCiphertext<N>
impl<const N: usize> GroupedElGamalCiphertext<N>
Sourcepub fn decrypt(
&self,
secret: &ElGamalSecretKey,
index: usize,
) -> Result<DiscreteLog, GroupedElGamalError>
pub fn decrypt( &self, secret: &ElGamalSecretKey, index: usize, ) -> Result<DiscreteLog, GroupedElGamalError>
Decrypts the grouped ElGamal ciphertext using an ElGamal secret key pertaining to a specified index.
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,
index: usize,
) -> Result<Option<u64>, GroupedElGamalError>
pub fn decrypt_u32( &self, secret: &ElGamalSecretKey, index: usize, ) -> Result<Option<u64>, GroupedElGamalError>
Decrypts the grouped ElGamal ciphertext to a number that is interpreted as a positive 32-bit
number (but still of type u64
).
If the originally encrypted amount is not a positive 32-bit number, then the function
returns None
.
pub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn from_bytes(bytes: &[u8]) -> Option<Self>
Trait Implementations§
Source§impl<const N: usize> Clone for GroupedElGamalCiphertext<N>
impl<const N: usize> Clone for GroupedElGamalCiphertext<N>
Source§fn clone(&self) -> GroupedElGamalCiphertext<N>
fn clone(&self) -> GroupedElGamalCiphertext<N>
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<const N: usize> Debug for GroupedElGamalCiphertext<N>
impl<const N: usize> Debug for GroupedElGamalCiphertext<N>
Source§impl From<GroupedElGamalCiphertext<2>> for GroupedElGamalCiphertext2Handles
impl From<GroupedElGamalCiphertext<2>> for GroupedElGamalCiphertext2Handles
Source§fn from(decoded_ciphertext: GroupedElGamalCiphertext<2>) -> Self
fn from(decoded_ciphertext: GroupedElGamalCiphertext<2>) -> Self
Converts to this type from the input type.
Source§impl From<GroupedElGamalCiphertext<3>> for GroupedElGamalCiphertext3Handles
impl From<GroupedElGamalCiphertext<3>> for GroupedElGamalCiphertext3Handles
Source§fn from(decoded_ciphertext: GroupedElGamalCiphertext<3>) -> Self
fn from(decoded_ciphertext: GroupedElGamalCiphertext<3>) -> Self
Converts to this type from the input type.
Source§impl<const N: usize> PartialEq for GroupedElGamalCiphertext<N>
impl<const N: usize> PartialEq for GroupedElGamalCiphertext<N>
Source§impl TryFrom<GroupedElGamalCiphertext2Handles> for GroupedElGamalCiphertext<2>
impl TryFrom<GroupedElGamalCiphertext2Handles> for GroupedElGamalCiphertext<2>
Source§type Error = ElGamalError
type Error = ElGamalError
The type returned in the event of a conversion error.
Source§impl TryFrom<GroupedElGamalCiphertext3Handles> for GroupedElGamalCiphertext<3>
impl TryFrom<GroupedElGamalCiphertext3Handles> for GroupedElGamalCiphertext<3>
Source§type Error = ElGamalError
type Error = ElGamalError
The type returned in the event of a conversion error.
impl<const N: usize> Copy for GroupedElGamalCiphertext<N>
impl<const N: usize> Eq for GroupedElGamalCiphertext<N>
impl<const N: usize> StructuralPartialEq for GroupedElGamalCiphertext<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for GroupedElGamalCiphertext<N>
impl<const N: usize> RefUnwindSafe for GroupedElGamalCiphertext<N>
impl<const N: usize> Send for GroupedElGamalCiphertext<N>
impl<const N: usize> Sync for GroupedElGamalCiphertext<N>
impl<const N: usize> Unpin for GroupedElGamalCiphertext<N>
impl<const N: usize> UnwindSafe for GroupedElGamalCiphertext<N>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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