Following this question ed25519 attacks and also this paper on degenerate curve attacks https://eprint.iacr.org/2015/1233.pdf, I tried to implement my own attack: Given a point (0, y) and a scalar (k), the computed point should be (0, y^k).
This attack worked successfully with affline points (X:Y), with point addition formulas such as:
Although, when implementing the same attack with extended coordinates using this point addition formula, it seems to fail.
Y will always revert to 1 or some big number. (I have kept y = Y/Z in mind).
Here is the code I used to implement the attack:
using H4x2_TinySDK.Ed25519;
using System.Numerics;
var p = new Point(BigInteger.Parse("0"), BigInteger.Parse("2"));
var q = new Point(BigInteger.Parse("0"), BigInteger.Parse("3"));
var t = p + q;
var qy = t.GetY(); // Expecting 6 <- (2*3). Actual result is 57896044618658097711785492504343953926634992332820282019728792003956564819947
The paper linked above states
An obvious but important observation is that, while we have described our attack in affine
coordinates, it also works in the (likely) case when the device performs its computation in projective
coordinates, using the projective versions of the same group operations. It is straightforward to check, for
example, that (0 : Y1 : 1) + (0 : Y2 : 1) = (0 : Y1Y2 : 1)
Although this doesn't seem to be the case.
It would be great if someone could show an example of how to implement the degenerate curve attack with extended coordinates, or provide some insight into what I might be doing wrong.
The following code is what is being used to do ed25519 point addition (full code @ https://github.com/tide-foundation/Tide-h4x2-2/blob/main/H4x2-TinySDK/H4x2-TinySDK/Ed25519/Point.cs):
public static Point operator +(in Point point1, in Point point2)
{
// TODO: check to see if point is on curve and on the prime order subgroup
// Algorithm taken from https://www.hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html.
BigInteger A = Mod((point1.Y - point1.X) * (point2.Y + point2.X));
BigInteger B = Mod((point1.Y + point1.X) * (point2.Y - point2.X));
BigInteger F = Mod(B - A);
if (F.Equals(BigInteger.Zero)) return Double(point1);
BigInteger C = Mod(point1.Z * Curve.Two * point2.T);
BigInteger D = Mod(point1.T * Curve.Two * point2.Z);
BigInteger E = D + C;
BigInteger G = B + A;
BigInteger H = D - C;
BigInteger X3 = Mod(E * F);
BigInteger Y3 = Mod(G * H);
BigInteger T3 = Mod(E * H);
BigInteger Z3 = Mod(F * G);
return new Point(X3, Y3, Z3, T3);
}
EDIT We have found that the paper states the attack works against projective coordinates, while we're using extended coordinates. I don't see how this should affect my results as x = X / Z and y = Y /Z for both types of coordinates.