all: Rename crypto.Sha3{,Hash}() to crypto.Keccak256{,Hash}()

As we aren't really using the standarized SHA-3
This commit is contained in:
Ricardo Catalinas Jiménez
2016-02-21 18:40:27 +00:00
parent c20d6e5e4e
commit 436fc8d76a
48 changed files with 92 additions and 92 deletions

View File

@ -43,7 +43,7 @@ import (
"golang.org/x/crypto/ripemd160"
)
func Sha3(data ...[]byte) []byte {
func Keccak256(data ...[]byte) []byte {
d := sha3.NewKeccak256()
for _, b := range data {
d.Write(b)
@ -51,7 +51,7 @@ func Sha3(data ...[]byte) []byte {
return d.Sum(nil)
}
func Sha3Hash(data ...[]byte) (h common.Hash) {
func Keccak256Hash(data ...[]byte) (h common.Hash) {
d := sha3.NewKeccak256()
for _, b := range data {
d.Write(b)
@ -63,7 +63,7 @@ func Sha3Hash(data ...[]byte) (h common.Hash) {
// Creates an ethereum address given the bytes and the nonce
func CreateAddress(b common.Address, nonce uint64) common.Address {
data, _ := rlp.EncodeToBytes([]interface{}{b, nonce})
return common.BytesToAddress(Sha3(data)[12:])
return common.BytesToAddress(Keccak256(data)[12:])
//return Sha3(common.NewValue([]interface{}{b, nonce}).Encode())[12:]
}
@ -265,7 +265,7 @@ func decryptPreSaleKey(fileContent []byte, password string) (key *Key, err error
if err != nil {
return nil, err
}
ethPriv := Sha3(plainText)
ethPriv := Keccak256(plainText)
ecKey := ToECDSA(ethPriv)
key = &Key{
Id: nil,
@ -330,7 +330,7 @@ func PKCS7Unpad(in []byte) []byte {
func PubkeyToAddress(p ecdsa.PublicKey) common.Address {
pubBytes := FromECDSAPub(&p)
return common.BytesToAddress(Sha3(pubBytes[1:])[12:])
return common.BytesToAddress(Keccak256(pubBytes[1:])[12:])
}
func zeroBytes(bytes []byte) {