Implemented key generation.