Skip to content

Commit e6ee94c

Browse files
committed
Fix the public key generation for Ethereum
fill the bytes with zeros to make sure the public key is 64 bytes long
1 parent ca9bad6 commit e6ee94c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ func encodeEthereum(privateKeyBytes []byte) (privateKey, address string) {
456456
_, pubKey := btcec.PrivKeyFromBytes(privateKeyBytes)
457457

458458
publicKey := pubKey.ToECDSA()
459-
publicKeyBytes := append(publicKey.X.Bytes(), publicKey.Y.Bytes()...)
459+
publicKeyBytes := append(publicKey.X.FillBytes(make([]byte, 32)), publicKey.Y.FillBytes(make([]byte, 32))...)
460460

461461
// Ethereum uses the last 20 bytes of the keccak256 hash of the public key
462462
hash := sha3.NewLegacyKeccak256()

0 commit comments

Comments
 (0)