pub struct ElGamalSecretKey(/* private fields */);
Expand description
Secret key for the ElGamal encryption scheme.
Instances of ElGamal secret key are zeroized on drop.
Implementations§
Source§impl ElGamalSecretKey
impl ElGamalSecretKey
Sourcepub fn new(signer: &dyn Signer, address: &Pubkey) -> Result<Self, SignerError>
pub fn new(signer: &dyn Signer, address: &Pubkey) -> Result<Self, SignerError>
Deterministically derives an ElGamal keypair from an Ed25519 signing key and a Safecoin address.
See ElGamalKeypair::new
for more context on the key derivation.
Sourcepub fn new_rand() -> Self
pub fn new_rand() -> Self
Randomly samples an ElGamal secret key.
This function is randomized. It internally samples a scalar element using OsRng
.
pub fn get_scalar(&self) -> &Scalar
Sourcepub fn decrypt(&self, ciphertext: &ElGamalCiphertext) -> DiscreteLog
pub fn decrypt(&self, ciphertext: &ElGamalCiphertext) -> DiscreteLog
Decrypts a ciphertext using the ElGamal secret key.
The output of this function is of type DiscreteLog
. To recover, the originally encrypted
message, use DiscreteLog::decode
.
Sourcepub fn decrypt_u32(&self, ciphertext: &ElGamalCiphertext) -> Option<u64>
pub fn decrypt_u32(&self, ciphertext: &ElGamalCiphertext) -> Option<u64>
Decrypts a ciphertext using the ElGamal secret key interpretting the message as type u32
.
pub fn as_bytes(&self) -> &[u8; 32]
pub fn to_bytes(&self) -> [u8; 32]
pub fn from_bytes(bytes: &[u8]) -> Option<ElGamalSecretKey>
Trait Implementations§
Source§impl Clone for ElGamalSecretKey
impl Clone for ElGamalSecretKey
Source§fn clone(&self) -> ElGamalSecretKey
fn clone(&self) -> ElGamalSecretKey
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 ConstantTimeEq for ElGamalSecretKey
impl ConstantTimeEq for ElGamalSecretKey
Source§impl Debug for ElGamalSecretKey
impl Debug for ElGamalSecretKey
Source§impl<'de> Deserialize<'de> for ElGamalSecretKey
impl<'de> Deserialize<'de> for ElGamalSecretKey
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 From<Scalar> for ElGamalSecretKey
impl From<Scalar> for ElGamalSecretKey
Source§fn from(scalar: Scalar) -> ElGamalSecretKey
fn from(scalar: Scalar) -> ElGamalSecretKey
Converts to this type from the input type.
Source§impl PartialEq for ElGamalSecretKey
impl PartialEq for ElGamalSecretKey
Source§impl Serialize for ElGamalSecretKey
impl Serialize for ElGamalSecretKey
Source§impl Zeroize for ElGamalSecretKey
impl Zeroize for ElGamalSecretKey
impl Eq for ElGamalSecretKey
Auto Trait Implementations§
impl Freeze for ElGamalSecretKey
impl RefUnwindSafe for ElGamalSecretKey
impl Send for ElGamalSecretKey
impl Sync for ElGamalSecretKey
impl Unpin for ElGamalSecretKey
impl UnwindSafe for ElGamalSecretKey
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§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