Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
EdwardsCurveBase.cs
1using System;
2using System.Security.Cryptography;
3using System.Numerics;
4
6{
10 public abstract class EdwardsCurveBase : PrimeFieldCurve
11 {
15 protected BigInteger d;
16
20 protected BigInteger d2;
21
31 BigInteger d, BigInteger Order, int Cofactor)
32 : this(Prime, BasePoint, d, Order, Cofactor, null)
33 {
34 }
35
45 public EdwardsCurveBase(BigInteger Prime, PointOnCurve BasePoint, BigInteger d,
46 BigInteger Order, int Cofactor, byte[] Secret)
47 : base(Prime, BasePoint, Order, Cofactor, Secret)
48 {
49 this.d = d;
50 this.d2 = BigInteger.Remainder(d << 1, this.p);
51 }
52
56 public abstract int CoordinateBits
57 {
58 get;
59 }
60
64 public override PointOnCurve Zero
65 {
66 get
67 {
68 return new PointOnCurve(BigInteger.Zero, BigInteger.One);
69 }
70 }
71
79 public abstract BigInteger GetX(BigInteger Y, bool X0);
80
86 public override byte[] Encode(PointOnCurve Point)
87 {
88 return EdDSA.Encode(Point, this);
89 }
90
96 public override PointOnCurve Decode(byte[] Point)
97 {
98 return EdDSA.Decode(Point, this);
99 }
100
105 public void Negate(ref PointOnCurve P)
106 {
107 P.X = this.p - P.X;
108 }
109 }
110}
Implements the Edwards curve Digital Signature Algorithm (EdDSA), as defined in RFC 8032....
Definition: EdDSA.cs:13
static byte[] Encode(PointOnCurve P, EdwardsCurveBase Curve)
Encodes a point on the curve in accordance with §5.1.2 of RFC 8032.
Definition: EdDSA.cs:140
static PointOnCurve Decode(byte[] Encoded, EdwardsCurveBase Curve)
Decodes a point on the curve in accordance with §5.1.3 of RFC 8032.
Definition: EdDSA.cs:167
Base class of different types of Edwards curves over a prime field.
void Negate(ref PointOnCurve P)
Negates a point on the curve.
override PointOnCurve Decode(byte[] Point)
Decodes an encoded point on the curve.
EdwardsCurveBase(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.
abstract 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 byte[] Encode(PointOnCurve Point)
Encodes a point on the curve.
EdwardsCurveBase(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.
BigInteger d
Edwards curve coefficient
BigInteger d2
Edwards curve coefficient * 2 mod p
abstract int CoordinateBits
Number of bits used to encode the y-coordinate.
override PointOnCurve Zero
Neutral point.
PointOnCurve BasePoint
Base-point of curve.
Base class of Elliptic curves over a prime field.
Represents a point on a curve.
Definition: PointOnCurve.cs:11