Skip to content

ed448-goldilocks: fix infinite recursion when adding EdwardsPoint and AffinePoint - #1979

Open
Ravan002 wants to merge 1 commit into
RustCrypto:masterfrom
Ravan002:ed448-edwards-affine-add
Open

Ravan002 wants to merge 1 commit into
RustCrypto:masterfrom
Ravan002:ed448-edwards-affine-add

Conversation

@Ravan002

Copy link
Copy Markdown

Adding an EdwardsPoint and an AffinePoint with + never returns. The reference impls dereference both sides and call the by-value impl, and define_add_variants! forwards the by-value impl back to the reference one, so they call each other forever. += and - were fine because they go through to_edwards().

let g = EdwardsPoint::GENERATOR;
g + g.to_affine();      // before: hangs, after: g.double()
g.to_affine() + g;      // same

Both reference impls now convert the affine point with to_edwards(), like Sub and AddAssign already do. add_affine_point covers all four by-value and by-reference combinations; on master it hangs.

… AffinePoint

The reference Add impls between EdwardsPoint and AffinePoint dereferenced
both sides and called the by-value impl, which the define_add_variants
macro forwards back to the reference impl, so the addition never returned.
Convert the affine point with to_edwards() instead.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant