public static void Test2() { DH64 dh64 = new DH64(); for (var i = 0; i < data.Length; i += 2) { ulong privateKey1 = data[i].PrivateKey; ulong publicKey1 = data[i].PublicKey; ulong secret1 = data[i].Secret; ulong privateKey2 = data[i+1].PrivateKey; ulong publicKey2 = data[i+1].PublicKey; ulong secret2 = data[i+1].Secret; ulong secret11 = dh64.Secret(privateKey1, publicKey2); ulong secret22 = dh64.Secret(privateKey2, publicKey1); //Console.WriteLine("{0}, {1}, {2}, {3}", privateKey1, publicKey1, secret1, secret11); //Console.WriteLine("{0}, {1}, {2}, {3}", privateKey2, publicKey2, secret2, secret22); if (secret1 != secret11 || secret2 != secret22) { throw new Exception("Secret not match"); } } Console.WriteLine("Test2 PASS."); }
public static void Test1() { DH64 dh64 = new DH64(); for (var i = 0; i < 10000; i ++) { ulong privateKey1; ulong publicKey1; dh64.KeyPair(out privateKey1, out publicKey1); ulong privateKey2; ulong publicKey2; dh64.KeyPair(out privateKey2, out publicKey2); ulong secret1 = dh64.Secret(privateKey1, publicKey2); ulong secret2 = dh64.Secret(privateKey2, publicKey1); if (secret1 != secret2) { throw new Exception("Secret not match"); } } Console.WriteLine("Test1 PASS."); }