diff --git a/Cargo.lock b/Cargo.lock index 9b6afc650..ed3c2f7ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2552,7 +2552,7 @@ dependencies = [ [[package]] name = "zcash_note_encryption" version = "0.4.0" -source = "git+https://github.com/QED-it/zcash_note_encryption?branch=zsa1#58384553aab76b2ee6d6eb328cf2187fa824ec9a" +source = "git+https://github.com/QED-it/zcash_note_encryption?branch=zsa1#76745f00551d4442dee11ad64a8400b75132d18f" dependencies = [ "chacha20", "chacha20poly1305", diff --git a/src/bundle/commitments.rs b/src/bundle/commitments.rs index 953c9d474..1572987bd 100644 --- a/src/bundle/commitments.rs +++ b/src/bundle/commitments.rs @@ -2,13 +2,11 @@ use blake2b_simd::{Hash as Blake2bHash, Params, State}; -use zcash_note_encryption_zsa::MEMO_SIZE; - use crate::{ bundle::{Authorization, Authorized, Bundle}, issuance::{IssueAuth, IssueBundle, Signed}, note::AssetBase, - note_encryption::OrchardDomainCommon, + note_encryption::{OrchardDomainCommon, MEMO_SIZE}, orchard_flavor::{OrchardVanilla, OrchardZSA}, value::NoteValue, }; diff --git a/src/note_encryption.rs b/src/note_encryption.rs index 8f2607e89..26d293209 100644 --- a/src/note_encryption.rs +++ b/src/note_encryption.rs @@ -11,6 +11,8 @@ mod orchard_domain; mod orchard_domain_vanilla; mod orchard_domain_zsa; +pub(crate) use domain::MEMO_SIZE; + pub use { compact_action::CompactAction, orchard_domain::{OrchardDomain, OrchardDomainCommon}, diff --git a/src/note_encryption/compact_action.rs b/src/note_encryption/compact_action.rs index d7494d1c8..8ed04d983 100644 --- a/src/note_encryption/compact_action.rs +++ b/src/note_encryption/compact_action.rs @@ -20,8 +20,8 @@ impl ShieldedOutput> for Action Option { - Some(self.encrypted_note().enc_ciphertext) + fn enc_ciphertext(&self) -> Option<&D::NoteCiphertextBytes> { + Some(&self.encrypted_note().enc_ciphertext) } fn enc_ciphertext_compact(&self) -> D::CompactNoteCiphertextBytes { @@ -69,7 +69,7 @@ impl ShieldedOutput> for CompactAction< self.cmx.to_bytes() } - fn enc_ciphertext(&self) -> Option { + fn enc_ciphertext(&self) -> Option<&D::NoteCiphertextBytes> { None } @@ -115,12 +115,13 @@ impl CompactAction { pub mod testing { use rand::RngCore; - use zcash_note_encryption_zsa::{note_bytes::NoteBytes, Domain, NoteEncryption, MEMO_SIZE}; + use zcash_note_encryption_zsa::{note_bytes::NoteBytes, Domain, NoteEncryption}; use crate::{ address::Address, keys::OutgoingViewingKey, note::{AssetBase, ExtractedNoteCommitment, Note, Nullifier, RandomSeed, Rho}, + note_encryption::MEMO_SIZE, value::NoteValue, }; diff --git a/src/note_encryption/domain.rs b/src/note_encryption/domain.rs index ec6dc8ad3..91d4ba4f2 100644 --- a/src/note_encryption/domain.rs +++ b/src/note_encryption/domain.rs @@ -8,7 +8,7 @@ use blake2b_simd::Params; use zcash_note_encryption_zsa::{ note_bytes::NoteBytes, BatchDomain, Domain, EphemeralKeyBytes, OutPlaintextBytes, - OutgoingCipherKey, MEMO_SIZE, OUT_PLAINTEXT_SIZE, + OutgoingCipherKey, OUT_PLAINTEXT_SIZE, }; use crate::{ @@ -51,6 +51,9 @@ pub(super) const NOTE_VERSION_BYTE_V2: u8 = 0x02; /// The version byte for ZSA. pub(super) const NOTE_VERSION_BYTE_V3: u8 = 0x03; +/// The size of the memo. +pub(crate) const MEMO_SIZE: usize = 512; + pub(super) type Memo = [u8; MEMO_SIZE]; /// Defined in [Zcash Protocol Spec ยง 5.4.2: Pseudo Random Functions][concreteprfs]. diff --git a/src/note_encryption/orchard_domain.rs b/src/note_encryption/orchard_domain.rs index 7ee11530a..e56f15cd1 100644 --- a/src/note_encryption/orchard_domain.rs +++ b/src/note_encryption/orchard_domain.rs @@ -3,7 +3,7 @@ use core::fmt; -use zcash_note_encryption_zsa::{note_bytes::NoteBytes, AEAD_TAG_SIZE, MEMO_SIZE}; +use zcash_note_encryption_zsa::{note_bytes::NoteBytes, AEAD_TAG_SIZE}; use crate::{ action::Action, @@ -11,7 +11,10 @@ use crate::{ Note, }; -use super::{compact_action::CompactAction, domain::Memo}; +use super::{ + compact_action::CompactAction, + domain::{Memo, MEMO_SIZE}, +}; /// Represents the Orchard protocol domain specifics required for note encryption and decryption. pub trait OrchardDomainCommon: fmt::Debug + Clone {