NoteEncryption

Struct NoteEncryption 

Source
pub struct NoteEncryption<D: Domain> { /* private fields */ }
Expand description

A struct containing context required for encrypting Sapling and Orchard notes.

This struct provides a safe API for encrypting Sapling and Orchard notes. In particular, it enforces that fresh ephemeral keys are used for every note, and that the ciphertexts are consistent with each other.

Implements section 4.19 of the Zcash Protocol Specification

Implementations§

Source§

impl<D: Domain> NoteEncryption<D>

Source

pub fn new( ovk: Option<D::OutgoingViewingKey>, note: D::Note, memo: D::Memo, ) -> Self

Construct a new note encryption context for the specified note, recipient, and memo.

Source

pub fn new_with_esk( esk: D::EphemeralSecretKey, ovk: Option<D::OutgoingViewingKey>, note: D::Note, memo: D::Memo, ) -> Self

Available on crate feature pre-zip-212 only.

For use only with Sapling. This method is preserved in order that test code be able to generate pre-ZIP-212 ciphertexts so that tests can continue to cover pre-ZIP-212 transaction decryption.

Source

pub fn esk(&self) -> &D::EphemeralSecretKey

Exposes the ephemeral secret key being used to encrypt this note.

Source

pub fn epk(&self) -> &D::EphemeralPublicKey

Exposes the encoding of the ephemeral public key being used to encrypt this note.

Source

pub fn encrypt_note_plaintext(&self) -> [u8; 580]

Generates encCiphertext for this note.

Source

pub fn encrypt_outgoing_plaintext<R: RngCore>( &self, cv: &D::ValueCommitment, cmstar: &D::ExtractedCommitment, rng: &mut R, ) -> [u8; 80]

Generates outCiphertext for this note.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.