我基本上是试图通过使用Golang从以太坊账户的种子短语中获取公钥和私钥。我有这个:
package generator
import (
"fmt"
"github.com/tyler-smith/go-bip32"
"github.com/tyler-smith/go-bip39"
)
type HDWallet struct{}
const BIP_PATH = "m/44'/60'/0'/0/0"
func (wallet *HDWallet) GenerateAddressAndPrivateKey(seedPhrase string) (string, string, error) {
seed, err := bip39.NewSeedWithErrorChecking(seedPhrase, "")
if err != nil {
return "", "", err
}
masterKey, err := bip32.NewMasterKey(seed)
if err != nil {
return "", "", err
}
publicKey := masterKey.PublicKey()
if err != nil {
return "", "", err
}
return ???, ???, nil
}
字符串
我有主密钥,但我如何获得派生帐户(公钥和私钥)?
1条答案
按热度按时间new9mtju1#
为了将公钥和私钥作为已知的十六进制字符串(帐户密钥)检索,您需要将生成的主私钥和公钥转换为ECDSA十六进制字符串,如下所示。顺便说一下,通常您不会使用主私钥和公钥。
字符串
您可以检查生成的十六进制字符串公钥是否属于私钥十六进制字符串,如下所示。
型
--编辑--
没有保证,但尝试这种方法。
型