2

Using some of the code from Geth's source code https://github.com/ethereum/go-ethereum, I'm trying to find a way to generate valid Ethereum wallets. For starters, I'm using the hex version of secp256k1 prime MINUS 1, which is "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140". Plugging that into Metamask I get an address of "0x80C0dbf239224071c59dD8970ab9d542E3414aB2". I would like to use the functions to get the equivalent address.

I've so far put in the hex format of the private key "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140". I get a 20 length byte array [164 121 62 11 173 85 89 159 11 68 30 45 4 221 247 191 191 44 73 181]

To be specific, I defined the secp256k1 prime - 1's hex value and used Geth's Crypto's newKey() function

var r io.Reader
r = strings.NewReader("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140")


tmp, err := newKey(r)

if err != nil {
    fmt.Println(err)
}
fmt.Println(tmp.Address)

I have two questions. First, did I input the private key right as a hex? Second, how do I convert this 20 length byte array to a "normal" hex address?

Volker
  • 40,468
  • 7
  • 81
  • 87
Luke Zhang
  • 343
  • 1
  • 4
  • 14

0 Answers0