Oh, doh, yes.

I should have looked at my implementation of mul before posting.

Thanks,

-- 
Raul

On Thu, Jan 30, 2014 at 1:02 PM, Pascal Jasmin <godspiral2...@yahoo.ca> wrote:
> Cliff Reiter's code uses a different algorithm than the python code (uses 
> jacobian coordinate transformation to avoid inverse mod calculation).  His 
> code can be found here (but his first link is a good intro): 
> http://webbox.lafayette.edu/~reiterc/j/vector/factor_ecj.html
>
> For the python implementation, you want to look at __mul__ .  __rmul__ I 
> believe just overloads the * operator perhaps for the right argument to *.
>
> The general overview of elyptic curve multiplication is that it involves 
> repeated doublings and additions.
>
> http://repl.it/languages/Python is a useful resource for figuring out python 
> code.  But here is the only part I had trouble understanding:
>
> leftmostbit =: 2&#.@:({. , 0 $~ 2 -~ #)@:(2&#. inv) NB. for some reason 
> divides msb by 2.
>
>
>
> ________________________________
> From: Raul Miller <rauldmil...@gmail.com>
> To: Programming forum <programm...@jsoftware.com>
> Sent: Thursday, January 30, 2014 12:32:59 PM
> Subject: Re: [Jprogramming] math requests
>
>
> I have been looking at this, and I did a straightforward conversion of
> the python code to J (not quite complete). And I have a couple issues
> I would like to talk through before proceeding (I've also not yet
> studied Cliff Reiter's code).
>
> First, I would like to quibble with what I assume is the underlying
> standards document. The value INFINITY behaves like a zero in the
> context of addition. That strikes me as a bit odd.
>
> Second, though, I would like to understand python's rules a bit better
> - what happens when one multiples a Point with integer?
>
> Specifically, consider this excerpt from
> https://github.com/warner/python-ecdsa/blob/master/ecdsa/ellipticcurve.py
> :
>
>   p192 = Point( c192, Gx, Gy, r )
>
>   # Checking against some sample computations presented
>   # in X9.62:
>
>   d = 651056770906015076056810763456358567190100156695615665659
>   Q = d * p192
>
> The definitions of p192 and d are trivial for me to translate:
>
>   p192=. (c192;Gx;Gy;r) conew 'Point'
>
>   d=. 651056770906015076056810763456358567190100156695615665659x
>
> But how do I translate Q?
>
> In the definition of Point, I saw the following bit of python:
>
>   def __rmul__( self, other ):
>     """Multiply a point by an integer."""
>
>     return self * other
>
> But if that is the relevant code, all it is telling me is that
> multiplication is defined in terms of multiplication - as far as I can
> see, there is no other definition for multiplying a Point and an
> integer, nor have I seen any constructor for constructing a Point from
> an integer.
>
> Before I spend too much time chasing down rabbit holes (I really
> should be working on some other issues), can someone explain to me
> what is supposed to happen here?
>
> Thanks,
>
> --
> Raul
>
>
> On Wed, Jan 29, 2014 at 11:35 AM, Pascal Jasmin <godspiral2...@yahoo.ca> 
> 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
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to