Skip to content

Commit

Permalink
Remove RLP encoding for CreateAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
0xalank authored and wizeguyy committed Jan 25, 2023
1 parent 6bf159e commit 32b1142
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
Expand All @@ -32,7 +33,6 @@ import (

"github.com/dominant-strategies/go-quai/common"
"github.com/dominant-strategies/go-quai/common/math"
"github.com/dominant-strategies/go-quai/rlp"
"golang.org/x/crypto/sha3"
)

Expand Down Expand Up @@ -106,8 +106,9 @@ func Keccak512(data ...[]byte) []byte {

// CreateAddress creates an ethereum address given the bytes and the nonce
func CreateAddress(b common.Address, nonce uint64, code []byte) common.Address {
data, _ := rlp.EncodeToBytes([]interface{}{b, nonce, code})
return common.BytesToAddress(Keccak256(data)[12:])
nonceBytes := make([]byte, 8)
binary.BigEndian.PutUint64(nonceBytes, uint64(nonce))
return common.BytesToAddress(Keccak256(b.Bytes(), nonceBytes, code)[12:])
}

// CreateAddress2 creates an ethereum address given the address bytes, initial
Expand Down

0 comments on commit 32b1142

Please sign in to comment.