Skip to content

Implement io.jwt.verify_eddsa builtin (closes #145) - #153

Open
ume3445 wants to merge 2 commits into
open-policy-agent:mainfrom
ume3445:implement-jwt-verify-eddsa
Open

Implement io.jwt.verify_eddsa builtin (closes #145)#153
ume3445 wants to merge 2 commits into
open-policy-agent:mainfrom
ume3445:implement-jwt-verify-eddsa

Conversation

@ume3445

@ume3445 ume3445 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements io.jwt.verify_eddsa as described in #145.

Changes

  • Added a public verifyEdDSA method to TokenBuiltins.java, following the exact pattern of the existing verify_es256/verify_es384/verify_es512 methods
  • Delegates to the existing private _verifyEdDSA method, which already correctly implements EdDSA verification matching OPA's Go reference implementation (topdown/tokens.go): raw signing input with no pre-hashing, verified via Ed25519 through BouncyCastle
  • Registered the new builtin in the builtins() map alongside the other io.jwt.verify_* entries
  • The verification logic itself was already correct and in use internally by io.jwt.decode_verify; this PR only exposes it as a standalone public builtin

Testing

  • Verified against the jwtverifyeddsa/success-cert compliance fixture, which now correctly evaluates and passes (previously the missing function meant the test was silently skipped rather than actually asserted, since the test harness ignores FunctionNotFoundError cases)
  • Confirmed the existing jwtdecodeverify EdDSA case still passes, since it exercises the same shared _verifyEdDSA path
  • Full opa-evaluator suite shows no new regressions (stash-and-compare against the pre-existing failure set, identical 62 unrelated failures with and without the change)

Closes #145.

Signed-off-by: Muhammad Umer Hammad <umerhammad010@gmail.com>
type = "string",
name = "certificate",
description =
"PEM encoded certificate, PEM encoded public key, or the JWK key (set) used to verify the signature")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

_verifyEdDSA reaches getPublicKeyextractPublicKey, which only handles RSAKey and ECKey. An Ed25519 JWK parses to an OctetKeyPair (kty: OKP), so it falls into the else branch and throws "Unsupported JWK key type" — meaning this returns false (or errors in strict mode) for a valid Ed25519 JWK, even though the arg doc here advertises "the JWK key (set)".

This diverges from OPA: its getKeysFromCertOrJWK (v1/topdown/tokens.go) parses JWKs via jwx's jwk.Export, which supports OKP keys, so OPA accepts an Ed25519 JWK for io.jwt.verify_eddsa. For parity, consider adding an OKP branch to extractPublicKey (convert OctetKeyPair → Ed25519 PublicKey) rather than only supporting the PEM path. The added test only covers the PEM cert fixture, so the JWK path is untested for EdDSA.

Signed-off-by: Muhammad Umer Hammad <umerhammad010@gmail.com>
@ume3445
ume3445 requested a review from a team as a code owner July 22, 2026 00:51
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.

Implement io.jwt.verify_eddsa builtin

2 participants