pub struct ElGamalPubkey(/* private fields */);
Expand description
Public key for the ElGamal encryption scheme.
Implementations§
Source§impl ElGamalPubkey
impl ElGamalPubkey
Sourcepub fn new(secret: &ElGamalSecretKey) -> Self
pub fn new(secret: &ElGamalSecretKey) -> Self
Derives the ElGamalPubkey
that uniquely corresponds to an ElGamalSecretKey
.
pub fn get_point(&self) -> &RistrettoPoint
pub fn to_bytes(&self) -> [u8; 32]
👎Deprecated since 2.0.0: please use
into()
insteadpub fn from_bytes(bytes: &[u8]) -> Option<ElGamalPubkey>
👎Deprecated since 2.0.0: please use
try_from()
insteadSourcepub fn encrypt<T: Into<Scalar>>(&self, amount: T) -> ElGamalCiphertext
pub fn encrypt<T: Into<Scalar>>(&self, amount: T) -> ElGamalCiphertext
Encrypts an amount under the public key.
This function is randomized. It internally samples a scalar element using OsRng
.
Sourcepub fn encrypt_with<T: Into<Scalar>>(
&self,
amount: T,
opening: &PedersenOpening,
) -> ElGamalCiphertext
pub fn encrypt_with<T: Into<Scalar>>( &self, amount: T, opening: &PedersenOpening, ) -> ElGamalCiphertext
Encrypts an amount under the public key and an input Pedersen opening.
Sourcepub fn decrypt_handle(self, opening: &PedersenOpening) -> DecryptHandle
pub fn decrypt_handle(self, opening: &PedersenOpening) -> DecryptHandle
Generates a decryption handle for an ElGamal public key under a Pedersen opening.
Trait Implementations§
Source§impl Clone for ElGamalPubkey
impl Clone for ElGamalPubkey
Source§fn clone(&self) -> ElGamalPubkey
fn clone(&self) -> ElGamalPubkey
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 ElGamalPubkey
impl Debug for ElGamalPubkey
Source§impl Default for ElGamalPubkey
impl Default for ElGamalPubkey
Source§fn default() -> ElGamalPubkey
fn default() -> ElGamalPubkey
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ElGamalPubkey
impl<'de> Deserialize<'de> for ElGamalPubkey
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 ElGamalPubkey
impl Display for ElGamalPubkey
Source§impl EncodableKey for ElGamalPubkey
impl EncodableKey for ElGamalPubkey
fn read<R: Read>(reader: &mut R) -> Result<Self, Box<dyn Error>>
fn write<W: Write>(&self, writer: &mut W) -> Result<String, Box<dyn Error>>
fn read_from_file<F>(path: F) -> Result<Self, Box<dyn Error>>
fn write_to_file<F>(&self, outfile: F) -> Result<String, Box<dyn Error>>
Source§impl From<&ElGamalPubkey> for [u8; 32]
impl From<&ElGamalPubkey> for [u8; 32]
Source§fn from(pubkey: &ElGamalPubkey) -> Self
fn from(pubkey: &ElGamalPubkey) -> Self
Converts to this type from the input type.
Source§impl From<ElGamalPubkey> for [u8; 32]
impl From<ElGamalPubkey> for [u8; 32]
Source§fn from(pubkey: ElGamalPubkey) -> Self
fn from(pubkey: ElGamalPubkey) -> Self
Converts to this type from the input type.
Source§impl From<ElGamalPubkey> for ElGamalPubkey
impl From<ElGamalPubkey> for ElGamalPubkey
Source§fn from(decoded_pubkey: ElGamalPubkey) -> Self
fn from(decoded_pubkey: ElGamalPubkey) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ElGamalPubkey
impl PartialEq for ElGamalPubkey
Source§impl Serialize for ElGamalPubkey
impl Serialize for ElGamalPubkey
Source§impl TryFrom<&[u8]> for ElGamalPubkey
impl TryFrom<&[u8]> for ElGamalPubkey
Source§impl TryFrom<ElGamalPubkey> for ElGamalPubkey
impl TryFrom<ElGamalPubkey> for ElGamalPubkey
Source§type Error = ElGamalError
type Error = ElGamalError
The type returned in the event of a conversion error.
Source§impl Zeroize for ElGamalPubkey
impl Zeroize for ElGamalPubkey
impl Copy for ElGamalPubkey
impl Eq for ElGamalPubkey
impl StructuralPartialEq for ElGamalPubkey
Auto Trait Implementations§
impl Freeze for ElGamalPubkey
impl RefUnwindSafe for ElGamalPubkey
impl Send for ElGamalPubkey
impl Sync for ElGamalPubkey
impl Unpin for ElGamalPubkey
impl UnwindSafe for ElGamalPubkey
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