For modular inverses in teaching I use
gcd2x=: 3 : 0
'r0 r1'=.y
's0 s1'=.1 0
't0 t1'=.0 1
while. r1 ~: 0 do.
q=. <. r0 % r1
'r0 r1'=. r1,r0-q*r1
's0 s1'=. s1,s0-q*s1
't0 t1'=. t1,t0-q*t1
end.
r0,s0,t0
)
invmod=: 4 : 'y| {: gcd2x y,x'
5 invmod 21
17
21|5*17
1
Best, Cliff
On 1/29/2014 11:35 AM, Pascal Jasmin wrote:
With all of the mathematicians on this list, these functions have likely been
implemented before in J.
elyptic curve point add, multiplication and double
a python reference implementation:
https://github.com/warner/python-ecdsa/blob/master/ecdsa/ellipticcurve.py
the functions are: __add__ __mul__ and double
if I may suggest J explicit signatures for the first 2 functions as:
F =: 4 : 0
'yx yy yo' =. y
'xx xy xo' =. x
)
Some other methods than the python reference could be considered here:
http://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication
also appreciated if you have in implementation of inverse_mod
for reference function of same nate at:
https://github.com/warner/python-ecdsa/blob/master/ecdsa/numbertheory.py
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
Clifford A. Reiter
Lafayette College, Easton, PA 18042
http://webbox.lafayette.edu/~reiterc/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm