Skip to content

feat: add Ed25519 and Ed448 algorithms (RFC 9864) - #69

Merged
miladrahimi merged 1 commit into
mainfrom
feature/ed25519-ed448
Aug 1, 2026
Merged

feat: add Ed25519 and Ed448 algorithms (RFC 9864)#69
miladrahimi merged 1 commit into
mainfrom
feature/ed25519-ed448

Conversation

@miladrahimi

Copy link
Copy Markdown
Owner

Summary

Adds the RFC 9864 fully-specified EdDSA algorithm identifiers, Ed25519 and Ed448. RFC 9864 deprecates the
polymorphic EdDSA identifier in favour of names that pin the curve, and jwt.io now lists both. The existing
EdDsa* classes are untouched and keep working.

What's included

  • Ed25519Signer / Ed25519Verifier — subclass the EdDsa* classes and change only the JWS alg name.
    Same libsodium keys and same signatures, so tokens are interchangeable apart from the header.
  • Ed448Signer / Ed448Verifier — Curve448 via OpenSSL (openssl_sign/openssl_verify with digest 0),
    available since PHP 8.4.
  • Ed448PrivateKey / Ed448PublicKey — PEM path or inline content, like the RSA/ECDSA keys. They require
    OPENSSL_KEYTYPE_ED448 at construction, so on PHP 7.4–8.3 users get a clear InvalidKeyException instead of
    an obscure OpenSSL failure, and every other algorithm is unaffected.
  • Docs (README, ARCHITECTURE, TESTING, ADDING_AN_ALGORITHM, CONTRIBUTING, CLAUDE.md) and runnable
    examples/ed25519.php + examples/ed448.php.

Compatibility

No breaking changes and no new runtime dependencies. Ed25519 needs ext-sodium (as EdDSA already did);
Ed448 needs PHP 8.4+ with OpenSSL Ed448 support and is skipped elsewhere.

Testing

  • Ed25519Test, Ed448Test, Ed448PrivateKeyTest, Ed448PublicKeyTest, plus new ExamplesTest /
    ExamplesScriptsTest coverage for the README snippets and example scripts.
  • Interop vectors signed with the OpenSSL CLI: sodium verifies an independent Ed25519 implementation
    (RFC 8037 key), and the Ed448 vector pins the raw 114-byte signature format.
  • New test-only keys: ed448-private.pem, ed448-public.pem, and x448-private.pem (loads but cannot sign)
    to cover the signing-failure path.
  • Full suite green locally: 326 tests, 455 assertions.

@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6682be3) to head (cd1a649).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##                main       #69   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       261       290   +29     
===========================================
  Files             40        44    +4     
  Lines            578       629   +51     
===========================================
+ Hits             578       629   +51     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

RFC 9864 deprecates the polymorphic EdDSA identifier in favor of the
fully-specified Ed25519 and Ed448 names, which jwt.io now lists.

- Ed25519Signer/Ed25519Verifier subclass the EdDsa classes, changing
  only the JWS alg name; same sodium keys and signatures.
- Ed448Signer/Ed448Verifier run on OpenSSL (openssl_sign/openssl_verify
  with no digest), available since PHP 8.4. The Ed448PrivateKey and
  Ed448PublicKey classes (PEM path or inline, like RSA/ECDSA keys) gate
  the algorithm at construction by requiring OPENSSL_KEYTYPE_ED448, so
  PHP 7.4-8.3 users get a clear InvalidKeyException and everything else
  keeps working unchanged.
- Interop vectors signed with the OpenSSL CLI: sodium verifies an
  independent Ed25519 implementation (RFC 8037 key), and the Ed448
  vector pins the raw 114-byte signature format.
- New test keys: ed448-*.pem plus x448-private.pem (loads but cannot
  sign) for the signing-failure path.
@miladrahimi
miladrahimi force-pushed the feature/ed25519-ed448 branch from 7091a2e to cd1a649 Compare August 1, 2026 06:59
@sonarqubecloud

sonarqubecloud Bot commented Aug 1, 2026

Copy link
Copy Markdown

@miladrahimi
miladrahimi merged commit e404b15 into main Aug 1, 2026
21 checks passed
@miladrahimi
miladrahimi deleted the feature/ed25519-ed448 branch August 1, 2026 07:04
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