AntonKueltz / fastecdsa

Python library for fast elliptic curve crypto
https://pypi.python.org/pypi/fastecdsa
The Unlicense
263 stars 76 forks source link

Scalar Inversion #73

Closed pausto closed 2 years ago

pausto commented 3 years ago

Is it possible to make fast number inversion? A -> A^-1 Thx

AntonKueltz commented 3 years ago

Can you provide more details? Do you want a function int -> int that computes the inverse of an integer in some field? That’s a bit out of scope for this library.

pausto commented 3 years ago

Can you provide more details? Do you want a function int -> int that computes the inverse of an integer in some field? That’s a bit out of scope for this library.

Yes that's right. You have an "Arbitrary Elliptic Curve Arithmetic" where you have point addition and multiplication. Finding the inverse element, I would refer to the same. This also applies to the theory of fields of curves, as does the very addition and multiplication of curves defined on them.

AntonKueltz commented 2 years ago

Computing the inverse of an integer in a field of integers mod p isn't elliptic curve arithmetic so it's not in scope for this library. If you can provide an example of what you mean in the context of elliptic curve operations I'm happy to re-open this issue.

Inverting a point on an elliptic curve would depend on the operation. For addition the inverse of P is just -P. For multiplication an inverse point doesn't really make sense because you can't multiply a point by another point. The inverse of the scalar x would just be e.g. x^-1 mod q where q is the curve order.