Verify JWT with RSA Public Key in Node

Trying to verify a JWT using the public key, I'm writing some integration tests around this, but this is what I'm doing


const {privateKey, publicKey} = crypto.generateKeyPairSync("rsa", {modulusLength: 4096});
const privateKeyString = privateKey.export({type: "pkcs8", format: "pem"}).toString();
const publicKeyString = publicKey.export({type: "spki", format: "pem"}).toString();

let user = {email: ''};

const token = jwt.sign(user, privateKeyString, {algorithm: "RS256"});

That gets passed to the following function:

jwt.verify(token, publicKeyString);

I've also tried with:

jwt.verify(token, publicKeyString, {algorithms: ['RS256']}

Both yield:

verify: JsonWebTokenError: invalid signature

I've used to validate the token, and also verifying the signature with both the public and private key. Using jwt.decode works correctly as well.

Not sure what I'm doing wrong.