Added a generate_keypair() function