fixing bug in secret key generation