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.Numerics;
2
4{
8 public abstract class EdwardsCurveBase : PrimeFieldCurve
9 {
13 protected BigInteger d;
14
18 protected BigInteger d2;
19
29 BigInteger d, BigInteger Order, int Cofactor)
30 : this(Prime, BasePoint, d, Order, Cofactor, null)
31 {
32 }
33
43 public EdwardsCurveBase(BigInteger Prime, PointOnCurve BasePoint, BigInteger d,
44 BigInteger Order, int Cofactor, byte[] Secret)
45 : base(Prime, BasePoint, Order, Cofactor, Secret)
46 {
47 this.d = d;
48 this.d2 = BigInteger.Remainder(d << 1, this.p);
49 }
50
54 public abstract int CoordinateBits
55 {
56 get;
57 }
58
62 public override PointOnCurve Zero
63 {
64 get
65 {
66 return new PointOnCurve(BigInteger.Zero, BigInteger.One);
67 }
68 }
69
73 public BigInteger D => this.d;
74
82 public abstract BigInteger GetX(BigInteger Y, bool X0);
83
90 public override byte[] Encode(PointOnCurve Point, bool BigEndian)
91 {
92 return EdDSA.Encode(Point, BigEndian, this);
93 }
94
101 public override PointOnCurve Decode(byte[] Point, bool BigEndian)
102 {
103 return EdDSA.Decode(Point, BigEndian, this);
104 }
105
110 public void Negate(ref PointOnCurve P)
111 {
112 P.X = this.p - P.X;
113 }
114
115 }
116}
Implements the Edwards curve Digital Signature Algorithm (EdDSA), as defined in RFC 8032....
Definition: EdDSA.cs:13
static PointOnCurve Decode(byte[] Encoded, bool BigEndian, EdwardsCurveBase Curve)
Decodes a point on the curve in accordance with §5.1.3 of RFC 8032.
Definition: EdDSA.cs:174
static byte[] Encode(PointOnCurve P, bool BigEndian, EdwardsCurveBase Curve)
Encodes a point on the curve in accordance with §5.1.2 of RFC 8032.
Definition: EdDSA.cs:143
Base class of different types of Edwards curves over a prime field.
void Negate(ref PointOnCurve P)
Negates a point on the curve.
EdwardsCurveBase(BigInteger Prime, PointOnCurve BasePoint, BigInteger d, BigInteger Order, int Cofactor)
Base class of different types of Edwards curves 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 PointOnCurve Decode(byte[] Point, bool BigEndian)
Decodes an encoded point on the curve.
override byte[] Encode(PointOnCurve Point, bool BigEndian)
Encodes a point on the curve.
EdwardsCurveBase(BigInteger Prime, PointOnCurve BasePoint, BigInteger d, BigInteger Order, int Cofactor, byte[] Secret)
Base class of different types of Edwards curves over a prime field.
BigInteger D
d coefficient of Edwards curve.
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:10