<commit_before><commit_msg>adding testing generator for cyclic group<commit_after>package main

import (
	"crypto/rand"
	"fmt"
	"math/big"
	"sync"
)

func gen(n, prob int) (*big.Int, *big.Int, *big.Int) {
	for {
		q, err := rand.Prime(rand.Reader, n-1)
		if err != nil {
			panic(err.Error())
		}
		n := new(big.Int).Mul(q, big.NewInt(2))
		p := new(big.Int).Add(n, big.NewInt(1))
		// p = 2q + 1, order(p) = n = 2q
		if p.ProbablyPrime(prob) {
			for {
				a, err := rand.Int(rand.Reader, p)
				if err != nil {
					panic(err.Error())
				}
				if b := new(big.Int).Exp(a, big.NewInt(2), p); b.Cmp(big.NewInt(1)) == 0 {
					continue
				}
				if b := new(big.Int).Exp(a, q, p); b.Cmp(big.NewInt(1)) == 0 {
					return p, q, a
				}
			}
		}
	}
	return nil, nil, nil
}

var mutex = &sync.Mutex{}

func printPrimes(n, prob int) {
	fmt.Println("start...")
	p, q, g := gen(n, prob)
	mutex.Lock()
	fmt.Println("p = ", p)
	fmt.Println("q = ", q)
	fmt.Println("g = ", g)
	mutex.Unlock()
}

func main() {

	result := make(chan *big.Int)
	threads := 4

	for i := 0; i < threads; i++ {
		go func() {
			p, q, g := gen(1024, 64)
			mutex.Lock()
			result <- p
			result <- q
			result <- g
			mutex.Unlock()
		}()
	}
	for i := 0; i < threads; i++ {
		fmt.Println("p = ", <-result)
		fmt.Println("q = ", <-result)
		fmt.Println("g = ", <-result)
	}
}
{'fraction_non_alphanumeric': 0.2184936614466816, 'fraction_numerical': 0.014914243102162566, 'mean_word_length': 2.559681697612732, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4562332', 'n_tokens_mistral': 675, 'n_tokens_neox': 586, 'n_words': 135}