diff --git a/internal/lib/lib.go b/internal/lib/lib.go index 2297625..fa0eab7 100644 --- a/internal/lib/lib.go +++ b/internal/lib/lib.go @@ -161,12 +161,11 @@ func PrimitiveRootFast(modulus *big.Int, tpf map[string]*big.Int) (*big.Int, err isPrimitive := true for p := range tpf { - e := new(big.Int) - f, _ := new(big.Int).SetString(p, 10) - k := new(big.Int).Div(phi, f) - e.Exp(g, k, modulus) - - if e.Cmp(big.NewInt(1)) == 0 { + // we already know factors are valid from computing phi + k, _ := new(big.Int).SetString(p, 10) + k.Div(phi, k) + k.Exp(g, k, modulus) + if k.Cmp(big.NewInt(1)) == 0 { isPrimitive = false break }