Keys

Make, store, convert and rotate the keys that sign and encrypt your tokens, as JSON Web Keys.

Every token starts with a key, and there are two kinds. A secret is one key that both sides share, like the single key to a padlock: whoever holds it can sign and verify, or lock and unlock. A key pair is two keys that belong together. The private key signs or decrypts, and the public key verifies or encrypts. You keep the private key on your server and never hand it out; the public key you can give to anyone, which is how other services check your tokens without being able to make them. Concepts explains the vocabulary.

unjwt writes keys as JSON Web Keys (RFC 7517): plain JSON objects you can store in a secret manager, publish, and pass straight to sign(), verify(), encrypt() and decrypt(). A public ES256 key looks like this:

{
  "kty": "EC",
  "crv": "P-256",
  "x": "cbCcIXJKSdiE8TGTgXgwNAf5PERuCJGMTGlRnj78Lqw",
  "y": "bcMypp7pabIplm3uG1IeBFOt-8WiHFZbneJiHcrEfVA",
  "alg": "ES256",
  "kid": "2026-10"
}

kty says what kind of key it is, alg the one algorithm it is for, and kid its name. The private half is the same object plus a d member. Every function on these pages comes from unjwt/jwk.

ktyWhat it isAlgorithms
octA secretHS*, A*KW, A*GCMKW, A*GCM, A*CBC-HS*
RSAAn RSA key pairRS*, PS*, RSA-OAEP*
ECAn elliptic-curve key pair (P-256, -384, -521)ES*, ECDH-ES*
OKPAn Ed25519 or X25519 key pairEd25519, EdDSA, ECDH-ES*