key generation working