Skip to content

Commit

Permalink
Fix the public key generation for Ethereum
Browse files Browse the repository at this point in the history
fill the bytes with zeros to make sure the public key is 64 bytes long
  • Loading branch information
modood committed May 20, 2024
1 parent ca9bad6 commit e6ee94c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e6ee94c

Please sign in to comment.