public void TestPublicKey()
        {
            string    publicKeyString = "GXC69R784krfXRuFYMuNwhTTnMGPMuCSSng3WPssL6vrXRqTYCLT4";
            PublicKey publicKey       = PublicKey.FromString(publicKeyString);

            Console.WriteLine(publicKey.ToString());
            Assert.AreEqual <string>(publicKeyString, publicKey.ToString(), "Public keys should be equal");
        }
 public Memo GenerateMemo(string publicKey, ulong nonce, string message)
 {
     return(new Memo()
     {
         From = PrivateKey.GetPublicKey().ToString(),
         To = publicKey,
         Nonce = nonce,
         Message = Hex.BytesToHex(AES.EncryptWithChecksum(PrivateKey, PublicKey.FromString(publicKey), nonce, message))
     });
 }
Beispiel #3
0
 /// <summary>
 /// Check if <paramref name="publicKey"/> is valid or not
 /// </summary>
 /// <returns><c>true</c>, if valid public was ised, <c>false</c> otherwise.</returns>
 /// <param name="publicKey">Public key.</param>
 public bool IsValidPublic(string publicKey)
 {
     try
     {
         return(PublicKey.FromString(publicKey).ToString() == publicKey);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #4
0
        public void MemoEncryptDecrypt()
        {
            string message = "6不6"; // including special charactors
            var    result  = AES.EncryptWithChecksum(PrivateKey.FromWif("5J7Yu8zZD5oV9Ex7npmsT3XBbpSdPZPBKBzLLQnXz5JHQVQVfNT"), PublicKey.FromString("GXC8H1wXTAUWcTtogBmA5EW8TUWLA6T1kAXwMKYtnNuqAe1VCXFD9"), 16087047636745223546L, message);
            var    msg     = Hex.BytesToHex(result);

            Console.WriteLine(Hex.BytesToHex(result));
            string decryptedMsg = AES.DecryptWithChecksum(PrivateKey.FromWif("5J7Yu8zZD5oV9Ex7npmsT3XBbpSdPZPBKBzLLQnXz5JHQVQVfNT"), PublicKey.FromString("GXC8H1wXTAUWcTtogBmA5EW8TUWLA6T1kAXwMKYtnNuqAe1VCXFD9"), 16087047636745223546L, Hex.HexToBytes(msg));

            Console.WriteLine(decryptedMsg);
            Assert.AreEqual(message, decryptedMsg);
        }
Beispiel #5
0
        public void MemoEncryptDecrypt2()
        {
            string message      = "hi你好"; // including special charactors
            var    msg          = "d504585e9d604bcf24a2ce19c220e5f7";
            string decryptedMsg = AES.DecryptWithChecksum(PrivateKey.FromWif("5J7Yu8zZD5oV9Ex7npmsT3XBbpSdPZPBKBzLLQnXz5JHQVQVfNT"), PublicKey.FromString("GXC8H1wXTAUWcTtogBmA5EW8TUWLA6T1kAXwMKYtnNuqAe1VCXFD9"), 398450244318460L, Hex.HexToBytes(msg));

            Console.WriteLine(decryptedMsg);
            Assert.AreEqual(message, decryptedMsg);
        }