Closed Taneb closed 6 years ago
@Taneb just a gentle reminder that you intended to resolve remaining issues. Or we can merge as is and restrict inputs of discrete logarithm to primitive roots only.
Sorry, I've been busier than I expected! :sweat_smile: Going to do some work on this tonight, though
I think we can introduce a newtype
newtype PrimitiveRoot n = PrimitiveRoot (Mod n)
and amend the signature of Math.NumberTheory.Moduli.PrimitiveRoot
to
isPrimitiveRoot
:: KnownNat n => Mod n -> Maybe (PrimitiveRoot n)
Consequently, discreteLogarithm
should allow only PrimitiveRoot
as its second argument,
discreteLogarithm :: (KnownNat m, Integral b) => Mod m -> PrimitiveRoot m -> Maybe b
This eliminates the current issue with logarithms by non-primitive base (Pollard's algorithm supposes that the base is primitive) without compromising performance or correctness.
Oooh, that's a good idea. I'll implement that this evening
@Taneb any chance to finish it soon?
Closing, superseded by #130. Anyway, thanks for you efforts.
Sorry I neglected this issue! I'm glad it's been solved by someone, I had... less time and headspace for this than I'd have liked
It was a pleasure to work with you at ZuriHac.
This is the work I started at ZuriHac. It implements Pollard's rho algorithm to compute the discrete logarithm. This has the deficiency that there are some solutions it cannot find, such as 2^x == 7 (mod 9), which I would like to resolve before this PR gets merged.