Add the file elliptic.R
to the R
subdirectory of your project.
Implement the function ecAddModp
as described in the
documentation. Since this function is intended to be used for Lenstra’s
algorithm, we need it to print a warning if either of the inverse
calculations fail (which should sometimes happen if the modulus is not
prime). See ?warning
for details on how to print a
warning.
Implement ecNegModp
as specified.
Implement ecPowModp
as specified. This needs to be
an elliptic curve version of the qPower
function from
the notes, using repeated “squaring” (doubling). Otherwise it will
be too slow. It only needs to work for nonnegative exponents. The given
examples should run quickly:
> system.time(ecPowModp(3, 45, 8831, c(4,11), as.bigz("2349089023472938409283490823")))
user system elapsed
0.033 0.000 0.033