From e6ee94c0838f93b5ea24519a1dc502f7cb0521a9 Mon Sep 17 00:00:00 2001 From: modood Date: Mon, 20 May 2024 20:36:14 +0800 Subject: [PATCH] Fix the public key generation for Ethereum fill the bytes with zeros to make sure the public key is 64 bytes long --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index d4aafd4..0fc4e9f 100644 --- a/main.go +++ b/main.go @@ -456,7 +456,7 @@ func encodeEthereum(privateKeyBytes []byte) (privateKey, address string) { _, pubKey := btcec.PrivKeyFromBytes(privateKeyBytes) publicKey := pubKey.ToECDSA() - publicKeyBytes := append(publicKey.X.Bytes(), publicKey.Y.Bytes()...) + publicKeyBytes := append(publicKey.X.FillBytes(make([]byte, 32)), publicKey.Y.FillBytes(make([]byte, 32))...) // Ethereum uses the last 20 bytes of the keccak256 hash of the public key hash := sha3.NewLegacyKeccak256()