Skip to content

Commit

Permalink
Remove the network-specific 0xf6 convention for empty memos
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom committed Dec 13, 2023
1 parent bd8f55d commit a6ca7ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 5 additions & 14 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub struct SaplingOutputInfo {
/// `None` represents the `ovk = ⊥` case.
ovk: Option<OutgoingViewingKey>,
note: Note,
memo: Option<[u8; 512]>,
memo: [u8; 512],
rcv: ValueCommitTrapdoor,
}

Expand All @@ -165,7 +165,7 @@ impl SaplingOutputInfo {
None,
dummy_to,
NoteValue::from_raw(0),
None,
[0u8; 512],
zip212_enforcement,
)
}
Expand All @@ -175,7 +175,7 @@ impl SaplingOutputInfo {
ovk: Option<OutgoingViewingKey>,
to: PaymentAddress,
value: NoteValue,
memo: Option<[u8; 512]>,
memo: [u8; 512],
zip212_enforcement: Zip212Enforcement,
) -> Self {
let rseed = generate_random_rseed_internal(zip212_enforcement, rng);
Expand All @@ -194,16 +194,7 @@ impl SaplingOutputInfo {
self,
rng: &mut R,
) -> OutputDescription<circuit::Output> {
let encryptor = sapling_note_encryption::<R>(
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::<R>(self.ovk, self.note.clone(), self.memo, rng);

// Construct the value commitment.
let cv = ValueCommitment::derive(self.note.value(), self.rcv.clone());
Expand Down Expand Up @@ -381,7 +372,7 @@ impl SaplingBuilder {
ovk: Option<OutgoingViewingKey>,
to: PaymentAddress,
value: NoteValue,
memo: Option<[u8; 512]>,
memo: [u8; 512],
) -> Result<(), Error> {
let output = SaplingOutputInfo::new_internal(
&mut rng,
Expand Down

0 comments on commit a6ca7ef

Please sign in to comment.