func deriveIntegerGroupFromOrder(groupOrder *big.Int) (*IntegerGroupParams, error) {
	result := &IntegerGroupParams{
		GroupOrder: groupOrder,
	}

	for i := uint32(1); i < maxPrimeGenerationAttempts; i++ {
		result.Modulus = new(big.Int).Mul(result.GroupOrder, big.NewInt(int64(i*2)))
		result.Modulus.Add(result.Modulus, bigOne)

		if result.Modulus.ProbablyPrime(128) {
			seed := calculateSeed(groupOrder, "", 128, "")
			pSeed := calculateHash(HashToBig(&seed))
			qSeed := calculateHash(pSeed)
			pSeedHash, _ := BigToHash(pSeed)
			qSeedHash, _ := BigToHash(qSeed)
			generator1, err := calculateGroupGenerator(&seed, pSeedHash, qSeedHash, result.Modulus, result.GroupOrder, 1)
			if err != nil {
				return nil, err
			}
			generator2, err := calculateGroupGenerator(&seed, pSeedHash, qSeedHash, result.Modulus, result.GroupOrder, 2)
			if err != nil {
				return nil, err
			}

			result.G = generator1
			result.H = generator2

			if !result.Modulus.ProbablyPrime(40) {
				return nil, errors.New("generated non-prime modulus")
			}

			if !result.GroupOrder.ProbablyPrime(40) {
				return nil, errors.New("generated non-prime group order")
			}

			if new(big.Int).Exp(result.G, result.GroupOrder, result.Modulus).Cmp(bigOne) != 0 {
				return nil, errors.New("G^order mod modulus != 1")
			}

			if new(big.Int).Exp(result.H, result.GroupOrder, result.Modulus).Cmp(bigOne) != 0 {
				return nil, errors.New("H^order mod modulus != 1")
			}

			if new(big.Int).Exp(result.G, big.NewInt(100), result.Modulus).Cmp(bigOne) == 0 {
				return nil, errors.New("G^100 mod modulus != 1")
			}

			if new(big.Int).Exp(result.H, big.NewInt(100), result.Modulus).Cmp(bigOne) == 0 {
				return nil, errors.New("H^100 mod modulus != 1")
			}

			if result.G.Cmp(result.H) == 0 {
				return nil, errors.New("H == G")
			}

			if result.G.Cmp(bigOne) == 0 {
				return nil, errors.New("G == 1")
			}

			return result, nil
		}
	}

	return nil, errors.New("too many attempts to generate schnorr group")
}
// deriveIntegerGroupFromOrder calculates the description of a group G of a specific
// prime order embedded within a field.
deriveIntegerGroupFromOrder calculates the description of a group G of a specific
prime order embedded within a field.
// deriveIntegerGroupFromOrder calculates the description of a group G of a specific // prime order embedded within a field .
func deriveIntegerGroupFromOrder(groupOrder *big.Int) (*IntegerGroupParams, error) {
	result := &IntegerGroupParams{
		GroupOrder: groupOrder,
	}
	for i := uint32(1); i < maxPrimeGenerationAttempts; i++ {
		result.Modulus = new(big.Int).Mul(result.GroupOrder, big.NewInt(int64(i*2)))
		result.Modulus.Add(result.Modulus, bigOne)
		if result.Modulus.ProbablyPrime(128) {
			seed := calculateSeed(groupOrder, "", 128, "")
			pSeed := calculateHash(HashToBig(&seed))
			qSeed := calculateHash(pSeed)
			pSeedHash, _ := BigToHash(pSeed)
			qSeedHash, _ := BigToHash(qSeed)
			generator1, err := calculateGroupGenerator(&seed, pSeedHash, qSeedHash, result.Modulus, result.GroupOrder, 1)
			if err != nil {
				return nil, err
			}
			generator2, err := calculateGroupGenerator(&seed, pSeedHash, qSeedHash, result.Modulus, result.GroupOrder, 2)
			if err != nil {
				return nil, err
			}
			result.G = generator1
			result.H = generator2
			if !result.Modulus.ProbablyPrime(40) {
				return nil, errors.New("generated non-prime modulus")
			}
			if !result.GroupOrder.ProbablyPrime(40) {
				return nil, errors.New("generated non-prime group order")
			}
			if new(big.Int).Exp(result.G, result.GroupOrder, result.Modulus).Cmp(bigOne) != 0 {
				return nil, errors.New("G^order mod modulus != 1")
			}
			if new(big.Int).Exp(result.H, result.GroupOrder, result.Modulus).Cmp(bigOne) != 0 {
				return nil, errors.New("H^order mod modulus != 1")
			}
			if new(big.Int).Exp(result.G, big.NewInt(100), result.Modulus).Cmp(bigOne) == 0 {
				return nil, errors.New("G^100 mod modulus != 1")
			}
			if new(big.Int).Exp(result.H, big.NewInt(100), result.Modulus).Cmp(bigOne) == 0 {
				return nil, errors.New("H^100 mod modulus != 1")
			}
			if result.G.Cmp(result.H) == 0 {
				return nil, errors.New("H == G")
			}
			if result.G.Cmp(bigOne) == 0 {
				return nil, errors.New("G == 1")
			}
			return result, nil
		}
	}
	return nil, errors.New("too many attempts to generate schnorr group")
}
func deriveIntegerGroupFromOrder ( groupOrder * big . Int ) ( * IntegerGroupParams , error ) { result := & IntegerGroupParams { GroupOrder : groupOrder , } for i := uint32 ( 1 ) ; i < maxPrimeGenerationAttempts ; i ++ { result . Modulus = new ( big . Int ) . Mul ( result . GroupOrder , big . NewInt ( int64 ( i * 2 ) ) ) result . Modulus . Add ( result . Modulus , bigOne ) if result . Modulus . ProbablyPrime ( 128 ) { seed := calculateSeed ( groupOrder , " " , 128 , " " ) pSeed := calculateHash ( HashToBig ( & seed ) ) qSeed := calculateHash ( pSeed ) pSeedHash , _ := BigToHash ( pSeed ) qSeedHash , _ := BigToHash ( qSeed ) generator1 , err := calculateGroupGenerator ( & seed , pSeedHash , qSeedHash , result . Modulus , result . GroupOrder , 1 ) if err != nil { return nil , err } generator2 , err := calculateGroupGenerator ( & seed , pSeedHash , qSeedHash , result . Modulus , result . GroupOrder , 2 ) if err != nil { return nil , err } result . G = generator1 result . H = generator2 if ! result . Modulus . ProbablyPrime ( 40 ) { return nil , errors . New ( " " ) } if ! result . GroupOrder . ProbablyPrime ( 40 ) { return nil , errors . New ( " " ) } if new ( big . Int ) . Exp ( result . G , result . GroupOrder , result . Modulus ) . Cmp ( bigOne ) != 0 { return nil , errors . New ( " " ) } if new ( big . Int ) . Exp ( result . H , result . GroupOrder , result . Modulus ) . Cmp ( bigOne ) != 0 { return nil , errors . New ( " " ) } if new ( big . Int ) . Exp ( result . G , big . NewInt ( 100 ) , result . Modulus ) . Cmp ( bigOne ) == 0 { return nil , errors . New ( " " ) } if new ( big . Int ) . Exp ( result . H , big . NewInt ( 100 ) , result . Modulus ) . Cmp ( bigOne ) == 0 { return nil , errors . New ( " " ) } if result . G . Cmp ( result . H ) == 0 { return nil , errors . New ( " " ) } if result . G . Cmp ( bigOne ) == 0 { return nil , errors . New ( " " ) } return result , nil } } return nil , errors . New ( " " ) }
deriveIntegerGroupFromOrder calculates the description of a group G of a specific
prime order embedded within a field.
deriveIntegerGroupFromOrder calculates the description of a group G of a specific prime order embedded within a field .