-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCurve.cs
69 lines (55 loc) · 1.39 KB
/
Curve.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Numerics;
namespace LeutgebAes.EllipticCurve
{
public class Curve
{
private BigInteger q;
private FieldElement a, b;
public Curve(BigInteger q, BigInteger a, BigInteger b)
{
this.q = q;
this.a = new FieldElement(q, a);
this.b = new FieldElement(q, b);
}
public FieldElement A {
get { return this.a; }
}
public FieldElement B {
get { return this.b; }
}
public BigInteger Q
{
get { return q; }
}
public static bool operator ==(Curve a, Curve b)
{
return a.q == b.q && a.a == b.a && a.b == b.b;
}
public static bool operator !=(Curve a, Curve b)
{
return !(a == b);
}
public override bool Equals(object obj)
{
if (obj.GetType() != this.GetType())
return false;
return this == (Curve)obj;
}
public FieldElement GenerateFieldElement(BigInteger x)
{
return new FieldElement(q, x);
}
public Point Infinity {
get { return new Point(this, null, null); }
}
public static Curve Dummy
{
get { return new Curve(BigInteger.Zero, BigInteger.Zero, BigInteger.Zero); }
}
public override int GetHashCode()
{
return a.GetHashCode() ^ b.GetHashCode() ^ q.GetHashCode();
}
}
}