Post
Topic
Board Development & Technical Discussion
Re: Elliptic curve point multiplication
by
someone42
on 01/05/2012, 05:37:50 UTC
I don't suppose anyone here knows php and modular arithmetic well enough to tell me what is wrong with my modular inversion code... It works with positive values, but not negative values.

The problem is probably originating from one of the calls to bcmod(). I don't know how php's bignum library does it, but modulus functions in any language can produce unexpected results when one of the operands is negative. You could workaround this by adding $m to $a (if $a is negative) in modinv().