Repository navigation
Conversation
RFC 7748 Section 5 specifies that the Montgomery ladder concludes with a conditional swap based on the final swap value: (x_2, x_3) = cswap(swap, x_2, x_3) and (z_2, z_3) = cswap(swap, z_2, z_3). In ed448-goldilocks, the ladder loop uses the lazy swap form (choice = swap ^ bit; swap = bit). For odd scalars, bit 0 is 1 so swap is 1 at loop termination, leaving x0 and x1 swapped and returning [k+1]P instead of [k]P. Applying conditional_swap with Choice::from(swap) restores x0 to [k]P for all scalars. Closes RustCrypto#1988
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
RFC 7748 §5 specifies that the Montgomery ladder concludes with a conditional swap based on the final swap value:
(x_2, x_3) = cswap(swap, x_2, x_3)\ and (z_2, z_3) = cswap(swap, z_2, z_3).
In \ed448-goldilocks, the scalar multiplication ladder in \src/montgomery.rs\ uses the lazy swap formulation (\choice = swap ^ bit, \swap = bit). For odd scalars, bit 0 is 1, so \swap\ is 1 upon exiting the loop. Without a final conditional swap, \x0\ and \x1\ remain swapped, causing &MontgomeryPoint * &EdwardsScalar\ to return [k + 1]P\ instead of [k]P.
Closes #1988
Changes
Verification
AI was used to write this code.