aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-02-24 19:57:57 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-02-24 19:57:57 +0800
commit483feb0d3f015f103f80dbaf2aca9a130f5d964c (patch)
tree8137bf41be9b84bc6797ec55c861332b2efc3ab1 /core
parent1415669ac31cf8f06d107e06681b95c2b5e1c040 (diff)
parent139f6a0f4c1b3358a92bdfb5637878b2c97eba78 (diff)
downloaddexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar
dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar.gz
dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar.bz2
dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar.lz
dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar.xz
dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar.zst
dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.zip
Merge pull request #2242 from jimenezrick/upstream-crypto
Closes #2241: Use Keccak-256 from golang.org/x/crypto/sha3 and mention explicitly
Diffstat (limited to 'core')
-rw-r--r--core/state/state_object.go4
-rw-r--r--core/types/bloom9.go2
-rw-r--r--core/types/bloom9_test.go2
-rw-r--r--core/types/transaction.go2
-rw-r--r--core/vm/contracts.go2
-rw-r--r--core/vm/instructions.go2
-rw-r--r--core/vm/jit.go2
-rw-r--r--core/vm/jit_test.go2
-rw-r--r--core/vm/runtime/runtime.go2
-rw-r--r--core/vm/vm.go2
-rw-r--r--core/vm/vm_jit.go4
11 files changed, 13 insertions, 13 deletions
diff --git a/core/state/state_object.go b/core/state/state_object.go
index 6095fc96a..0f86325c6 100644
--- a/core/state/state_object.go
+++ b/core/state/state_object.go
@@ -30,7 +30,7 @@ import (
"github.com/ethereum/go-ethereum/trie"
)
-var emptyCodeHash = crypto.Sha3(nil)
+var emptyCodeHash = crypto.Keccak256(nil)
type Code []byte
@@ -225,7 +225,7 @@ func (self *StateObject) Code() []byte {
func (self *StateObject) SetCode(code []byte) {
self.code = code
- self.codeHash = crypto.Sha3(code)
+ self.codeHash = crypto.Keccak256(code)
self.dirty = true
}
diff --git a/core/types/bloom9.go b/core/types/bloom9.go
index 372045ab2..ecf2bffc2 100644
--- a/core/types/bloom9.go
+++ b/core/types/bloom9.go
@@ -101,7 +101,7 @@ func LogsBloom(logs vm.Logs) *big.Int {
}
func bloom9(b []byte) *big.Int {
- b = crypto.Sha3(b[:])
+ b = crypto.Keccak256(b[:])
r := new(big.Int)
diff --git a/core/types/bloom9_test.go b/core/types/bloom9_test.go
index 5744bec6c..58e8f7073 100644
--- a/core/types/bloom9_test.go
+++ b/core/types/bloom9_test.go
@@ -73,7 +73,7 @@ func TestBloom9(t *testing.T) {
func TestAddress(t *testing.T) {
block := &Block{}
block.Coinbase = common.Hex2Bytes("22341ae42d6dd7384bc8584e50419ea3ac75b83f")
- fmt.Printf("%x\n", crypto.Sha3(block.Coinbase))
+ fmt.Printf("%x\n", crypto.Keccak256(block.Coinbase))
bin := CreateBloom(block)
fmt.Printf("bin = %x\n", common.LeftPadBytes(bin, 64))
diff --git a/core/types/transaction.go b/core/types/transaction.go
index 0c9c1ce18..37715ee53 100644
--- a/core/types/transaction.go
+++ b/core/types/transaction.go
@@ -202,7 +202,7 @@ func doFrom(tx *Transaction, homestead bool) (common.Address, error) {
return common.Address{}, err
}
var addr common.Address
- copy(addr[:], crypto.Sha3(pubkey[1:])[12:])
+ copy(addr[:], crypto.Keccak256(pubkey[1:])[12:])
tx.from.Store(addr)
return addr, nil
}
diff --git a/core/vm/contracts.go b/core/vm/contracts.go
index f204432a2..5cc9f903b 100644
--- a/core/vm/contracts.go
+++ b/core/vm/contracts.go
@@ -111,7 +111,7 @@ func ecrecoverFunc(in []byte) []byte {
}
// the first byte of pubkey is bitcoin heritage
- return common.LeftPadBytes(crypto.Sha3(pubKey[1:])[12:], 32)
+ return common.LeftPadBytes(crypto.Keccak256(pubKey[1:])[12:], 32)
}
func memCpy(in []byte) []byte {
diff --git a/core/vm/instructions.go b/core/vm/instructions.go
index 26f7671ff..1e1086b13 100644
--- a/core/vm/instructions.go
+++ b/core/vm/instructions.go
@@ -316,7 +316,7 @@ func opMulmod(instr instruction, pc *uint64, env Environment, contract *Contract
func opSha3(instr instruction, pc *uint64, env Environment, contract *Contract, memory *Memory, stack *stack) {
offset, size := stack.pop(), stack.pop()
- hash := crypto.Sha3(memory.Get(offset.Int64(), size.Int64()))
+ hash := crypto.Keccak256(memory.Get(offset.Int64(), size.Int64()))
stack.push(common.BytesToBig(hash))
}
diff --git a/core/vm/jit.go b/core/vm/jit.go
index 504aab523..5404730c1 100644
--- a/core/vm/jit.go
+++ b/core/vm/jit.go
@@ -96,7 +96,7 @@ type Program struct {
// NewProgram returns a new JIT program
func NewProgram(code []byte) *Program {
program := &Program{
- Id: crypto.Sha3Hash(code),
+ Id: crypto.Keccak256Hash(code),
mapping: make(map[uint64]uint64),
destinations: make(map[uint64]struct{}),
code: code,
diff --git a/core/vm/jit_test.go b/core/vm/jit_test.go
index e8e078a46..4174c666f 100644
--- a/core/vm/jit_test.go
+++ b/core/vm/jit_test.go
@@ -189,7 +189,7 @@ func (self *Env) Db() Database { return nil }
func (self *Env) GasLimit() *big.Int { return self.gasLimit }
func (self *Env) VmType() Type { return StdVmTy }
func (self *Env) GetHash(n uint64) common.Hash {
- return common.BytesToHash(crypto.Sha3([]byte(big.NewInt(int64(n)).String())))
+ return common.BytesToHash(crypto.Keccak256([]byte(big.NewInt(int64(n)).String())))
}
func (self *Env) AddLog(log *Log) {
}
diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go
index 1fa06e980..565ce7b73 100644
--- a/core/vm/runtime/runtime.go
+++ b/core/vm/runtime/runtime.go
@@ -67,7 +67,7 @@ func setDefaults(cfg *Config) {
}
if cfg.GetHashFn == nil {
cfg.GetHashFn = func(n uint64) common.Hash {
- return common.BytesToHash(crypto.Sha3([]byte(new(big.Int).SetUint64(n).String())))
+ return common.BytesToHash(crypto.Keccak256([]byte(new(big.Int).SetUint64(n).String())))
}
}
}
diff --git a/core/vm/vm.go b/core/vm/vm.go
index 320135ff2..d45d136b5 100644
--- a/core/vm/vm.go
+++ b/core/vm/vm.go
@@ -58,7 +58,7 @@ func (self *Vm) Run(contract *Contract, input []byte) (ret []byte, err error) {
}
var (
- codehash = crypto.Sha3Hash(contract.Code) // codehash is used when doing jump dest caching
+ codehash = crypto.Keccak256Hash(contract.Code) // codehash is used when doing jump dest caching
program *Program
)
if EnableJit {
diff --git a/core/vm/vm_jit.go b/core/vm/vm_jit.go
index 07cb52d4a..589c30fa8 100644
--- a/core/vm/vm_jit.go
+++ b/core/vm/vm_jit.go
@@ -200,7 +200,7 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi
self.data.timestamp = self.env.Time()
self.data.code = getDataPtr(code)
self.data.codeSize = uint64(len(code))
- self.data.codeHash = hash2llvm(crypto.Sha3(code)) // TODO: Get already computed hash?
+ self.data.codeHash = hash2llvm(crypto.Keccak256(code)) // TODO: Get already computed hash?
jit := C.evmjit_create()
retCode := C.evmjit_run(jit, unsafe.Pointer(&self.data), unsafe.Pointer(self))
@@ -242,7 +242,7 @@ func (self *JitVm) Env() Environment {
//export env_sha3
func env_sha3(dataPtr *byte, length uint64, resultPtr unsafe.Pointer) {
data := llvm2bytesRef(dataPtr, length)
- hash := crypto.Sha3(data)
+ hash := crypto.Keccak256(data)
result := (*i256)(resultPtr)
*result = hash2llvm(hash)
}