From e835ff0010a7f55945f04680643b85abd99b536a Mon Sep 17 00:00:00 2001 From: William Hua Date: Mon, 15 Jul 2024 17:59:59 -0400 Subject: [PATCH] ethwallet: swap out btcec.S256 with crypto.S256 https://github.com/0xsequence/ethkit/blob/cdebd571052500fd2e341d7e91cdfd0bb128a6d9/go-ethereum/crypto/signature_nocgo.go#L82-L84 https://github.com/0xsequence/ethkit/blob/cdebd571052500fd2e341d7e91cdfd0bb128a6d9/go-ethereum/crypto/signature_nocgo.go#L161-L196 Upstream go-ethereum started embedding the original curve in a new type with custom marshaling, causing the original curve check to fail when running with CGO_ENABLED=0. --- ethwallet/hdnode.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ethwallet/hdnode.go b/ethwallet/hdnode.go index 1a0319f6..85b569a1 100644 --- a/ethwallet/hdnode.go +++ b/ethwallet/hdnode.go @@ -8,6 +8,7 @@ import ( "github.com/0xsequence/ethkit/go-ethereum/accounts" "github.com/0xsequence/ethkit/go-ethereum/common" "github.com/0xsequence/ethkit/go-ethereum/crypto" + "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil/hdkeychain" "github.com/btcsuite/btcd/chaincfg" "github.com/tyler-smith/go-bip39" @@ -249,6 +250,9 @@ func derivePrivateKey(masterKey *hdkeychain.ExtendedKey, path accounts.Derivatio } privateKeyECDSA := privateKey.ToECDSA() + if privateKeyECDSA.Curve == btcec.S256() { + privateKeyECDSA.PublicKey.Curve = crypto.S256() + } return privateKeyECDSA, nil }