Пример #1
0
// Shuffle takes a (private) seed and a (possibly public) label and produces a random shuffle of the integers [0, 16).
func (rs *RandomSource) Shuffle(label []byte) encoding.Shuffle {
	key := [16]byte{}
	copy(key[:], label)

	cached, ok := rs.encodingCache[key]

	if ok {
		return cached
	} else {
		rs.encodingCache[key] = encoding.GenerateShuffle(rs.Stream(label))
		return rs.encodingCache[key]
	}
}
Пример #2
0
func getShuffle(seed, label []byte) encoding.Shuffle {
	key := [32]byte{}
	copy(key[0:16], seed)
	copy(key[16:32], label)

	cached, ok := encodingCache[key]

	if ok {
		return cached
	} else {
		encodingCache[key] = encoding.GenerateShuffle(generateStream(seed, label))
		return encodingCache[key]
	}
}