Repository navigation
Conversation
…hecks and equation EdDSASigningProvider.verify now goes through an Ed25519Verifier. The default, BouncyCastleEd25519Verifier, runs libsodium's input checks and its cofactorless equation on BouncyCastle's field arithmetic and allocates about 6 KB per verification instead of about 630 KB. It checks itself against libsodium's verdicts on first use and fails with a LinkageError naming the bcprov version if they differ. I2pEd25519Verifier is the previous verifier; select it with CryptoConfiguration.INSTANCE.setEd25519Verifier. Signing stays on the i2p fork. bcprov goes to 1.86. Tests check both verifiers against libsodium's verdicts (2,368 generated cases, RFC 8032, Wycheproof, speccheck) and against each other on 4,000 seeded cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MJrQU97MHKeQpEH7XcJT9A
…rdening - BouncyCastleEd25519Verifier decodes the key before it reads the message, so a key that is not a curve point gives false with a null message, as I2pEd25519Verifier does; a null message with a key that decodes throws CryptoException in both. - On a bcprov without the X25519Field methods the equation uses (before 1.67) the LinkageError names the bcprov version and what is needed. - The self-check's outcome is kept once definite; a transient error such as an OutOfMemoryError no longer disables verification for the life of the JVM. - setEd25519Verifier refuses null. The verify javadoc mentions the LinkageError, and crypto-api.md says how to choose the verifier. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MJrQU97MHKeQpEH7XcJT9A
|
Contributor
|
Initial automated review · Aster Hi @satran004, thanks for the PR! 🙏 This is an automatic first check by an AI reviewer. It does not replace maintainer review and may be wrong. Reviewed commit: Issues found:
Suggestions:
Not tested: I reviewed the code and CI without running builds, tests, or the libsodium corpus. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Ed25519
verifynow has two interchangeable implementations behind a newEd25519Verifierinterface. Both give a cardano-node's outcomes, which come from libsodium'scrypto_sign_ed25519_verify_detached.BouncyCastleEd25519Verifier(new default): libsodium's input checks plus libsodium's cofactorless equation, ported onto BouncyCastle'sX25519Fieldwith SHA-512. It is pure Java and allocates about 7 KB per verify, against about 634 KB on the i2p path.I2pEd25519Verifier: the existing i2p-based verification with the checks from fix(crypto): align Ed25519 verification with cardano-node (KES header validation) #718, unchanged.To select a verifier, use
CryptoConfiguration.INSTANCE.setEd25519Verifier(...)globally, ornew EdDSASigningProvider(verifier)for one provider. Signing, extended-key signing, KES and VRF keep using i2p. KES leaf verification goes through the configured verifier.BouncyCastle's own
Ed25519.verifyis not used. It is cofactored and accepts mixed-order inputs that libsodium rejects: 7,696 of 100,212 cases in our differential corpus.Details
Ed25519InputChecks(package-private): the libsodium checks. They reject a non-canonicalS, a small-orderRor key, and a non-canonical key.Ed25519Equation(package-private): libsodium'sfrombytes_negate_vartime,slide,double_scalarmult_vartime,tobytesand byte compare, onX25519Field.Load-time self-check. On first use it runs three vectors:
R(reject; BouncyCastle's own verify accepts it);If the bcprov on the classpath disagrees, or lacks
X25519Field,verifythrows aLinkageErrorthat names the bcprov version and jar and says to use 1.67+ or switch toI2pEd25519Verifier. Only a definite outcome is cached; a transient OOM or StackOverflow is retried.Both verifiers agree on a null message:
false;CryptoException.setEd25519Verifier(null)is rejected.bcprov is bumped to 1.86.
Docs: "Choosing the Ed25519 verifier" in
www/src/content/docs/reference/crypto-api.md.Testing
Libsodium parity. Test resources: 2,371 libsodium 1.0.18 corpus vectors, 220 fixed vectors (RFC 8032 and small-order cases), and probes. Both verifiers must match libsodium on every vector.
Wider differential runs, outside the repo: about 100k cases, plus RFC 8032 and Wycheproof. 0 mismatches against libsodium across bcprov 1.67–1.86.
Builds:
:crypto:test88/88 and:crypto-ext:test149/149 on JDK 17. In the wider build, the only failure isRocksDbJmtCrashRecoveryTest("Crash worker timed out"), which also fails on unmodified master 5ca123e.Yano downstream, with this branch backported onto Yano v0.8.0-pre7. Results are identical with the baseline, BouncyCastle and i2p verifiers:
That covers about 11k Ed25519 verifies per run, including KES and opcert checks. Per-caller counts are identical.
Reviews: an independent Claude review (approve; its P3s are fixed in 5c0ebe3) and two Codex adversarial reviews (both approve).
Compatibility
SigningProvider.verifyis unchanged.LinkageErrorwith advice, instead of failing obscurely.🤖 Generated with Claude Code
https://claude.ai/code/session_01MJrQU97MHKeQpEH7XcJT9A