11 private readonly BigInteger p58;
12 private readonly BigInteger twoP14;
41 this.p58 = (this.p - 5) / 8;
42 this.twoP14 = BigInteger.ModPow(
Two, (this.
p - 1) / 4, this.
p);
65 BigInteger G = this.
modP.
Add(D, C);
66 BigInteger H = this.
modP.
Add(B, A);
83 BigInteger A = P.Y - P.X;
86 BigInteger B = P.Y + P.X;
93 BigInteger G = this.
modP.
Add(D, C);
94 BigInteger H = this.
modP.
Add(B, A);
109 public override BigInteger
GetX(BigInteger Y,
bool X0)
112 BigInteger u = y2 - BigInteger.One;
116 BigInteger v = this.
modP.
Multiply(this.
d, y2) + BigInteger.One;
122 BigInteger.ModPow(
this.modP.Multiply(u, v7),
this.p58,
this.Prime));
131 if (Test == this.
Prime - u)
134 throw new ArgumentException(
"Not a valid point.", nameof(Y));
140 throw new ArgumentException(
"Not a valid point.", nameof(Y));
165 BigInteger Right = this.
modP.
Add(
168 this.modP.Multiply(
this.d, X2),
171 return Left == Right;
Base class of different types of Edwards curves over a prime field.
BigInteger D
d coefficient of Edwards curve.
BigInteger d
Edwards curve coefficient
Base class of Twisted Edwards curves (-x²+y²=1+dx²y²) over a prime field.
override void AddTo(ref PointOnCurve P, PointOnCurve Q)
Adds Q to P .
EdwardsTwistedCurve(BigInteger Prime, PointOnCurve BasePoint, BigInteger d, BigInteger Order, int Cofactor, byte[] Secret)
Base class of Twisted Edwards curves (-x²+y²=1+dx²y²) over a prime field.
override BigInteger GetX(BigInteger Y, bool X0)
Gets the X-coordinate that corresponds to a given Y-coordainte, and the first bit of the X-coordinate...
override bool IsPoint(PointOnCurve Point)
Checks if a point is on the curve.
override void Double(ref PointOnCurve P)
Doubles a point on the curve.
EdwardsTwistedCurve(BigInteger Prime, PointOnCurve BasePoint, BigInteger d, BigInteger Order, int Cofactor)
Base class of Twisted Edwards curves (-x²+y²=1+dx²y²) over a prime field.
BigInteger Order
Order of curve.
int Cofactor
Cofactor of curve.
static readonly BigInteger Two
2
PointOnCurve BasePoint
Base-point of curve.
BigInteger Multiply(BigInteger a, BigInteger b)
Multiplies two numbers, modulus p
BigInteger Add(BigInteger a, BigInteger b)
Adds two numbers, modulus p
BigInteger Subtract(BigInteger a, BigInteger b)
Subtracts two numbers, modulus p
readonly ModulusP modP
Arithmetic modulus p
BigInteger Prime
Prime of curve.
readonly BigInteger p
Prime p
Represents a point on a curve.
bool IsHomogeneous
If the point is in homogeneous coordinates.