Struct solana_zk_token_sdk::encryption::elgamal::ElGamalSecretKey
source · [−]pub struct ElGamalSecretKey(_);
Expand description
Secret key for the ElGamal encryption scheme.
Instances of ElGamal secret key are zeroized on drop.
Implementations
sourceimpl 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 Solana address.
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<u32>
pub fn decrypt_u32(&self, ciphertext: &ElGamalCiphertext) -> Option<u32>
Decrypts a ciphertext using the ElGamal secret key interpretting the message as type u32
.
sourcepub fn decrypt_u32_online(
&self,
ciphertext: &ElGamalCiphertext,
hashmap: &DecodeU32Precomputation
) -> Option<u32>
pub fn decrypt_u32_online(
&self,
ciphertext: &ElGamalCiphertext,
hashmap: &DecodeU32Precomputation
) -> Option<u32>
Decrypts a ciphertext using the ElGamal secret key and a pre-computed hashmap. It
interprets the decrypted message as type u32
.
pub fn as_bytes(&self) -> &[u8; 32]
pub fn to_bytes(&self) -> [u8; 32]
pub fn from_bytes(bytes: [u8; 32]) -> Option<ElGamalSecretKey>
Trait Implementations
sourceimpl Clone for ElGamalSecretKey
impl Clone for ElGamalSecretKey
sourcefn clone(&self) -> ElGamalSecretKey
fn clone(&self) -> ElGamalSecretKey
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl ConstantTimeEq for ElGamalSecretKey
impl ConstantTimeEq for ElGamalSecretKey
sourceimpl Debug for ElGamalSecretKey
impl Debug for ElGamalSecretKey
sourceimpl<'de> Deserialize<'de> for ElGamalSecretKey
impl<'de> Deserialize<'de> for ElGamalSecretKey
sourcefn 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
sourceimpl Drop for ElGamalSecretKey
impl Drop for ElGamalSecretKey
sourceimpl From<Scalar> for ElGamalSecretKey
impl From<Scalar> for ElGamalSecretKey
sourcefn from(scalar: Scalar) -> ElGamalSecretKey
fn from(scalar: Scalar) -> ElGamalSecretKey
Performs the conversion.
sourceimpl PartialEq<ElGamalSecretKey> for ElGamalSecretKey
impl PartialEq<ElGamalSecretKey> for ElGamalSecretKey
sourceimpl Serialize for ElGamalSecretKey
impl Serialize for ElGamalSecretKey
sourceimpl Zeroize for ElGamalSecretKey
impl Zeroize for ElGamalSecretKey
impl Eq for ElGamalSecretKey
Auto Trait Implementations
impl RefUnwindSafe for ElGamalSecretKey
impl Send for ElGamalSecretKey
impl Sync for ElGamalSecretKey
impl Unpin for ElGamalSecretKey
impl UnwindSafe for ElGamalSecretKey
Blanket Implementations
impl<T> AbiEnumVisitor for T where
T: Serialize + ?Sized,
impl<T> AbiEnumVisitor for T where
T: Serialize + ?Sized,
pub default fn visit_for_abi(
&self,
_digester: &mut AbiDigester
) -> Result<AbiDigester, DigestError>
impl<T> AbiEnumVisitor for T where
T: Serialize + AbiExample + ?Sized,
impl<T> AbiEnumVisitor for T where
T: Serialize + AbiExample + ?Sized,
pub default fn visit_for_abi(
&self,
digester: &mut AbiDigester
) -> Result<AbiDigester, DigestError>
impl<T> AbiExample for T
impl<T> AbiExample for T
pub default fn example() -> T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more