Added a key generation algorithm