Пример #1
0
func worker(c chan *[32]byte) {
	var seed, secret, public [32]byte

	slice := seed[:]
	rand.Read(slice)

	enc := make([]byte, blockSize*blockCount)
	raw := make([]byte, 8*blockCount)
	raw[0] = 0x12 // the network tag

	h := newHash()
	for {
		crypto.SecretFromSeed(&secret, &seed)
		crypto.PublicFromSecret(&public, &secret)

		// need to encode multiples of 8 bytes
		copy(raw[1:], public[:7])
		base58.Encode(enc, raw)

		for _, re := range res {
			if re.Match(enc[skip:]) {
				// clean hash state
				//h.Write(slice)
				//h.Sum(slice[:0])
				//h.Write(slice)

				c <- &secret
				return
			}
		}
		h.Write(slice)
		h.Sum(slice[:0])
	}
}
Пример #2
0
func benchmark(b *testing.B) {
	var seed, secret, public [32]byte

	slice := seed[:]

	enc := make([]byte, blockSize*blockCount)
	raw := make([]byte, 8*blockCount)
	raw[0] = 0x12 // the network tag

	h := newHash()
	for i := 0; i < b.N; i++ {
		crypto.SecretFromSeed(&secret, &seed)
		crypto.PublicFromSecret(&public, &secret)

		// need to encode base58 in multiples of 8 bytes
		copy(raw[1:], public[:7])
		base58.Encode(enc, raw)

		for _, re := range res {
			re.Match(enc[skip:])
		}

		h.Write(slice)
		h.Sum(slice[:0])
	}
}