Skip to content

fix: make PCZT trial decryption generic over MemoSize#6

Merged
QuantumExplorer merged 1 commit into
dashifiedfrom
fix/pczt-memo-generic
Jul 2, 2026
Merged

fix: make PCZT trial decryption generic over MemoSize#6
QuantumExplorer merged 1 commit into
dashifiedfrom
fix/pczt-memo-generic

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

  • OrchardDomain::for_pczt_action and impl ShieldedOutput<OrchardDomain<ZcashMemo>> for pczt::Action were pinned to ZcashMemo, even though pczt::Bundle/Action/Output and Builder::build_for_pczt are generic over M: MemoSize (feat: make memo size generic via MemoSize trait #1)
  • As a result, a pczt::Bundle<DashMemo> had no supported trial-decryption path: a PCZT Signer could not verify the outputs it was being asked to authorize (try_note_decryption(&OrchardDomain::for_pczt_action(action), ...) did not compile for M = DashMemo), and because both the trait and the types live in this crate, orphan rules prevent downstream crates from adding the impl themselves
  • Neither impl body was Zcash-specific, so this generalizes both over M: MemoSize

Changes

  • OrchardDomain::for_pczt_action moved into the generic impl<M: MemoSize> OrchardDomain<M> block, taking &pczt::Action<M>; now delegates to for_nullifier instead of duplicating its body
  • impl<M: MemoSize> ShieldedOutput<OrchardDomain<M>> for pczt::Action<M> replaces the ZcashMemo-only impl; enc_ciphertext returns Option<&M::NoteCiphertextBytes>
  • New regression test pczt_trial_decryption_is_memo_size_generic: builds a pczt::Bundle<DashMemo> via Builder::<DashMemo>::build_for_pczt, trial-decrypts the output through for_pczt_action, and checks note value, recipient address, and the 36-byte memo round-trip

No behavior change for ZcashMemo users — the generic impls subsume the old pinned ones.

Test plan

  • cargo test --lib pczt — 6 passed (including the full proving PCZT role tests and the new regression test)
  • cargo check --all-features
  • cargo clippy --all-features clean
  • cargo fmt -- --check

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • PCZT trial decryption now works with multiple memo sizes, not just the default one.
    • Decrypted memo recovery is supported across memo-size variants during shielded output handling.
  • Tests

    • Added coverage to verify trial decryption succeeds with a non-default memo size.

OrchardDomain::for_pczt_action and the ShieldedOutput impl for
pczt::Action were pinned to ZcashMemo, so a pczt::Bundle<DashMemo>
built via Builder::<DashMemo>::build_for_pczt had no supported
trial-decryption path: a Signer could not verify the outputs it was
asked to authorize, and orphan rules prevent downstream crates from
adding the impl themselves.

Generalize both over M: MemoSize, delegate for_pczt_action to
for_nullifier instead of duplicating its body, and add a regression
test that trial-decrypts a DashMemo PCZT output end-to-end.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 82fb7c28-16ce-4710-a137-733309c1d9b7

📥 Commits

Reviewing files that changed from the base of the PR and between f055573 and 0d9f5f9.

📒 Files selected for processing (1)
  • src/note_encryption.rs

📝 Walkthrough

Walkthrough

OrchardDomain::for_pczt_action and the ShieldedOutput implementation for PCZT actions in src/note_encryption.rs are generalized from being specific to ZcashMemo to being generic over any MemoSize. A new test validates trial decryption using DashMemo.

Changes

Generic PCZT action decryption

Layer / File(s) Summary
Generalize for_pczt_action and ShieldedOutput impl
src/note_encryption.rs
for_pczt_action now accepts crate::pczt::Action<M>; the ShieldedOutput<OrchardDomain<M>> impl for crate::pczt::Action<M> is generalized, with enc_ciphertext returning Option<&M::NoteCiphertextBytes>.
DashMemo trial decryption test
src/note_encryption.rs
A new test builds a PCZT bundle with DashMemo and verifies decrypted value, address, and memo bytes using the generic for_pczt_action.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Test
  participant OrchardDomain
  participant PcztAction as "pczt::Action<M>"

  Test->>OrchardDomain: for_pczt_action(&PcztAction)
  OrchardDomain->>PcztAction: ephemeral_key(), cmstar()
  OrchardDomain->>PcztAction: enc_ciphertext()
  PcztAction-->>OrchardDomain: Option<&M::NoteCiphertextBytes>
  OrchardDomain-->>Test: decrypted note value, address, memo
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: generalizing PCZT trial decryption over MemoSize.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pczt-memo-generic

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self Reviewed

@QuantumExplorer QuantumExplorer merged commit 81ca424 into dashified Jul 2, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant