func NewElGamal(modulusLength int) (*ElGamal, error) {
	p, err := GetSafePrime(modulusLength)
	if err != nil {
		return nil, fmt.Errorf("failed to generate safe prime")
	}
	zero := big.NewInt(0)
	one := big.NewInt(1)
	two := big.NewInt(2)
	three := big.NewInt(3)
	q := new(big.Int).Sub(p, one)
	q.Div(q, two)
	var g *big.Int
	sampler := sample.NewUniformRange(three, p)
	for {
		g, err = sampler.Sample()
		if err != nil {
			return nil, err
		}
		g.Exp(g, two, p)
		if new(big.Int).Mod(new(big.Int).Sub(p, one), g).Cmp(zero) == 0 {
			continue
		}
		gInv := new(big.Int).ModInverse(g, p)
		if new(big.Int).Mod(new(big.Int).Sub(p, one), gInv).Cmp(zero) == 0 {
			continue
		}
		break
	}
	x, err := sampler.Sample()
	if err != nil {
		return nil, err
	}
	y := new(big.Int).Exp(g, x, p)
	return &ElGamal{
		Y: y,
		G: g,
		P: p,
		Q: q,
	}, nil
}
NewElGamal creates parameters for ElGamal scheme. Implementation is
adapted from https://github.com/dlitz/pycrypto/blob/master/lib/Crypto/PublicKey/ElGamal.py.
package keygen
import (
	"fmt"
	"math/big"
	"github.com/fentec-project/gofe/sample"
)
type ElGamal struct {
	Y *big.Int  
	G *big.Int  
	P *big.Int  
	Q *big.Int  
}