I have a public key that gets generated using the secpk256 curve, I am trying to determine the ethereum address of this public key. Basically I obtain the key as a simple string and then try to use geths crypto functions to get the public address of this public key.
Heres a sample hex encoded public key string: 02ccb8bc17397c55242a27d1681bf48b5b40a734205760882cd83f92aca4f1cf45 heres my code sample:
package main
import (
"github.com/ethereum/go-ethereum/crypto"
)
publickey := "02ccb8bc17397c55242a27d1681bf48b5b40a734205760882cd83f92aca4f1cf45"
ecdsaPub, err := crypto.UnmarshalPubkey(publickey)
if err != nil {
return "", err
}
ethAddress := crypto.PubkeyToAddress(*ecdsaPub).String()