pub struct AeKey(/* private fields */);
Implementations§
Source§impl AeKey
impl AeKey
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 authenticated encryption key from a Solana signer and a public seed.
This function exists for applications where a user may not wish to maintain a Solana signer and an authenticated encryption key separately. Instead, a user can derive the ElGamal keypair on-the-fly whenever encrytion/decryption is needed.
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 authenticated encryption 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
Generates a random authenticated encryption key.
This function is randomized. It internally samples a scalar element using OsRng
.
Sourcepub fn encrypt(&self, amount: u64) -> AeCiphertext
pub fn encrypt(&self, amount: u64) -> AeCiphertext
Encrypts an amount under the authenticated encryption key.
pub fn decrypt(&self, ciphertext: &AeCiphertext) -> Option<u64>
Trait Implementations§
Source§impl EncodableKey for AeKey
impl EncodableKey for AeKey
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 SeedDerivable for AeKey
impl SeedDerivable for AeKey
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>>
impl Eq for AeKey
impl StructuralPartialEq for AeKey
Auto Trait Implementations§
impl Freeze for AeKey
impl RefUnwindSafe for AeKey
impl Send for AeKey
impl Sync for AeKey
impl Unpin for AeKey
impl UnwindSafe for AeKey
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<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