Loading pkg/core/hashring.go +6 −6 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ type RootKey hash.Hash // BucketKey is the hmac key derived from RootKey for a specific distributor type BucketKey struct { bucketKey hash.Hash bucketKey []byte } func NewRootKey(secretKey string) RootKey { Loading @@ -62,16 +62,16 @@ func NewRootKey(secretKey string) RootKey { func NewBucketKey(secret string, distName string) BucketKey { rootKey := NewRootKey(secret) rootKey.Write([]byte(distName)) bucketKey := rootKey.Sum(nil) return BucketKey{ bucketKey: hmac.New(sha256.New, bucketKey), bucketKey: rootKey.Sum(nil), } } func (b *BucketKey) NewBucketHash(usrBytes []byte) Hashkey { b.bucketKey.Reset() b.bucketKey.Write(usrBytes) h := b.bucketKey.Sum(nil) bucketHash := hmac.New(sha256.New, b.bucketKey) bucketHash.Reset() bucketHash.Write(usrBytes) h := bucketHash.Sum(nil) return Hashkey(binary.BigEndian.Uint64(h[:8])) } Loading Loading
pkg/core/hashring.go +6 −6 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ type RootKey hash.Hash // BucketKey is the hmac key derived from RootKey for a specific distributor type BucketKey struct { bucketKey hash.Hash bucketKey []byte } func NewRootKey(secretKey string) RootKey { Loading @@ -62,16 +62,16 @@ func NewRootKey(secretKey string) RootKey { func NewBucketKey(secret string, distName string) BucketKey { rootKey := NewRootKey(secret) rootKey.Write([]byte(distName)) bucketKey := rootKey.Sum(nil) return BucketKey{ bucketKey: hmac.New(sha256.New, bucketKey), bucketKey: rootKey.Sum(nil), } } func (b *BucketKey) NewBucketHash(usrBytes []byte) Hashkey { b.bucketKey.Reset() b.bucketKey.Write(usrBytes) h := b.bucketKey.Sum(nil) bucketHash := hmac.New(sha256.New, b.bucketKey) bucketHash.Reset() bucketHash.Write(usrBytes) h := bucketHash.Sum(nil) return Hashkey(binary.BigEndian.Uint64(h[:8])) } Loading