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 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>,
source§impl EncodableKey for ElGamalSecretKey
impl EncodableKey for ElGamalSecretKey
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<Scalar> for ElGamalSecretKey
impl From<Scalar> for ElGamalSecretKey
source§fn from(scalar: Scalar) -> ElGamalSecretKey
fn from(scalar: Scalar) -> ElGamalSecretKey
source§impl PartialEq for ElGamalSecretKey
impl PartialEq for ElGamalSecretKey
source§impl SeedDerivable for ElGamalSecretKey
impl SeedDerivable for ElGamalSecretKey
fn from_seed(seed: &[u8]) -> Result<Self, Box<dyn Error>>
fn from_seed_and_derivation_path( _seed: &[u8], _derivation_path: Option<DerivationPath>, ) -> Result<Self, Box<dyn Error>>
fn from_seed_phrase_and_passphrase( seed_phrase: &str, passphrase: &str, ) -> Result<Self, Box<dyn Error>>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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>
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>
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