diff --git a/Gopkg.lock b/Gopkg.lock index 411d386f..3ad9b39c 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1,12 +1,6 @@ # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. -[[projects]] - branch = "master" - name = "github.com/aead/siphash" - packages = ["."] - revision = "e404fcfc888570cadd1610538e2dbc89f66af814" - [[projects]] branch = "master" name = "github.com/agl/ed25519" @@ -71,6 +65,12 @@ packages = ["."] revision = "dee3fe6eb0e98dc774a94fc231f85baf7c29d360" +[[projects]] + name = "github.com/dchest/siphash" + packages = ["."] + revision = "ca249f45189071f5d44dc6401334e3572037b9cb" + version = "v1.2.0" + [[projects]] branch = "master" name = "github.com/decred/base58" @@ -128,6 +128,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "746f7a4be4e049bc47a6d29b4fdb85c908c7da9e1983f856b26b69a218bfae80" + inputs-digest = "39581a6756a6344d0ccd461101b468d5d9df91892fe8cedd0b87aa0c49d38dc4" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 220cc9c8..249bf218 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -23,6 +23,10 @@ branch = "master" name = "github.com/dchest/blake256" +[[constraint]] + name = "github.com/dchest/siphash" + version = "1.2.0" + [[constraint]] branch = "master" name = "github.com/decred/base58" diff --git a/gcs/gcs.go b/gcs/gcs.go index a46249ee..cd8dd8b2 100644 --- a/gcs/gcs.go +++ b/gcs/gcs.go @@ -13,8 +13,8 @@ import ( "sort" "sync" - "github.com/aead/siphash" "github.com/dchest/blake256" + "github.com/dchest/siphash" "github.com/decred/dcrd/chaincfg/chainhash" ) @@ -38,7 +38,7 @@ var ( // KeySize is the size of the byte array required for key material for the // SipHash keyed hash function. -const KeySize = siphash.KeySize +const KeySize = 16 // uint64s implements sort.Interface for *[]uint64 type uint64s []uint64 @@ -92,8 +92,10 @@ func NewFilter(P uint8, key [KeySize]byte, data [][]byte) (*Filter, error) { // Insert the hash (modulo N*P) of each data element into a slice and // sort the slice. + k0 := binary.LittleEndian.Uint64(key[0:8]) + k1 := binary.LittleEndian.Uint64(key[8:16]) for _, d := range data { - v := siphash.Sum64(d, &key) % f.modulusNP + v := siphash.Hash(k0, k1, d) % f.modulusNP values = append(values, v) } sort.Sort((*uint64s)(&values)) @@ -241,7 +243,9 @@ func (f *Filter) Match(key [KeySize]byte, data []byte) bool { b := newBitReader(f.filterNData[4:]) // Hash our search term with the same parameters as the filter. - term := siphash.Sum64(data, &key) % f.modulusNP + k0 := binary.LittleEndian.Uint64(key[0:8]) + k1 := binary.LittleEndian.Uint64(key[8:16]) + term := siphash.Hash(k0, k1, data) % f.modulusNP // Go through the search filter and look for the desired value. var lastValue uint64 @@ -289,8 +293,10 @@ func (f *Filter) MatchAny(key [KeySize]byte, data [][]byte) bool { values = &vs } defer matchPool.Put(values) + k0 := binary.LittleEndian.Uint64(key[0:8]) + k1 := binary.LittleEndian.Uint64(key[8:16]) for _, d := range data { - v := siphash.Sum64(d, &key) % f.modulusNP + v := siphash.Hash(k0, k1, d) % f.modulusNP *values = append(*values, v) } sort.Sort((*uint64s)(values)) diff --git a/gcs/go.mod b/gcs/go.mod index 2f93d7f6..e820172e 100644 --- a/gcs/go.mod +++ b/gcs/go.mod @@ -1,8 +1,8 @@ module github.com/decred/dcrd/gcs require ( - github.com/aead/siphash v0.0.0-20170329201724-e404fcfc8885 github.com/dchest/blake256 v1.0.0 + github.com/dchest/siphash v1.2.0 github.com/decred/dcrd/blockchain/stake v1.0.1 github.com/decred/dcrd/chaincfg/chainhash v1.0.1 github.com/decred/dcrd/txscript v1.0.1 diff --git a/gcs/go.sum b/gcs/go.sum index 5a7bb14e..b7053a36 100644 --- a/gcs/go.sum +++ b/gcs/go.sum @@ -7,6 +7,8 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/blake256 v1.0.0 h1:6gUgI5MHdz9g0TdrgKqXsoDX+Zjxmm1Sc6OsoGru50I= github.com/dchest/blake256 v1.0.0/go.mod h1:xXNWCE1jsAP8DAjP+rKw2MbeqLczjI3TRx2VK+9OEYY= +github.com/dchest/siphash v1.2.0 h1:YWOShuhvg0GqbQpMa60QlCGtEyf7O7HC1Jf0VjdQ60M= +github.com/dchest/siphash v1.2.0/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= github.com/decred/base58 v1.0.0 h1:BVi1FQCThIjZ0ehG+I99NJ51o0xcc9A/fDKhmJxY6+w= github.com/decred/base58 v1.0.0/go.mod h1:LLY1p5e3g91byL/UO1eiZaYd+uRoVRarybgcoymu9Ks= github.com/decred/dcrd/chaincfg/chainhash v1.0.1 h1:0vG7U9+dSjSCaHQKdoSKURK2pOb47+b+8FK5q4+Je7M= diff --git a/go.mod b/go.mod index 0db2f309..54b2d4c6 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,6 @@ module github.com/decred/dcrd require ( - github.com/aead/siphash v0.0.0-20170329201724-e404fcfc8885 github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd github.com/btcsuite/goleveldb v1.0.0 @@ -9,6 +8,7 @@ require ( github.com/btcsuite/winsvc v1.0.0 github.com/davecgh/go-spew v1.1.0 github.com/dchest/blake256 v1.0.0 + github.com/dchest/siphash v1.2.0 github.com/decred/base58 v1.0.0 github.com/decred/dcrd/addrmgr v1.0.2 github.com/decred/dcrd/blockchain v1.0.1 @@ -23,7 +23,7 @@ require ( github.com/decred/dcrd/dcrec/secp256k1 v1.0.0 github.com/decred/dcrd/dcrjson v1.0.0 github.com/decred/dcrd/dcrutil v1.1.1 - github.com/decred/dcrd/gcs v1.0.1 + github.com/decred/dcrd/gcs v1.0.2 github.com/decred/dcrd/hdkeychain v1.1.0 github.com/decred/dcrd/mempool v1.0.1 github.com/decred/dcrd/mining v1.0.1 diff --git a/go.sum b/go.sum index 0093de20..b46cd82d 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/blake256 v1.0.0 h1:6gUgI5MHdz9g0TdrgKqXsoDX+Zjxmm1Sc6OsoGru50I= github.com/dchest/blake256 v1.0.0/go.mod h1:xXNWCE1jsAP8DAjP+rKw2MbeqLczjI3TRx2VK+9OEYY= +github.com/dchest/siphash v1.2.0 h1:YWOShuhvg0GqbQpMa60QlCGtEyf7O7HC1Jf0VjdQ60M= +github.com/dchest/siphash v1.2.0/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= github.com/decred/base58 v1.0.0 h1:BVi1FQCThIjZ0ehG+I99NJ51o0xcc9A/fDKhmJxY6+w= github.com/decred/base58 v1.0.0/go.mod h1:LLY1p5e3g91byL/UO1eiZaYd+uRoVRarybgcoymu9Ks= github.com/decred/dcrd/addrmgr v1.0.1 h1:2GLtE3o+4FCzjRMjK+Cc/gfgS7Vzv8jkz5gM4B4WygA=