You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JWK: support the registered secp256k1 curve name for EC keys #786
RFC 8812, section 3.1 registers the JWK crv value for the secp256k1 curve as "secp256k1". JWT::JWK::EC only recognises "P-256K", a name from earlier drafts, in lib/jwt/jwk/ec.rb:
to_openssl_curve maps 'P-256K' to 'secp256k1' and raises JWT::JWKError, 'Invalid curve provided' for anything else.
keypair_components exports secp256k1 keys with crv: 'P-256K'.
As a result, ES256K tokens can't be verified against a JWKS that uses the registered name, and keys exported by ruby-jwt aren't readable by implementations that only accept "secp256k1".
This also shows up with real JWKS. The Connect2id demo JWKS publishes an EC key with crv: "secp256k1". Importing it works because the key is built lazily, but verify_key, private? and export raise, so JWT::JWK::Set#export fails for the whole set. Looking up other keys by kid isn't affected.
Suggested fix
Accept both "secp256k1" and "P-256K" in to_openssl_curve. This is backwards compatible and could go into a patch release.
Export secp256k1 keys with crv: "secp256k1". This changes exported JWKs and their thumbprints for existing secp256k1 keys, so it might fit better in a minor or major release, with a CHANGELOG note.
The import half is fixed by #787, which will ship in 3.3.1. JWT::JWK::EC now accepts both "secp256k1" (RFC 8812) and "P-256K". Imported JWKs keep the curve name they were given, so standard secp256k1 JWKs, such as the one in the Connect2id demo JWKS, can be used to verify ES256K tokens and exported again.
I'm leaving this open for the export side. Keys created from an OpenSSL::PKey::EC are still exported with crv: "P-256K". Switching to "secp256k1" would change exported JWKs and their RFC 7638 thumbprints, so it's planned for the next minor release, with a CHANGELOG note.
Activity
Accept the RFC 8812 secp256k1 curve name for EC JWKs (#787)
anakinj commentedon Nov 4, 2026
The import half is fixed by #787, which will ship in 3.3.1.
JWT::JWK::ECnow accepts both"secp256k1"(RFC 8812) and"P-256K". Imported JWKs keep the curve name they were given, so standard secp256k1 JWKs, such as the one in the Connect2id demo JWKS, can be used to verify ES256K tokens and exported again.I'm leaving this open for the export side. Keys created from an
OpenSSL::PKey::ECare still exported withcrv: "P-256K". Switching to"secp256k1"would change exported JWKs and their RFC 7638 thumbprints, so it's planned for the next minor release, with a CHANGELOG note.Posted by Claude on behalf of @anakinj.