liveBook · Manning

Public-private key pair

As explained in Secure APIs

A public-private key pair consists of mathematically related cryptographic keys, with the private key used for signing and the public key used for verification.

A public-private key pair contains two mathematically related cryptographic keys. Keep the private key for signing JWTs; distribute the public key for validating their signatures. section 8.2 section 8.7

This arrangement lets an API verify tokens without receiving the signing secret. Generate the pair before using an asymmetric algorithm such as PS256, and validate the token’s claims while constraining the permitted algorithm. section 8.2 section 8.7

Generate an RSA pair for JWTs

OpenSSL can create a 3072-bit RSA pair with `openssl genpkey -algorithm RSA -out private_key.pem -outpubkey public_key.pem -pkeyopt rsa_keygen_bits:3072`. Load `private_key.pem` for signing with PyJWT and PS256; use the corresponding public key to verify signatures. section 8.2

How Secure APIs covers it

How deep it goes
Explains signing roles, OpenSSL generation, Python loading, and validation safeguards, but does not detail cryptographic mathematics.
Examples
Uses an OpenSSL RSA-generation command, PEM key files, Python key loading, and a PyJWT PS256 token-issuance fragment.
What it assumes
Assumes basic JWT authentication context while introducing asymmetric signing, RSA key generation, and PEM key loading.
What you can do after
Build it from scratch by generating an RSA pair, loading the private key, signing JWTs, and validating them with the public key.
How it connects
Connects asymmetric cryptography with JWT, PS256, OpenSSL, digital signature validation, OIDC, JWKS, and RBAC.

Also explained in

Compare how 6 books explain public-private key pair →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secure APIs. The section links point to the parts of the book it draws on.