Correct checksum computation
[NovacoinLibrary.git] / NovacoinTest / Program.cs
index d7242ad..592f7ff 100644 (file)
@@ -1,8 +1,6 @@
 \feffusing System;
-using System.Collections.Generic;
 using System.Linq;
 using System.Text;
-using System.Threading.Tasks;
 
 
 namespace NovacoinTest
@@ -39,22 +37,37 @@ namespace NovacoinTest
             Console.WriteLine("OK: {0}\n", strBlock1 == strBlock1Bytes);
 
             Console.WriteLine(b2.ToString());
-            Console.WriteLine("OK: {0}\n", strBlock2 == strBlock2Bytes);
+            Console.WriteLine("Reserialization is OK: {0}\n", strBlock2 == strBlock2Bytes);
 
             /// ECDSA keypair generation test
 
             CKeyPair keyPair1 = new CKeyPair();
             CKeyPair keyPair2 = new CKeyPair(keyPair1.Secret);
+            CPubKey pubKey = keyPair2.GetPubKey();
        
             Console.WriteLine(keyPair1.ToString());
-            Console.WriteLine("OK: {0}\n", keyPair1.ToString() == keyPair2.ToString());
+            Console.WriteLine("PubKey: {0}", pubKey.ToString());
+            Console.WriteLine("Reinitialization is OK: {0}\n", keyPair1.ToString() == keyPair2.ToString());
+
+            /// Address generation test
+
+            CKeyID keyID = keyPair1.GetKeyID();
+            Console.WriteLine("Key ID: {0}", Interop.ToHex(keyID.hashBytes));
+            Console.WriteLine("Novacoin address: {0}\n", keyID.ToString());
+
+            string strPubKeyTest = "029780fac8b85b4a47a616acb4e19d7958eaf02acc5123f65e7824ce720b1ae788";
+            CPubKey pubKeyTest = new CPubKey(Interop.ParseHex(strPubKeyTest));
+            Console.WriteLine("Donations may be sent to: {0}\n", pubKeyTest.GetKeyID().ToString());
 
             /// ECDSA keypair signing test
 
             string data = "Превед!";
-            byte[] signature = keyPair1.Sign(Encoding.UTF8.GetBytes(data)).ToArray();
+            byte[] dataBytes = Encoding.UTF8.GetBytes(data);
+            byte[] signature = keyPair1.Sign(dataBytes).ToArray();
 
             Console.WriteLine("Signature: {0}", Interop.ToHex(signature));
+            Console.WriteLine("Signature is OK: {0} (CKeyPair)", keyPair1.VerifySignature(dataBytes, signature));
+            Console.WriteLine("Signature is OK: {0} (CPubKey)", pubKey.VerifySignature(dataBytes, signature));
 
             Console.ReadLine();
         }