So I am trying to get public key in hex formatting. In some documentation I found the following will give public key from the private key, but it is not formatted correctly as I can see:
publicKey := privateKey.Public()
// output is &{0xc0000aa810 111467676592638012114394423922557735151709477236068497041031680458777853727687 91044589275583075592054080804256995961966216084890183147914377743969771213580}
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
if !ok {
log.Fatal("error casting public key to ECDSA")
}
// output looks the same here: &{0xc0000aa810 111467676592638012114394423922557735151709477236068497041031680458777853727687 91044589275583075592054080804256995961966216084890183147914377743969771213580}
publicKeyBytes := crypto.FromECDSAPub(publicKeyECDSA)
// output: [4 246 112 120 28 51 214 136 11 9 156 225 31 55 248 83 107 177 101 138 103 54 81 101 66 67 247 150 1 88 0 147 199 201 73 105 81 71 44 213 141 125 198 50 50 47 21 2 25 193 203 214 105 129 64 151 83 64 247 101 247 190 42 83 12]
But what I am trying to get is the hex formatted of this. It does look like privateKey,Public()
gives this, but added things with it. Is there a way to get just the hex representation of the public key so I can store and use later in the code?