package spectre import "golang.org/x/crypto/scrypt" func userKey(name, secret string, scoper Scoper) ([]byte, error) { nameBytes := []byte(name) secretBytes := []byte(secret) keyScope := []byte(scoper.Scope(Authentication)) nameBytesLen := len(nameBytes) keySalt := append(keyScope, byte(nameBytesLen>>24), byte(nameBytesLen>>16), byte(nameBytesLen>>8), byte(nameBytesLen), ) keySalt = append(keySalt, nameBytes...) return scrypt.Key(secretBytes, keySalt, 32768, 8, 2, 64) }