// Generate a random element in the group of all the elements in Z/nZ that
// has a multiplicative inverse.
Generate a random element in the group of all the elements in Z/nZ that
has a multiplicative inverse.
// Generate a random element in the group of all the elements in Z / nZ that // has a multiplicative inverse .
func GetRandomNumberInMultiplicativeGroup(n *big.Int, random io.Reader) (*big.Int, error) {
	r, err := rand.Int(random, n)
	if err != nil {
		return nil, err
	}
	zero := big.NewInt(0)
	one := big.NewInt(1)
	if zero.Cmp(r) == 0 || one.Cmp(new(big.Int).GCD(nil, nil, n, r)) != 0 {
		return GetRandomNumberInMultiplicativeGroup(n, random)
	}
	return r, nil
}
func GetRandomNumberInMultiplicativeGroup ( n * big . Int , random io . Reader ) ( * big . Int , error ) { r , err := rand . Int ( random , n ) if err != nil { return nil , err } zero := big . NewInt ( 0 ) one := big . NewInt ( 1 ) if zero . Cmp ( r ) == 0 || one . Cmp ( new ( big . Int ) . GCD ( nil , nil , n , r ) ) != 0 { return GetRandomNumberInMultiplicativeGroup ( n , random ) } return r , nil }
Generate a random element in the group of all the elements in Z/nZ that
has a multiplicative inverse.
Generate a random element in the group of all the elements in Z / nZ that has a multiplicative inverse .