Fixed address generation

This commit is contained in:
obscuren 2014-07-03 10:03:58 +02:00
parent 35ae9e3aa8
commit 81bc721c5c

View File

@ -3,8 +3,8 @@ package ethcrypto
import ( import (
"code.google.com/p/go.crypto/ripemd160" "code.google.com/p/go.crypto/ripemd160"
"crypto/sha256" "crypto/sha256"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/sha3" "github.com/obscuren/sha3"
"math/big"
) )
func Sha256Bin(data []byte) []byte { func Sha256Bin(data []byte) []byte {
@ -28,8 +28,6 @@ func Sha3Bin(data []byte) []byte {
} }
// Creates an ethereum address given the bytes and the nonce // Creates an ethereum address given the bytes and the nonce
func CreateAddress(b []byte, nonce *big.Int) []byte { func CreateAddress(b []byte, nonce uint64) []byte {
addrBytes := append(b, nonce.Bytes()...) return Sha3Bin(ethutil.NewValue([]interface{}{b, nonce}).Encode())[12:]
return Sha3Bin(addrBytes)[12:]
} }