fix(crypto): reject public Sapling encryption shared secrets
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 upstream release_v4.8.3 at b715a9f. No protocol, transaction-validation, SDK dependency, or historical-reading changes.
Companion PRs: https://github.com/tronprotocol/librustzcash/pull/18 and https://github.com/tronprotocol/zksnark-java-sdk/pull/25.