Fix get public key function