Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: PrivateKey Curve bug #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

aitimate
Copy link

The current *ecdsa.PrivateKey does not conform to the standard secp256k1 curve, and therefore cannot be directly used with go-ethereum or related libraries for signing transactions. If you need to reproduce the issue, you can test it using the code below:

// see: https://github.com/ethereum/go-ethereum/blob/master/crypto/signature_nocgo.go#L82
func TestCurve(t *testing.T) {
	entropy, _ := bip39.NewEntropy(256)
	mnemonic, _ := bip39.NewMnemonic(entropy)
	hd, _ := NewFromMnemonic(mnemonic)
	path := MustParseDerivationPath(fmt.Sprintf("m/44'/60'/0'/0/%d", 0))
	account, _ := hd.Derive(path, false)
	privateKey, _ := hd.PrivateKey(account)
	if privateKey.Curve != crypto.S256() {
		panic(fmt.Errorf("private key curve is not secp256k1 : %v(%v)", getCurveName(privateKey), privateKey.Curve))
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant