11 private readonly BigInteger a;
12 private readonly BigInteger b;
68 public BigInteger
A => this.a;
73 public BigInteger
B => this.b;
102 if (sDividend.IsZero)
111 yR = this.
modP.
Add(P.Y,
this.modP.Multiply(s,
this.modP.Subtract(xR, P.X)));
133 BigInteger s = this.
modP.
Divide(sDividend, sDivisor);
135 BigInteger yR = this.
modP.
Add(P.Y,
this.modP.Multiply(s,
this.modP.Subtract(xR, P.X)));
153 BigInteger Right = this.
modP.
Add(
157 this.modP.Multiply(Point.
X, Point.
X),
161 return Left == Right;
170 public override byte[]
Sign(
byte[] Data,
bool BigEndian)
181 public override byte[]
Sign(Stream Data,
bool BigEndian)
194 public override bool Verify(
byte[] Data,
byte[]
PublicKey,
bool BigEndian,
byte[] Signature)
207 public override bool Verify(Stream Data,
byte[]
PublicKey,
bool BigEndian,
byte[] Signature)
Implements the Elliptic Curve Digital Signature Algorithm (ECDSA).
static bool Verify(byte[] Data, byte[] PublicKey, bool BigEndian, HashFunctionArray HashFunction, PrimeFieldCurve Curve, byte[] Signature)
Verifies a signature of Data made by the ECDSA algorithm.
static byte[] Sign(byte[] Data, bool BigEndian, byte[] PrivateKey, HashFunctionArray HashFunction, PrimeFieldCurve Curve)
Signs data using the ECDSA algorithm.
BigInteger Order
Order of curve.
int Cofactor
Cofactor of curve.
virtual byte[] PublicKey
Encoded public key
static readonly BigInteger Two
2
virtual PointOnCurve Zero
Neutral point.
PointOnCurve BasePoint
Base-point of curve.
byte[] PrivateKey
Private key
BigInteger Multiply(BigInteger a, BigInteger b)
Multiplies two numbers, modulus p
BigInteger Add(BigInteger a, BigInteger b)
Adds two numbers, modulus p
BigInteger Divide(BigInteger a, BigInteger b)
Divides two numbers, modulus p
BigInteger Subtract(BigInteger a, BigInteger b)
Subtracts two numbers, modulus p
Base class of Elliptic curves over a prime field.
readonly ModulusP modP
Arithmetic modulus p
BigInteger Prime
Prime of curve.
virtual HashFunctionStream HashFunctionStream
Hash function to use in signatures for data streams.
Base class of Weierstrass curves (y²=x³+ax+b) over a prime field.
void Negate(ref PointOnCurve P)
Negates a point on the curve.
BigInteger A
Coefficient a.
override byte[] Sign(byte[] Data, bool BigEndian)
Creates a signature of Data using the ECDSA algorithm.
WeierstrassCurve(BigInteger Prime, PointOnCurve BasePoint, BigInteger a, BigInteger b, BigInteger Order, int Cofactor)
Base class of Weierstrass curves (y²=x³+ax+b) over a prime field.
override void Double(ref PointOnCurve P)
Doubles a point on the curve.
WeierstrassCurve(BigInteger Prime, PointOnCurve BasePoint, BigInteger a, BigInteger b, BigInteger Order, int Cofactor, byte[] Secret)
Base class of Weierstrass curves (y²=x³+ax+b) over a prime field.
override void AddTo(ref PointOnCurve P, PointOnCurve Q)
Adds Q to P .
override byte[] Sign(Stream Data, bool BigEndian)
Creates a signature of Data using the ECDSA algorithm.
override bool IsPoint(PointOnCurve Point)
Checks if a point is on the curve.
WeierstrassCurve(BigInteger Prime, PointOnCurve BasePoint, BigInteger a, BigInteger b, BigInteger Order, int Cofactor, uint[] Secret)
Base class of Weierstrass curves (y²=x³+ax+b) over a prime field.
BigInteger B
Coefficient b.
override bool Verify(Stream Data, byte[] PublicKey, bool BigEndian, byte[] Signature)
Verifies a signature of Data made by the ECDSA algorithm.
override bool Verify(byte[] Data, byte[] PublicKey, bool BigEndian, byte[] Signature)
Verifies a signature of Data made by the ECDSA algorithm.
HashFunction
Hash method enumeration.
Represents a point on a curve.
bool NonZero
If the point is not zero (infinity).