Skip to content

Commit 8c1e10a

Browse files
author
Daisuke Kanda
committed
force assign geth's S256() as Curve value
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
1 parent 12f1905 commit 8c1e10a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pkg/wallet/wallet.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99

1010
"github.com/btcsuite/btcd/btcutil/hdkeychain"
11+
gethcrypto "github.com/ethereum/go-ethereum/crypto"
1112
"github.com/btcsuite/btcd/chaincfg"
1213
bip39 "github.com/tyler-smith/go-bip39"
1314
)
@@ -124,7 +125,17 @@ func GetPrvKeyFromHDWallet(seed []byte, hp *HDPathLevel) (*ecdsa.PrivateKey, err
124125
if err != nil {
125126
return nil, err
126127
}
127-
return btcecPrivKey.ToECDSA(), nil
128+
129+
ecdsaPrivKey := btcecPrivKey.ToECDSA()
130+
131+
// The ecdsaPrivKey.Curve points to the dcrd.secp256k1.S256() instance,
132+
// but in some environments (e.g., Docker containers) the comparison with gethcrypto.S256() may fail.
133+
// To ensure consistency, we replace the Curve with gethcrypto.S256().'
134+
if ecdsaPrivKey.Curve.Params().Name == "secp256k1" && ecdsaPrivKey.Curve != gethcrypto.S256() {
135+
ecdsaPrivKey.Curve = gethcrypto.S256()
136+
}
137+
138+
return ecdsaPrivKey, nil
128139
}
129140

130141
func GetPrvKeyFromMnemonicAndHDWPath(mnemonic, path string) (*ecdsa.PrivateKey, error) {

0 commit comments

Comments
 (0)