aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/crypto.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-17 00:27:24 +0800
committerFelix Lange <fjl@twurst.com>2015-03-17 00:27:24 +0800
commit64490897f3d7689fcd49dd3ae94b2b307f59b6cb (patch)
tree24089bc200c22faf0f6ee11cab9695f0fa7a9047 /crypto/crypto.go
parente620bde405161771ea7ecd1cee8641eb9265465e (diff)
downloaddexon-64490897f3d7689fcd49dd3ae94b2b307f59b6cb.tar
dexon-64490897f3d7689fcd49dd3ae94b2b307f59b6cb.tar.gz
dexon-64490897f3d7689fcd49dd3ae94b2b307f59b6cb.tar.bz2
dexon-64490897f3d7689fcd49dd3ae94b2b307f59b6cb.tar.lz
dexon-64490897f3d7689fcd49dd3ae94b2b307f59b6cb.tar.xz
dexon-64490897f3d7689fcd49dd3ae94b2b307f59b6cb.tar.zst
dexon-64490897f3d7689fcd49dd3ae94b2b307f59b6cb.zip
crypto: add Sha3Hash
Diffstat (limited to 'crypto/crypto.go')
-rw-r--r--crypto/crypto.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go
index bc72928ac..1f8dfcf32 100644
--- a/crypto/crypto.go
+++ b/crypto/crypto.go
@@ -16,10 +16,10 @@ import (
"errors"
"code.google.com/p/go-uuid/uuid"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto/ecies"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
"github.com/ethereum/go-ethereum/crypto/sha3"
- "github.com/ethereum/go-ethereum/common"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/ripemd160"
)
@@ -37,6 +37,15 @@ func Sha3(data ...[]byte) []byte {
return d.Sum(nil)
}
+func Sha3Hash(data ...[]byte) (h common.Hash) {
+ d := sha3.NewKeccak256()
+ for _, b := range data {
+ d.Write(b)
+ }
+ d.Sum(h[:])
+ return h
+}
+
// Creates an ethereum address given the bytes and the nonce
func CreateAddress(b []byte, nonce uint64) []byte {
return Sha3(common.NewValue([]interface{}{b, nonce}).Encode())[12:]