Skip to content

fix(crypto): reject public Sapling encryption shared secrets - #69

Open
Federico2014 wants to merge 1 commit into
release_v4.8.3from
fix/sapling-recipient-privacy
Open

Federico2014 wants to merge 1 commit into
release_v4.8.3from
fix/sapling-recipient-privacy

Conversation

@Federico2014

@Federico2014 Federico2014 commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

What does this PR do?

Reject the canonical identity shared point in NoteEncryption.encryptToRecipient before key derivation or ciphertext creation. Both native shielded transactions and shielded TRC20 builders propagate this failure before output proving. The check covers identity aliases, small-order recipient points and a zero ephemeral secret.

Why are these changes required?

A degenerate recipient key can make the shared point public, exposing the amount and memo after the output is published. Check the canonical result of native key agreement rather than matching a particular recipient encoding. This sender-only change works with the existing SDK 1.0.0 and leaves historical note decryption and consensus verification unchanged.

This PR has been tested by:

  • Five new real-JNI tests cover identity aliases/order-four points, rejection followed by successful encryption and decryption, zero ephemeral secrets, rejection in both transaction builders before proving, and reading historical degenerate ciphertext.
  • These tests plus the two existing SaplingNoteTest cases passed with the bundled SDK and again with rebuilt normal release JNI (7 tests per run).
  • The identity-recipient regression fails against the original NoteEncryption implementation.
  • Changed production classes and their direct callers compiled with JDK 8 against locally built node dependencies. Focused Checkstyle 8.7 using the repository configuration passed; the forbidden Math check passed.
  • The Gradle offline test/Checkstyle invocation was blocked by missing cached dependencies in the p2p dependency graph. The focused runs used javac/JUnit with the existing local FullNode dependency JAR; they do not substitute for the full Gradle build/test matrix. Full CI remains required.

Follow up

Companion Rust/SDK changes reject these inputs during output proof generation and add native regressions. The node guard can ship independently without a dependency update.

Extra details

Based on Federico2014/java-tron release_v4.8.3 at 9f53b51. Cherry-picks the recipient fix from tronprotocol#7133 without unrelated upstream commits. No protocol, transaction-validation, SDK dependency, or historical-reading changes.

Companion PRs: tronprotocol/librustzcash#18 and tronprotocol/zksnark-java-sdk#25.


Summary by cubic

Rejects degenerate Sapling recipient keys so the shared encryption secret can never become public.

A recipient key that forces key agreement to the identity point makes the shared secret public, exposing the note amount and memo once the output is published. NoteEncryption.encryptToRecipient now returns empty for the canonical identity shared point before key derivation or ciphertext creation, and both native shielded transactions and shielded TRC20 builders fail before output proving.

  • Sender-only change; historical note decryption and consensus verification are unchanged.
  • Works with the existing SDK 1.0.0 and needs no dependency update.
  • New real-JNI tests cover identity aliases, small-order points, zero ephemeral secrets, rejection in both builders, and reading historical degenerate ciphertext.

Written for commit d96c293. Summary will update on new commits.

View guided diff Turn on auto-fix

@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0d7634d4-59dc-49cb-9f2d-2c2493e8d9f3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Turn on auto-fix | Re-trigger cubic

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