From a6ca7ef374c28b88f680467f5748e0658deb18ba Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Wed, 13 Dec 2023 11:34:44 -0700 Subject: [PATCH] Remove the network-specific 0xf6 convention for empty memos --- CHANGELOG.md | 3 +-- src/builder.rs | 19 +++++-------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e4d611..984d3ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,8 +95,7 @@ The entries below are relative to the `zcash_primitives::sapling` module as of - `SaplingBuilder::add_spend` now takes `extsk` by reference. Also, it no longer takes a `diversifier` argument as the diversifier may be obtained from the note. - - `SaplingBuilder::add_output` now takes an `Option<[u8; 512]>` memo instead - of a `MemoBytes`. + - `SaplingBuilder::add_output` now takes `[u8; 512]` instead of `MemoBytes`. - `SaplingBuilder::build` no longer takes a prover, proving context, progress notifier, or target height. Instead, it has `SpendProver, OutputProver` generic parameters and returns `(UnauthorizedBundle, SaplingMetadata)`. The diff --git a/src/builder.rs b/src/builder.rs index ff209fe..42328e8 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -142,7 +142,7 @@ pub struct SaplingOutputInfo { /// `None` represents the `ovk = ⊥` case. ovk: Option, note: Note, - memo: Option<[u8; 512]>, + memo: [u8; 512], rcv: ValueCommitTrapdoor, } @@ -165,7 +165,7 @@ impl SaplingOutputInfo { None, dummy_to, NoteValue::from_raw(0), - None, + [0u8; 512], zip212_enforcement, ) } @@ -175,7 +175,7 @@ impl SaplingOutputInfo { ovk: Option, to: PaymentAddress, value: NoteValue, - memo: Option<[u8; 512]>, + memo: [u8; 512], zip212_enforcement: Zip212Enforcement, ) -> Self { let rseed = generate_random_rseed_internal(zip212_enforcement, rng); @@ -194,16 +194,7 @@ impl SaplingOutputInfo { self, rng: &mut R, ) -> OutputDescription { - let encryptor = sapling_note_encryption::( - self.ovk, - self.note.clone(), - self.memo.unwrap_or_else(|| { - let mut memo = [0; 512]; - memo[0] = 0xf6; - memo - }), - rng, - ); + let encryptor = sapling_note_encryption::(self.ovk, self.note.clone(), self.memo, rng); // Construct the value commitment. let cv = ValueCommitment::derive(self.note.value(), self.rcv.clone()); @@ -381,7 +372,7 @@ impl SaplingBuilder { ovk: Option, to: PaymentAddress, value: NoteValue, - memo: Option<[u8; 512]>, + memo: [u8; 512], ) -> Result<(), Error> { let output = SaplingOutputInfo::new_internal( &mut rng,