Skip to content

Commit c33d5a7

Browse files
committed
Added easier ECDiffieHellman overload
1 parent a20b311 commit c33d5a7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

MLAPI.Cryptography.Examples/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public static void Main(string[] args)
1717
watch.Start();
1818

1919
// Both create their instances
20-
ECDiffieHellman serverDiffie = new ECDiffieHellman(ECDiffieHellman.DEFAULT_CURVE, ECDiffieHellman.DEFAULT_GENERATOR, ECDiffieHellman.DEFAULT_ORDER);
21-
ECDiffieHellman clientDiffie = new ECDiffieHellman(ECDiffieHellman.DEFAULT_CURVE, ECDiffieHellman.DEFAULT_GENERATOR, ECDiffieHellman.DEFAULT_ORDER);
20+
ECDiffieHellman serverDiffie = new ECDiffieHellman();
21+
ECDiffieHellman clientDiffie = new ECDiffieHellman();
2222

2323
// Exchange publics
2424

MLAPI.Cryptography/KeyExchanges/ECDiffieHellman.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ public class ECDiffieHellman
1313
public static readonly BigInteger DEFAULT_PRIME = (new BigInteger("1") << 255) - 19;
1414
public static readonly BigInteger DEFAULT_ORDER = (new BigInteger(1) << 252) + new BigInteger("27742317777372353535851937790883648493");
1515
public static EllipticCurve DEFAULT_CURVE = new EllipticCurve(486662, 1, DEFAULT_PRIME, EllipticCurve.CurveType.Montgomery);
16-
1716
public static CurvePoint DEFAULT_GENERATOR = new CurvePoint(9, new BigInteger("14781619447589544791020593568409986887264606134616475288964881837755586237401"));
1817

1918
protected readonly EllipticCurve curve;
2019
public readonly BigInteger priv;
2120
protected readonly CurvePoint generator, pub;
2221

22+
public ECDiffieHellman(byte[] priv = null) : this(DEFAULT_CURVE, DEFAULT_GENERATOR, DEFAULT_ORDER, priv)
23+
{
24+
25+
}
26+
2327
public ECDiffieHellman(EllipticCurve curve, CurvePoint generator, BigInteger order, byte[] priv = null)
2428
{
2529
this.curve = curve;

0 commit comments

Comments
 (0)