// Seed sets a new secret seed for PRNG.
511668
func (p *siprng) Seed(k [16]byte) {
	p.k0 = binary.LittleEndian.Uint64(k[0:8])
	p.k1 = binary.LittleEndian.Uint64(k[8:16])
	p.ctr = 1
}
1226059
func RandomPolynomial(seed int64) (Pol, error) {
	return DerivePolynomial(rand.New(rand.NewSource(seed)))
}
1205852
func Generate() string {
	rand.Seed(time.Now().UTC().UnixNano())

	cnpj := make([]int, 12)
	for i := 0; i < 12; i++ {
		cnpj[i] = rand.Intn(9)
	}
	checkDigit1 := computeCheckDigit(cnpj)
	cnpj = append(cnpj, checkDigit1)
	checkDigit2 := computeCheckDigit(cnpj)
	cnpj = append(cnpj, checkDigit2)

	var str string
	for _, value := range cnpj {
		str += strconv.Itoa(value)
	}
	return str
}
266212
func NewPcg64(seedH, seedL uint64) Pcg64 {
  lcg := lcglib.NewLcg128(Uint128{seedH, seedL})
  return Pcg64{NewPcg128x64(lcg, XslRr)}
}
779465
func (sr *Strrand) Generate(pattern string) (string, error) {
	result := ""
	g, err := sr.CreateGenerator(pattern)
	if err != nil {
		return result, err
	}
	return g.Generate(), nil
}
1348369
func BzzPrivateKeyFromConfig(conf *adapters.NodeConfig) (*ecdsa.PrivateKey, error) {
	// pad the seed key some arbitrary data as ecdsa.GenerateKey takes 40 bytes seed data
	privKeyBuf := append(crypto.FromECDSA(conf.PrivateKey), []byte{0x62, 0x7a, 0x7a, 0x62, 0x7a, 0x7a, 0x62, 0x7a}...)
	bzzPrivateKey, err := ecdsa.GenerateKey(crypto.S256(), bytes.NewReader(privKeyBuf))
	if err != nil {
		return nil, err
	}
	return bzzPrivateKey, nil
}
1252698
func prf10(result, secret, label, seed []byte) {
	hashSHA1 := sha1.New
	hashMD5 := md5.New

	labelAndSeed := make([]byte, len(label)+len(seed))
	copy(labelAndSeed, label)
	copy(labelAndSeed[len(label):], seed)

	s1, s2 := splitPreMasterSecret(secret)
	pHash(result, s1, labelAndSeed, hashMD5)
	result2 := make([]byte, len(result))
	pHash(result2, s2, labelAndSeed, hashSHA1)

	for i, b := range result2 {
		result[i] ^= b
	}
}
865515
func (p Prefixed) Generate() string {
	if p.Len == 0 {
		p.Len = PrefixedDefaultLen
	}

	if len(p.Acceptable) == 0 {
		p.Acceptable = PrefixedDefaultAcceptable
	}

	if p.RandGenerator == nil {
		p.RandGenerator = rand.Reader
	}

	builder := bytes.NewBufferString(p.Prefix)

	max := big.NewInt(int64(len(p.Acceptable)))

	for i := uint8(0); i < p.Len; i++ {
		result, err := rand.Int(p.RandGenerator, max)
		if err != nil {
			panic(err)
		}
		builder.WriteRune(p.Acceptable[result.Int64()])
	}
	return builder.String()
}
43664
func (m *MT19937) SeedArray(initKey [NN]uint64) {
	var i, j uint64

	m.Seed(19650218)
	i = 1
	j = 0

	k := NN
	if NN <= len(initKey) {
		k = len(initKey)
	}

	for ; k != 0; k-- {
		m.mt[i] = (m.mt[i] ^ ((m.mt[i-1] ^ (m.mt[i-1] >> 62)) * 3935559000370003845)) + initKey[j] + j /* non linear */

		i++
		j++
		if i >= NN {
			m.mt[0] = m.mt[NN-1]
			i = 1
		}
		if j >= uint64(len(initKey)) {
			j = 0
		}
	}

	for k = NN - 1; k != 0; k-- {
		m.mt[i] = (m.mt[i] ^ ((m.mt[i-1] ^ (m.mt[i-1] >> 62)) * 2862933555777941757)) - i /* non linear */
		i++
		if i >= NN {
			m.mt[0] = m.mt[NN-1]
			i = 1
		}
	}

	m.mt[0] = 1 << 63 /* MSB is 1; assuring non-zero initial array */
}
1347191
func New64WithSeed(seed uint32) hash.Hash64 {
	d := (*digest64)(New128WithSeed(seed).(*digest128))
	return d
}
1350824
func Seed(seed int64) {
	if seed == 0 {
		rand.Seed(time.Now().UTC().UnixNano())
	} else {
		rand.Seed(seed)
	}
}
305960
func NewGenerator() (*Generator, error) {
	var g Generator
	_, err := rand.Read(g.seed[:])
	if err != nil {
		return nil, errors.New("cannot generate random seed: " + err.Error())
	}
	return &g, nil
}
851776
func NewPcg32(seed uint64) Pcg32 {
  lcg := lcglib.NewLcg64(seed)
  return Pcg32{NewPcg64x32(lcg, XshRr)}
}
235563
func nextRand(seed int64) func(int) int {
	r := rand.New(rand.NewSource(seed))

	return func(numPeers int) int {
		if numPeers == 0 {
			return 0
		}
		return r.Intn(numPeers)
	}
}
1196022
func ValidateSeed(seed Trytes) Validatable {
	return func() error {
		if !IsTrytesOfExactLength(seed, HashTrytesSize) {
			return ErrInvalidSeed
		}
		return nil
	}
}
816497
func (c *cache) generate(dir string, limit int, test bool) {
	c.once.Do(func() {
		size := cacheSize(c.epoch*epochLength + 1)
		seed := seedHash(c.epoch*epochLength + 1)
		if test {
			size = 1024
		}
		// If we don't store anything on disk, generate and return.
		if dir == "" {
			c.cache = make([]uint32, size/4)
			generateCache(c.cache, c.epoch, seed)
			return
		}
		// Disk storage is needed, this will get fancy
		var endian string
		if !isLittleEndian() {
			endian = ".be"
		}
		path := filepath.Join(dir, fmt.Sprintf("cache-R%d-%x%s", algorithmRevision, seed[:8], endian))
		logger := log.New("epoch", c.epoch)

		// We're about to mmap the file, ensure that the mapping is cleaned up when the
		// cache becomes unused.
		runtime.SetFinalizer(c, (*cache).finalizer)

		// Try to load the file from disk and memory map it
		var err error
		c.dump, c.mmap, c.cache, err = memoryMap(path)
		if err == nil {
			logger.Debug("Loaded old ethash cache from disk")
			return
		}
		logger.Debug("Failed to load old ethash cache", "err", err)

		// No previous cache available, create a new cache file to fill
		c.dump, c.mmap, c.cache, err = memoryMapAndGenerate(path, size, func(buffer []uint32) { generateCache(buffer, c.epoch, seed) })
		if err != nil {
			logger.Error("Failed to generate mapped ethash cache", "err", err)

			c.cache = make([]uint32, size/4)
			generateCache(c.cache, c.epoch, seed)
		}
		// Iterate over all previous instances and delete old ones
		for ep := int(c.epoch) - limit; ep >= 0; ep-- {
			seed := seedHash(uint64(ep)*epochLength + 1)
			path := filepath.Join(dir, fmt.Sprintf("cache-R%d-%x%s", algorithmRevision, seed[:8], endian))
			os.Remove(path)
		}
	})
}
1264019
func NewRandomGenerator(seed string) *RandomGenerator {
	hasher := md5.New()
	hasher.Write([]byte(seed))
	sint := int64(binary.BigEndian.Uint64(hasher.Sum(nil)))
	source := rand.NewSource(sint)
	ran := rand.New(source)
	faker := &faker.Faker{
		Language: "end",
		Dict:     faker.Dict["en"],
		Rand:     ran,
	}
	return &RandomGenerator{
		Seed:  seed,
		faker: faker,
		rand:  ran,
	}
}