Salsa20 + wrapper stub
[NovacoinLibrary.git] / NovacoinTest / Program.cs
index 645c8e7..924d659 100644 (file)
@@ -6,6 +6,7 @@ using System.Text;
 namespace NovacoinTest
 {
     using Novacoin;
+    using System.Collections.Generic;
 
     class Program
     {
@@ -44,9 +45,18 @@ namespace NovacoinTest
             CKeyPair keyPair1 = new CKeyPair();
             CKeyPair keyPair2 = new CKeyPair(keyPair1.Secret);
             CPubKey pubKey = keyPair2.GetPubKey();
-       
-            Console.WriteLine(keyPair1.ToString());
-            Console.WriteLine("PubKey: {0}", pubKey.ToString());
+
+            string strPrivKeyBase58 = keyPair1.ToString();
+
+            Console.WriteLine("Privkey in Base58: {0}", strPrivKeyBase58);
+            Console.WriteLine("Privkey in Hex: {0}", keyPair1.ToHex());
+
+            CKeyPair keyPair3 = new CKeyPair(strPrivKeyBase58);
+            Console.WriteLine("Privkey base58 deserialization is OK: {0}", keyPair3.GetKeyID().ToString() == keyPair1.GetKeyID().ToString());
+
+            Console.WriteLine("Pubkey in Base58: {0}", pubKey.ToString());
+            Console.WriteLine("Pubkey in Hex: {0}", pubKey.ToHex());
+
             Console.WriteLine("Reinitialization is OK: {0}\n", keyPair1.ToString() == keyPair2.ToString());
 
             /// Address generation test
@@ -55,6 +65,17 @@ namespace NovacoinTest
             Console.WriteLine("Key ID: {0}", Interop.ToHex(keyID.hashBytes));
             Console.WriteLine("Novacoin address: {0}\n", keyID.ToString());
 
+            /// Privkey deserialization test
+            CKeyPair keyPair4 = new CKeyPair("MEP3qCtFGmWo3Gurf8fMnUNaDHGNf637DqjoeG8rKium2jSj51sf");
+            Console.WriteLine("\nHard-coded privkey in Hex: {0}", keyPair4.ToHex());
+            Console.WriteLine("Hard-Coded privkey address: {0}", keyPair4.GetKeyID().ToString());
+            Console.WriteLine("Hard-Coded privkey: {0}\n", keyPair4.ToString());
+
+            // Privkey hex deserialization test
+            CKeyPair keyPair5 = new CKeyPair(keyPair4.Secret.ToArray());
+            Console.WriteLine("Decoded privkey in Hex: {0}", keyPair5.ToHex());
+            Console.WriteLine("Decoded privkey address: {0}\n", keyPair5.GetKeyID().ToString());
+
             /// ECDSA keypair signing test
 
             string data = "Превед!";
@@ -65,6 +86,26 @@ namespace NovacoinTest
             Console.WriteLine("Signature is OK: {0} (CKeyPair)", keyPair1.VerifySignature(dataBytes, signature));
             Console.WriteLine("Signature is OK: {0} (CPubKey)", pubKey.VerifySignature(dataBytes, signature));
 
+            /// Donation address
+
+            string strPubKeyTest = "029780fac8b85b4a47a616acb4e19d7958eaf02acc5123f65e7824ce720b1ae788";
+            CPubKey pubKeyTest = new CPubKey(Interop.ParseHex(strPubKeyTest));
+            string strDonationAddress = pubKeyTest.GetKeyID().ToString();
+            Console.WriteLine("\nDonations may be sent to: {0}", strDonationAddress);
+            Console.WriteLine("Address generation is OK: {0}", strDonationAddress == "4T2t8uiDtyHceMwMjMHPn88TyJB3trCg3o");
+
+            /// Address deserialization test
+
+            CNovacoinAddress donationAddress = new CNovacoinAddress(strDonationAddress);
+            Console.WriteLine("Address reserialization is OK: {0}", donationAddress.ToString() == pubKeyTest.GetKeyID().ToString());
+
+            /*
+            IEnumerable<byte> dataBytesForScrypt = b1.header.ToBytes();
+            ScryptHash256 scryptHash = ScryptHash256.Compute256(dataBytesForScrypt);
+
+            Console.WriteLine(scryptHash.ToString());
+
+            */
             Console.ReadLine();
         }
     }