2using System.Globalization;
18 private static readonly BigInteger p0 = BigInteger.Pow(2, 448) - BigInteger.Pow(2, 224) - 1;
19 private static readonly BigInteger d0 = p0 - 39081;
20 private static readonly BigInteger n0 = BigInteger.Pow(2, 446) - BigInteger.Parse(
"008335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d", NumberStyles.HexNumber);
21 private static readonly BigInteger BasePointX = BigInteger.Parse(
"224580040295924300187604334099896036246789641632564134246125461686950415467406032909029192869357953282578032075146446173674602635247710");
22 private static readonly BigInteger BasePointY = BigInteger.Parse(
"298819210078481492676017930443930673437544040154080242095928241372331506189835876003536878655418784733982303233503462500531545062832660");
23 private readonly
SHAKE256 shake256_114;
24 private readonly
bool hashSecret;
55 : base(p0, new
PointOnCurve(BasePointX, BasePointY), d0, n0, 4, Secret)
57 this.shake256_114 =
new SHAKE256(114 << 3);
58 this.hashSecret = HashSecret;
69 protected override BigInteger
D =>
d;
83 byte[] Bin = this.shake256_114.ComputeVariable(Secret);
90 Array.Copy(Secret, 0,
PrivateKey, 0, Math.Min(57, Secret.Length));
106 public override byte[]
Sign(
byte[] Data)
117 public override byte[]
Sign(Stream Data)
146 private byte[] H_dom4(
byte[] Data)
149 byte[] Bin =
new byte[10 + c];
151 Array.Copy(preamble, 0, Bin, 0, 8);
154 Array.Copy(Data, 0, Bin, 10, c);
156 return this.shake256_114.ComputeVariable(Bin);
159 private byte[] H_dom4(Stream Data)
163 TempFile.
Write(preamble, 0, 8);
168 Data.CopyTo(TempFile);
170 TempFile.Position = 0;
171 return this.shake256_114.ComputeVariable(TempFile);
175 private static readonly
byte[] preamble = Encoding.ASCII.GetBytes(
"SigEd448");
Manages a temporary stream. Contents is kept in-memory, if below a memory threshold,...
override void Write(byte[] buffer, int offset, int count)
When overridden in a derived class, writes a sequence of bytes to the current stream and advances the...
override void WriteByte(byte value)
Writes a byte to the current position in the stream and advances the position within the stream by on...
Implements the Edwards curve Digital Signature Algorithm (EdDSA), as defined in RFC 8032....
static byte[] Sign(byte[] Data, byte[] PrivateKey, byte[] Prefix, HashFunctionArray HashFunction, EdwardsCurveBase Curve)
Signs data using the EdDSA algorithm.
static bool Verify(byte[] Data, byte[] PublicKey, HashFunctionArray HashFunction, EdwardsCurveBase Curve, byte[] Signature)
Verifies a signature of Data made by the EdDSA algorithm.
Edwards448 Elliptic Curve, as defined in RFC7748 and RFC8032: https://tools.ietf.org/html/rfc7748 htt...
override Tuple< byte[], byte[]> CalculatePrivateKey(byte[] Secret)
Calculates a private key from a secret.
override bool Verify(Stream Data, byte[] PublicKey, byte[] Signature)
Verifies a signature of Data made by the EdDSA algorithm.
Edwards448(byte[] Secret)
Edwards448 Elliptic Curve, as defined in RFC7748 and RFC8032: https://tools.ietf.org/html/rfc7748 htt...
override BigInteger D
d coefficient of Edwards curve.
override bool Verify(byte[] 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 EdDSA algorithm.
override byte[] Sign(Stream Data)
Creates a signature of Data using the EdDSA algorithm.
Edwards448()
Edwards448 Elliptic Curve, as defined in RFC7748 and RFC8032: https://tools.ietf.org/html/rfc7748 htt...
Edwards448(byte[] Secret, bool HashSecret)
Edwards448 Elliptic Curve, as defined in RFC7748 and RFC8032: https://tools.ietf.org/html/rfc7748 htt...
override int CoordinateBits
Number of bits used to encode the y-coordinate.
override string CurveName
Name of curve.
BigInteger d
Edwards curve coefficient
Base class of Edwards curves (x²+y²=1+dx²y²) over a prime field.
byte[] AdditionalInfo
Curve-specific additional information
virtual byte[] PublicKey
Encoded public key
byte[] PrivateKey
Private key
Implements the SHA3 SHAKE256 extendable-output functions, as defined in section 6....
Represents a point on a curve.