floodyberry / ed25519-donna

Implementations of a fast Elliptic-curve Digital Signature Algorithm
169 stars 47 forks source link

Questions about calculating |r|B, why we only have minust here? #38

Closed DK-DARKmatter closed 3 years ago

DK-DARKmatter commented 3 years ago

Hi there, Recently I am learning about curve25519. After reading the paper, I try to go through the code and I encounter some problems. https://github.com/floodyberry/ed25519-donna/blob/8757bd4cd209cb032853ece0ce413f122eef212c/fuzz/ed25519-ref10.c#L3887 Here, I know that we are picking precomputed point as (y+x, y-x, 2dxy), and when we have |r| is negative, we need to do operations to add -rB. But why we only invert 2dxy, which is T here, and left (y-x, y+x) as the same? Also, after that we do : https://github.com/floodyberry/ed25519-donna/blob/8757bd4cd209cb032853ece0ce413f122eef212c/fuzz/ed25519-ref10.c#L3929 And in ge_madd function, we have: https://github.com/floodyberry/ed25519-donna/blob/8757bd4cd209cb032853ece0ce413f122eef212c/fuzz/ed25519-ref10.c#L3545 My question is why we can do a multiplication here with Y+X and y+x. From my perspective, they seems in different coordinates, one is in extended coordinate and one is in affine coordinate(not sure about this, correct me if I'm wrong). Can we do a multiplication directly?

Thank you in advance