@@ -18,6 +18,7 @@ The following specifications are implemented by @panva/jose
1818- JSON Web Key Thumbprint - [ RFC7638] [ spec-thumbprint ]
1919- JWS Unencoded Payload Option - [ RFC7797] [ spec-b64 ]
2020- CFRG Elliptic Curve Signatures (EdDSA) - [ RFC8037] [ spec-okp ]
21+ - secp256k1 curve EC Key support - [ JOSE Registrations for WebAuthn Algorithms] [ draft-secp256k1 ]
2122
2223The test suite utilizes examples defined in [ RFC7520] [ spec-cookbook ] to confirm its JOSE
2324implementation is correct.
@@ -47,7 +48,7 @@ Legend:
4748| -- | -- | -- |
4849| RSASSA-PKCS1-v1_5 | ✓ | RS256, RS384, RS512 |
4950| RSASSA-PSS | ✓ | PS256, PS384, PS512 |
50- | ECDSA | ✓ | ES256, ES384, ES512 |
51+ | ECDSA | ✓ | ES256, ES256K, ES384, ES512 |
5152| Edwards-curve DSA | ✓ | EdDSA |
5253| HMAC with SHA-2 | ✓ | HS256, HS384, HS512 |
5354
@@ -247,6 +248,32 @@ jose.JWE.decrypt(
247248)
248249```
249250
251+ #### secp256k1
252+
253+ Note: the secp256k1 JOSE parameters registration and the RFC is still in a draft state. If the WG
254+ draft changes its mind about the parameter names again the new values will be propagated as a MINOR
255+ library version.
256+
257+ When you require ` @panva/jose ` you can work with ` secp256k1 ` EC keys right away, the EC JWK ` crv `
258+ used is as per the specification ` secp256k1 ` .
259+
260+ ``` js
261+ const jose = require (' @panva/jose' )
262+ let key = jose .JWK .generateSync (' EC' , ' secp256k1' )
263+ key = jose .JWK .asKey (fs .readFileSync (' path/to/key/file' ))
264+ key .crv === ' secp256k1'
265+ ```
266+
267+ For legacy reasons the unregistered EC JWK ` crv ` value ` P-256K ` is also supported but you must
268+ require ` @panva/jose ` like so to use it:
269+
270+ ``` js
271+ const jose = require (' @panva/jose/P-256K' )
272+ let key = jose .JWK .generateSync (' EC' , ' P-256K' )
273+ key = jose .JWK .asKey (fs .readFileSync (' path/to/key/file' ))
274+ key .crv === ' P-256K'
275+ ```
276+
250277## FAQ
251278
252279#### Semver?
@@ -315,6 +342,7 @@ in terms of performance and API (not having well defined errors).
315342[ spec-jws ] : https://tools.ietf.org/html/rfc7515
316343[ spec-jwt ] : https://tools.ietf.org/html/rfc7519
317344[ spec-okp ] : https://tools.ietf.org/html/rfc8037
345+ [ draft-secp256k1 ] : https://tools.ietf.org/html/draft-ietf-cose-webauthn-algorithms-01
318346[ spec-thumbprint ] : https://tools.ietf.org/html/rfc7638
319347[ suggest-feature ] : https://github.com/panva/jose/issues/new?labels=enhancement&template=feature-request.md&title=proposal%3A+
320348[ support-patreon ] : https://www.patreon.com/panva
0 commit comments