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>
impl<D: Domain> NoteEncryption<D>
Sourcepub fn new(
ovk: Option<D::OutgoingViewingKey>,
note: D::Note,
memo: D::Memo,
) -> Self
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.
Sourcepub 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.
pub fn new_with_esk( esk: D::EphemeralSecretKey, ovk: Option<D::OutgoingViewingKey>, note: D::Note, memo: D::Memo, ) -> Self
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.
Sourcepub fn esk(&self) -> &D::EphemeralSecretKey
pub fn esk(&self) -> &D::EphemeralSecretKey
Exposes the ephemeral secret key being used to encrypt this note.
Sourcepub fn epk(&self) -> &D::EphemeralPublicKey
pub fn epk(&self) -> &D::EphemeralPublicKey
Exposes the encoding of the ephemeral public key being used to encrypt this note.
Sourcepub fn encrypt_note_plaintext(&self) -> [u8; 580]
pub fn encrypt_note_plaintext(&self) -> [u8; 580]
Generates encCiphertext for this note.
Sourcepub fn encrypt_outgoing_plaintext<R: RngCore>(
&self,
cv: &D::ValueCommitment,
cmstar: &D::ExtractedCommitment,
rng: &mut R,
) -> [u8; 80]
pub fn encrypt_outgoing_plaintext<R: RngCore>( &self, cv: &D::ValueCommitment, cmstar: &D::ExtractedCommitment, rng: &mut R, ) -> [u8; 80]
Generates outCiphertext for this note.