This implements a generalization of Peter Dettman’s sqrt-less x-only random-base multiplication algorithm from #262, using the Jacobi symbol algorithm from #979. The generalization is to permit the X coordinate of the base point to be specified as a fraction $n/d$:
To compute $x(q \cdot P)$, where $x(P) = n/d$:
- Compute $g=n^3 + 7d^3$.
- Let $P’ = (ng, g^2, 1)$ (the Jacobian coordinates of $P$ mapped to the isomorphic curve $y^2 = x^3 + 7(dg)^3$).
- Compute the Jacobian coordinates $(X’,Y’,Z’) = q \cdot P’$ on the isomorphic curve.
- Return $X’/(dgZ’^2)$, which is the affine x coordinate on the isomorphic curve $X/Z’^2$ mapped back to secp256k1.
This ability to specify the X coordinate as a fraction is useful in the context of x-only Elligator Swift, which can decode to X coordinates on the curve without inversions this way.