Extract common key generation function
Move PublicKey decoding out of PubkeyBean