How do i produce keypairs for my users while implementing json web token

I want to check the integrity of my user information; that the information which my website server receives was indeed sent by them. From what I understand, json web tokens (jwt) is the way to go.

I want to use asymmetric keys for the signing. I know that key pairs can be generated using these commands:

openssl genrsa -out private.pem 2048 openssl rsa -in private.pem -outform PEM -pubout -out public.pem 

But how do I produce key pairs from javascript code for my users when they sign in. And how do I store the private key at the user end and the public key at the server end ?