3using System.Diagnostics.CodeAnalysis;
19 public override string Oid =>
"1.2.840.10045.2.1";
25 private BigInteger order;
26 private BigInteger coFactor;
34 public override bool IsConfigured => this.field is not
null || this.namedCurve is not
null;
43 if (SecurityInfo.Length != 2)
46 object? Obj = SecurityInfo.LastElementNested;
48 if (Obj is Vector EcParameters)
50 if (EcParameters.Length < 5 || EcParameters.Length > 6)
53 if (EcParameters.FirstElement is not BigInteger
Version ||
57 EcParameters[2] is not Vector Curve ||
59 Curve.FirstElement is not
byte[]
A ||
60 Curve[1] is not
byte[]
B ||
61 EcParameters[3] is not
byte[]
BasePoint ||
62 EcParameters[4] is not BigInteger
Order)
69 if (EcParameters.Length == 6)
71 if (EcParameters[5] is BigInteger h)
91 this.basePoint = G.Value;
99 this.order = this.namedCurve.
Order;
100 this.coFactor = this.namedCurve.
Cofactor;
101 this.basePoint = this.namedCurve.
BasePoint;
134 if (Data.Length == 0)
149 int c = (Data.Length - 1) / 2;
150 byte[] Gx =
new byte[c];
151 byte[] Gy =
new byte[c];
153 Buffer.BlockCopy(Data, 1, Gx, 0, c);
154 Buffer.BlockCopy(Data, 1 + c, Gy, 0, c);
165 Buffer.BlockCopy(Data, 1, Gx, 0, c);
176 Buffer.BlockCopy(Data, 1, Gx, 0, c);
196 if (
PublicKey is not
byte[] PublicKeyData)
228 public BigInteger
A => this.a;
233 public BigInteger
B => this.b;
238 public BigInteger
Order => this.order;
261 if (this.namedCurve is not
null)
262 Parameters[
"NamedCurve"] = this.namedCurve.GetType().FullName;
266 Parameters[
"A"] = this.a;
267 Parameters[
"B"] = this.b;
268 Parameters[
"Order"] = this.order;
269 Parameters[
"CoFactor"] = this.coFactor;
270 Parameters[
"G.X"] = this.basePoint.
X;
271 Parameters[
"G.Y"] = this.basePoint.
Y;
272 Parameters[
"X"] = this.publicKey?.
X;
273 Parameters[
"Y"] = this.publicKey?.
Y;
Abstract base class for field types.
abstract void GetParsedParameters(Dictionary< string, object?> Parameters)
Gets parsed parameters from the field type definition, if available.
Abstract base class for field types.
Abstract base class for named curves.
abstract EllipticCurve GetCurve()
Gets the Elliptic Curve associated with the named curve.
Elliptic Curve Public Key
BigInteger B
Elliptic Curve coefficient B.
BigInteger A
Elliptic Curve coefficient A.
override void GetParsedParameters(Dictionary< string, object?> Parameters)
Gets parsed parameters from the public key definition, if available.
PointOnCurve BasePoint
Elliptic Curve base point G
override string Oid
OID identifying the type of object.
override bool Configure(Vector SecurityInfo)
If the object can be configured by the security information provided.
override bool SetPublicKey(object? PublicKey)
Sets the public key, based on the security information provided.
BigInteger CoFactor
Elliptic Curve co-factor
override bool IsConfigured
If the object has been configured.
static bool TryParsePoint(byte[] Data, [NotNullWhen(true)] out PointOnCurve? Result)
Tries to parse a point on a curve.
BigInteger Order
Elliptic Curve Order
bool HasNamedCurve
If the public key is based on a named curve.
Abstract base class for public keys.
BigInteger D
d coefficient of Edwards curve.
Base class of Edwards curves (x²+y²=1+dx²y²) over a prime field.
Base class of Twisted Edwards curves (-x²+y²=1+dx²y²) over a prime field.
Abstract base class for elliptic curves.
BigInteger Order
Order of curve.
int Cofactor
Cofactor of curve.
static BigInteger ToInt(byte[] Binary, bool BigEndian)
Converts a little-endian binary representation of a big integer to a BigInteger.
PointOnCurve BasePoint
Base-point of curve.
Base class of Montgomery curves (y²=x³+Ax²+x), with birational Edwards equivalent over a prime field.
BigInteger A
Coefficient a.
Base class of Elliptic curves over a prime field.
BigInteger Prime
Prime of curve.
Base class of Weierstrass curves (y²=x³+ax+b) over a prime field.
BigInteger A
Coefficient a.
BigInteger B
Coefficient b.
Interface for named curves.
Represents a point on a curve.