Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current code had the following bugs:
y
coordinate it took the bytes serialization of the point and interpreted it as they
coordinate, ignoring the fact that the serialization encodes the parity bit of thex
coordinate in the most significant bit (which is the reason djb made the field elements are 255 bits)x
coordinate there was a bug inxrecover
using(q-3)/4
instead of(q-1)/4
.x
coordinate it did not flip it to the right parity using the parity bit.I generated test vectors using https://github.com/dalek-cryptography/curve25519-dalek and fixed the issues making the test pass.
references:
https://ed25519.cr.yp.to/python/ed25519.py
https://datatracker.ietf.org/doc/html/rfc8032#section-5.1.3
https://github.com/dalek-cryptography/curve25519-dalek/blob/076cf34/src/edwards.rs#L193
https://github.com/dalek-cryptography/curve25519-dalek/blob/076cf34/src/edwards.rs#L518
https://github.com/dalek-cryptography/curve25519-dalek/blob/076cf34/src/field.rs#L229