Commit 28baa309 authored by David Vorick's avatar David Vorick

switch hashing algo to blake2

parent d38338ca
......@@ -63,6 +63,7 @@ dependencies:
go install -race std
go get -u code.google.com/p/gcfg
go get -u github.com/agl/ed25519
go get -u github.com/codahale/blake2
go get -u github.com/inconshreveable/go-update
go get -u github.com/laher/goxc
go get -u github.com/mitchellh/go-homedir
......
package hash
import (
"crypto/sha256"
"github.com/NebulousLabs/Sia/encoding"
"github.com/codahale/blake2"
)
const (
......@@ -14,8 +14,12 @@ type (
Hash [HashSize]byte
)
func HashBytes(data []byte) Hash {
return sha256.Sum256(data)
func HashBytes(data []byte) (hash Hash) {
hasher := blake2.New(&blake2.Config{Size: HashSize})
hasher.Write(data)
sum := hasher.Sum(nil)
copy(hash[:], sum)
return
}
func HashObject(obj interface{}) Hash {
......
......@@ -60,7 +60,7 @@ func uniformTreeVerification(hdb *HostDB, numEntries int, t *testing.T) {
// verifies that the tree stays consistent through the adjustments.
func TestWeightedList(t *testing.T) {
// Create a hostdb and 3 equal entries to insert.
hdb, err := New(consensus.CreateGenesisState())
hdb, err := New(consensus.CreateGenesisState(consensus.GenesisTimestamp))
if err != nil {
t.Fatal(err)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment