-
Notifications
You must be signed in to change notification settings - Fork 219
Batch Conversion of Projective -> Affine Points #943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Regarding the algorithm: The Jacobian coordinates of an elliptic curve point If we wish to convert many points at once, then we have to compute the inverse of There is a trick for computing many modular inverses at once, often called "Montgomery's trick", which reduces the problem of computing So the batch conversion works by applying Montgomery's trick to reduce the There is an implementation of this technique in C++ here that demonstrates how it all comes together. |
Thanks! |
@tarcieri so the Montgomery trick for efficient simultaneous inversion is generic for inversion in a prime field, (actually even for any field in which the numbers have an inverse), and is not limited to projective->affine nor to secp256k1. Should we design a generic function that takes a sequence of elements and returns a sequence of their inverses, given an Also, we would then need to call this from a simultaneous Thoughts on this, or should I do a PR with my intended design? |
A generic implementation in either Perhaps this is also worth discussing having a trait for in |
Will try to get a PR for this today, max tomorrow, so it'll be in the next release |
The PR for batch inversion is ready for review, I am now thinking how to do batch affine conversion: unlike
|
A trait-based approach is great. You can use your branch by editing this repo's toplevel Cargo.toml and adding: [patch.crates-io]
elliptic-curve = { git = "https://github.com/ycscaly/traits", branch = "batch_invert" } It would definitely be great to see working tests against |
This gives error: |
@tarcieri the reason is version incompatibility. |
No? https://github.com/RustCrypto/traits/blob/aa21684/elliptic-curve/Cargo.toml#L3 I think you're doing something wrong. I can push up a branch if that's helpful. |
Here you go. Works for me: master...use-elliptic-curve-from-git |
Sorry, my problem was that I was working on an out of date version of |
#971 closed this |
@tarcieri I stumbled of what I think is a bug (or at the least, unclear documentation). In
points . However, that element can also be zero, which in turn leads to a panic as the unwrap in
|
Yeah, that seems busted. The comment refers to using @ycscaly can you open a new issue (or PR) for this? |
I'm really not sure what happened here. I originally wrote the code in that way so that the array was initialized to |
Ok, I managed to get it to panic again (using @tarcieri if this is truly the problem, I wouldn't even say this is an error in Is this intended? if not, it should be fixed. If it is indeed, I'll change |
Please open a PR to fix the issue. Re: issues with non-normalized/lazy field elements, really what would help is making separate types for normalized vs lazy field elements, like |
Done #1029 |
Uh oh!
There was an error while loading. Please reload this page.
In #937 I explained how expensive the
to_affine()
function is ink256
, and how it can become a bottleneck in certain situations. My suggestion to expose the projective coordinates got some backfire:Instead, the suggestion was to have a batch conversion:
Originally posted by @randombit in #937 (comment)
I am for this, and wondering:
The text was updated successfully, but these errors were encountered: