// GetGeneratorOfZnSubgroup returns a generator of a subgroup of a specified order in Z_n.
// Parameter groupOrder is order of Z_n (if n is prime, order is n-1).
GetGeneratorOfZnSubgroup returns a generator of a subgroup of a specified order in Z_n.
Parameter groupOrder is order of Z_n (if n is prime, order is n-1).
// GetGeneratorOfZnSubgroup returns a generator of a subgroup of a specified order in Z_n . // Parameter groupOrder is order of Z_n ( if n is prime order is n - 1 ) .
func GetGeneratorOfZnSubgroup(n, groupOrder, subgroupOrder *big.Int) (*big.Int, error) {
	if big.NewInt(0).Mod(groupOrder, subgroupOrder).Cmp(big.NewInt(0)) != 0 {
		err := fmt.Errorf("subgroupOrder does not divide groupOrder")
		return nil, err
	}
	r := new(big.Int).Div(groupOrder, subgroupOrder)
	for {
		h := GetRandomInt(n)
		g := new(big.Int)
		g.Exp(h, r, n)
		if g.Cmp(big.NewInt(1)) != 0 {
			return g, nil
		}
	}
}
func GetGeneratorOfZnSubgroup ( n , groupOrder , subgroupOrder * big . Int ) ( * big . Int , error ) { if big . NewInt ( 0 ) . Mod ( groupOrder , subgroupOrder ) . Cmp ( big . NewInt ( 0 ) ) != 0 { err := fmt . Errorf ( " " ) return nil , err } r := new ( big . Int ) . Div ( groupOrder , subgroupOrder ) for { h := GetRandomInt ( n ) g := new ( big . Int ) g . Exp ( h , r , n ) if g . Cmp ( big . NewInt ( 1 ) ) != 0 { return g , nil } } }
GetGeneratorOfZnSubgroup returns a generator of a subgroup of a specified order in Z_n.
GetGeneratorOfZnSubgroup returns a generator of a subgroup of a specified order in Z_n .