Struct solana_zk_token_sdk::encryption::elgamal::ElGamalSecretKey
source · 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_from_signer(
signer: &dyn Signer,
public_seed: &[u8]
) -> Result<Self, Box<dyn Error>>
pub fn new_from_signer( signer: &dyn Signer, public_seed: &[u8] ) -> Result<Self, Box<dyn Error>>
Deterministically derives an ElGamal secret key from a Solana signer and a public seed.
See ElGamalKeypair::new_from_signer
for more context on the key derivation.
sourcepub fn seed_from_signer(
signer: &dyn Signer,
public_seed: &[u8]
) -> Result<Vec<u8>, SignerError>
pub fn seed_from_signer( signer: &dyn Signer, public_seed: &[u8] ) -> Result<Vec<u8>, SignerError>
Derive a seed from a Solana signer used to generate an ElGamal secret key.
The seed is derived as the hash of the signature of a public seed.
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
.
sourcepub fn from_seed(seed: &[u8]) -> Result<Self, ElGamalError>
pub fn from_seed(seed: &[u8]) -> Result<Self, ElGamalError>
Derive an ElGamal secret key from an entropy seed.
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
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more