Skip to content

Commit

Permalink
Move MEMO_SIZE constant to orchard from zcash_note_encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Demin committed Aug 13, 2024
1 parent 20a7214 commit 6968ade
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/bundle/commitments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 2 additions & 0 deletions src/note_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 2 additions & 2 deletions src/note_encryption/compact_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<D: OrchardDomainCommon> CompactAction<D> {
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,
Expand All @@ -124,7 +124,7 @@ pub mod testing {
value::NoteValue,
};

use super::{CompactAction, OrchardDomain, OrchardDomainCommon};
use super::{CompactAction, OrchardDomain, OrchardDomainCommon, MEMO_SIZE};

/// Creates a fake `CompactAction` paying the given recipient the specified value.
///
Expand Down
5 changes: 4 additions & 1 deletion src/note_encryption/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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].
Expand Down
7 changes: 5 additions & 2 deletions src/note_encryption/orchard_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@

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,
note::{AssetBase, Rho},
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 {
Expand Down

0 comments on commit 6968ade

Please sign in to comment.