2using System.Globalization;
14 private static readonly BigInteger p0 = BigInteger.Pow(2, 448) - BigInteger.Pow(2, 224) - 1;
15 private static readonly BigInteger A0 = 156326;
16 private static readonly BigInteger A24 = (A0 - 2) / 4;
17 private static readonly BigInteger n0 = BigInteger.Pow(2, 446) - BigInteger.Parse(
"008335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d", NumberStyles.HexNumber);
18 private static readonly BigInteger BasePointU = 5;
19 private static readonly BigInteger BasePointV = BigInteger.Parse(
"355293926785568175264127502063783334808976399387714271831880898435169088786967410002932673765864550910142774147268105838985595290606362");
26 : base(p0, new
PointOnCurve(BasePointU, BasePointV), n0, 4)
36 : base(p0, new
PointOnCurve(BasePointU, BasePointV), n0, 4, Secret)
48 protected override BigInteger
A => A0;
64 BigInteger TwoU2 = U2 << 1;
65 BigInteger TwoU3 = U3 << 1;
68 (U4 - TwoU2 + (V2 << 2) + BigInteger.One));
72 (U5 -
this.modP.Multiply(TwoU2, V2) - TwoU3 - (V2 << 1) + UV.
X));
129 Array.Resize(ref Bin, 57);
137 Array.Resize(ref Bin, 57);
145 return new Tuple<byte[], byte[]>(Bin,
null);
161 if (PublicKeyXY.
Y.Equals(PublicKeyXY2.
Y))
164 throw new InvalidOperationException(
"Unable to create pair curve.");
172 public override byte[]
Sign(
byte[] Data)
174 throw new NotSupportedException(
"Signatures not supported.");
183 public override byte[]
Sign(Stream Data)
185 throw new NotSupportedException(
"Signatures not supported.");
198 throw new NotSupportedException(
"Signatures not supported.");
212 throw new NotSupportedException(
"Signatures not supported.");
Curve448 (Goldilocks), as defined in RFC 7748: https://tools.ietf.org/html/rfc7748
Curve448(byte[] Secret)
Curve448 (Goldilocks), as defined in RFC 7748: https://tools.ietf.org/html/rfc7748
override BigInteger ScalarMultiplication(byte[] N, BigInteger U)
Performs the scalar multiplication of N *U .
override byte[] Sign(Stream Data)
Creates a signature of Data using the XEdDSA algorithm.
override PointOnCurve ToUV(PointOnCurve XY)
Converts a pair of (X,Y) coordinates for the birational Edwards curve to a pair of (U,...
override PointOnCurve ToXY(PointOnCurve UV)
Converts a pair of (U,V) coordinates to a pair of (X,Y) coordinates in the birational Edwards curve.
Curve448()
Curve448 (Goldilocks), as defined in RFC 7748: https://tools.ietf.org/html/rfc7748
override bool Verify(byte[] Data, byte[] PublicKey, byte[] Signature)
Verifies a signature of Data made by the EdDSA algorithm.
override Tuple< byte[], byte[]> CalculatePrivateKey(byte[] Secret)
Calculates a private key from a secret.
override string CurveName
Name of curve.
override bool Verify(Stream Data, byte[] PublicKey, byte[] Signature)
Verifies a signature of Data made by the EdDSA algorithm.
override byte[] Sign(byte[] Data)
Creates a signature of Data using the XEdDSA algorithm.
override BigInteger A
a Coefficient in the definition of the curve E: v²=u³+A*u²+u
override EdwardsCurveBase CreatePair()
Creates the Edwards Curve pair.
Edwards448 Elliptic Curve, as defined in RFC7748 and RFC8032: https://tools.ietf.org/html/rfc7748 htt...
Base class of different types of Edwards curves over a prime field.
virtual byte[] PublicKey
Encoded public key
static readonly BigInteger Two
2
byte[] PrivateKey
Private key
virtual PointOnCurve PublicKeyPoint
Public key, as a point on the elliptic curve.
BigInteger Multiply(BigInteger a, BigInteger b)
Multiplies two numbers, modulus p
BigInteger Divide(BigInteger a, BigInteger b)
Divides two numbers, modulus p
Base class of Montgomery curves (y²=x³+Ax²+x), with biratinal Edwards equivalent over a prime field.
static BigInteger XFunction(byte[] N, BigInteger U, BigInteger A24, BigInteger p, int Bits)
Performs the scalar multiplication of N *U .
override PointOnCurve PublicKeyPoint
Public key.
readonly ModulusP modP
Arithmetic modulus p
override PointOnCurve ScalarMultiplication(byte[] N, PointOnCurve P, bool Normalize)
Performs the scalar multiplication of N *P .
readonly BigInteger p
Prime p
Contains methods for simple hash calculations.
static byte[] ComputeSHA512Hash(byte[] Data)
Computes the SHA-512 hash of a block of binary data.
Represents a point on a curve.