Skip to content

Commit

Permalink
Merge pull request #441 from nuttycom/remove_f6_memos
Browse files Browse the repository at this point in the history
Remove 0xf6 empty memo convention.
  • Loading branch information
nuttycom authored Feb 21, 2025
2 parents 319d0de + 4500bdf commit efa62fc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and this project adheres to Rust's notion of
- MSRV is now 1.70
- Migrated to `nonempty 0.11`, `incrementalmerkletree 0.8`, `shardtree 0.6`,
`zcash_spec 0.2`, `zip32 0.2`
- `orchard::builder::Builder::add_output` now takes a `[u8; 512]` for its
`memo` argument instead of an optional value.

## [0.10.1] - 2024-12-16

Expand Down
2 changes: 1 addition & 1 deletion benches/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn criterion_benchmark(c: &mut Criterion) {
let mut builder = Builder::new(BundleType::DEFAULT, Anchor::from_bytes([0; 32]).unwrap());
for _ in 0..num_recipients {
builder
.add_output(None, recipient, NoteValue::from_raw(10), None)
.add_output(None, recipient, NoteValue::from_raw(10), [0; 512])
.unwrap();
}
let bundle: Bundle<_, i64> = builder.build(rng).unwrap().unwrap().0;
Expand Down
4 changes: 2 additions & 2 deletions benches/note_decryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ fn bench_note_decryption(c: &mut Criterion) {
// The builder pads to two actions, and shuffles their order. Add two recipients
// so the first action is always decryptable.
builder
.add_output(None, recipient, NoteValue::from_raw(10), None)
.add_output(None, recipient, NoteValue::from_raw(10), [0; 512])
.unwrap();
builder
.add_output(None, recipient, NoteValue::from_raw(10), None)
.add_output(None, recipient, NoteValue::from_raw(10), [0; 512])
.unwrap();
let bundle: Bundle<_, i64> = builder.build(rng).unwrap().unwrap().0;
bundle
Expand Down
16 changes: 6 additions & 10 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,17 +334,13 @@ impl OutputInfo {
ovk: Option<OutgoingViewingKey>,
recipient: Address,
value: NoteValue,
memo: Option<[u8; 512]>,
memo: [u8; 512],
) -> Self {
Self {
ovk,
recipient,
value,
memo: memo.unwrap_or_else(|| {
let mut memo = [0; 512];
memo[0] = 0xf6;
memo
}),
memo,
}
}

Expand All @@ -355,7 +351,7 @@ impl OutputInfo {
let fvk: FullViewingKey = (&SpendingKey::random(rng)).into();
let recipient = fvk.address_at(0u32, Scope::External);

Self::new(None, recipient, NoteValue::zero(), None)
Self::new(None, recipient, NoteValue::zero(), [0u8; 512])
}

/// Builds the output half of an action.
Expand Down Expand Up @@ -594,7 +590,7 @@ impl Builder {
ovk: Option<OutgoingViewingKey>,
recipient: Address,
value: NoteValue,
memo: Option<[u8; 512]>,
memo: [u8; 512],
) -> Result<(), OutputError> {
let flags = self.bundle_type.flags();
if !flags.outputs_enabled() {
Expand Down Expand Up @@ -1192,7 +1188,7 @@ pub mod testing {
let ovk = fvk.to_ovk(scope);

builder
.add_output(Some(ovk.clone()), addr, value, None)
.add_output(Some(ovk.clone()), addr, value, [0u8; 512])
.unwrap();
}

Expand Down Expand Up @@ -1305,7 +1301,7 @@ mod tests {
);

builder
.add_output(None, recipient, NoteValue::from_raw(5000), None)
.add_output(None, recipient, NoteValue::from_raw(5000), [0u8; 512])
.unwrap();
let balance: i64 = builder.value_balance().unwrap();
assert_eq!(balance, -5000);
Expand Down
6 changes: 3 additions & 3 deletions src/pczt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ mod tests {
EMPTY_ROOTS[MERKLE_DEPTH_ORCHARD].into(),
);
builder
.add_output(None, recipient, NoteValue::from_raw(5000), None)
.add_output(None, recipient, NoteValue::from_raw(5000), [0u8; 512])
.unwrap();
let balance: i64 = builder.value_balance().unwrap();
assert_eq!(balance, -5000);
Expand Down Expand Up @@ -442,14 +442,14 @@ mod tests {
.add_spend(fvk.clone(), note, merkle_path.into())
.unwrap();
builder
.add_output(None, recipient, NoteValue::from_raw(10_000), None)
.add_output(None, recipient, NoteValue::from_raw(10_000), [0u8; 512])
.unwrap();
builder
.add_output(
Some(fvk.to_ovk(Scope::Internal)),
fvk.address_at(0u32, Scope::Internal),
NoteValue::from_raw(5_000),
None,
[0u8; 512],
)
.unwrap();
let balance: i64 = builder.value_balance().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions tests/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn bundle_chain() {
);
let note_value = NoteValue::from_raw(5000);
assert_eq!(
builder.add_output(None, recipient, note_value, None),
builder.add_output(None, recipient, note_value, [0u8; 512]),
Ok(())
);
let (unauthorized, bundle_meta) = builder.build(&mut rng).unwrap().unwrap();
Expand Down Expand Up @@ -112,7 +112,7 @@ fn bundle_chain() {
let mut builder = Builder::new(BundleType::DEFAULT, root.into());
assert_eq!(builder.add_spend(fvk, note, merkle_path.into()), Ok(()));
assert_eq!(
builder.add_output(None, recipient, NoteValue::from_raw(5000), None),
builder.add_output(None, recipient, NoteValue::from_raw(5000), [0u8; 512]),
Ok(())
);
let (unauthorized, _) = builder.build(&mut rng).unwrap().unwrap();
Expand Down

0 comments on commit efa62fc

Please sign in to comment.