miguelmota / go-ethereum-hdwallet

Ethereum HD Wallet derivations in Go (golang)

Home Page:https://github.com/miguelmota/go-ethereum-hdwallet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid private key generation

klim0v opened this issue · comments

        wallet, err := hdwallet.NewFromMnemonic("real town addict extend shoot name disagree vital turn live can tip")
	if err != nil {
		return "", err
	}

	path := hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/0")
	account, err := wallet.Derive(path, false)
	if err != nil {
		return "", err
	}

	keyHex, err := wallet.PrivateKeyHex(account)
	if err != nil {
		return "", err
	}

        return keyHex, nil

got c64f0b3e510d03adef3f057d1814bdc8a7f904caafa6928550fc10670dcff031
wanted c29cd818232f40614691a58c9afcbd5518b539cb135d73b1d9e26d5f5f5dcbbe (https://iancoleman.io/bip39/)

it was a mistake on the m/44H/60H/0H path

This was fixed upstream in btcsuite/btcutil#182, merged in Nov 2020 which effected 1 in 128 addresses that were unlucky enough to have a leading zero.