Пример #1
0
        public void ReceiveNonFungibleToken_5()
        {
            CreateFirstGenesisBlock();

            DiscountTokenGenesis();

            var encryptor = new ECC_DHA_AES_Encryptor();

            var discount_token = new NonFungibleToken();

            discount_token.Denomination = 50;
            discount_token.TokenCode    = "Custom.DISC";
            //  disount_token.OriginHash = "some unique random string";
            discount_token.ExpirationDate = DateTime.Now + TimeSpan.FromDays(365);
            discount_token.SerialNumber   = discount_token.CalculateHash(); // Just set to some random string
            discount_token.RedemptionCode = encryptor.Encrypt(PrivateKey1, AccountId2, discount_token.SerialNumber, "12345678901234567890");
            discount_token.Sign(PrivateKey1);

            SendDiscountToken(discount_token);

            ProcessReceiveDiscountToken(discount_token);

            var decryptor = new ECC_DHA_AES_Encryptor();

            string decrypted_redemption_code = decryptor.Decrypt(PrivateKey2, AccountId1, _OpenAccount2Block.NonFungibleToken.SerialNumber, (_OpenAccount2Block.NonFungibleToken as NonFungibleToken).RedemptionCode);

            Assert.AreEqual("12345678901234567890", decrypted_redemption_code);
        }
Пример #2
0
        public void EncryptionDecryption()
        {
            var AccountId1 = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);

            var AccountId2 = Signatures.GetAccountIdFromPrivateKey(PrivateKey2);

            var crypto = new ECC_DHA_AES_Encryptor();

            var salt = "54CRv2pEjNj8c3UBPv4AxYmEKEojmVdAagTpgSjHieAq";

            string encryptedMessage = crypto.Encrypt(PrivateKey1, AccountId2, salt, message);
            string decryptedMessage = crypto.Decrypt(PrivateKey2, AccountId1, salt, encryptedMessage);

            Assert.AreEqual <string>(message, decryptedMessage);
        }
        public void EncryptionDecryption()
        {
            var PrivateKey1 = "DQDP23xgHmLSsdm64qu1UsMteA5qDfgTiFRQRbjnfKstkg4LN";
            var AccountId1  = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);

            var PrivateKey2 = "2CcBpc2vn8uXeiXp7sW15w3wFYCWt36VufrKuPBzqnxVQto64H";
            var AccountId2  = Signatures.GetAccountIdFromPrivateKey(PrivateKey2);

            var crypto = new ECC_DHA_AES_Encryptor();

            var message = "This is the test message";
            var salt    = "54CRv2pEjNj8c3UBPv4AxYmEKEojmVdAagTpgSjHieAq";

            string encryptedMessage = crypto.Encrypt(PrivateKey1, AccountId2, salt, message);
            string decryptedMessage = crypto.Decrypt(PrivateKey2, AccountId1, salt, encryptedMessage);

            Assert.AreEqual <string>(message, decryptedMessage);
        }
Пример #4
0
        public void ReceiveNonFungibleToken_4()
        {
            CreateFirstGenesisBlock();

            DiscountTokenGenesis();

            var disount_token = new NonFungibleToken();

            disount_token.Denomination = 50;
            disount_token.TokenCode    = "Custom.DISC";
            //  disount_token.OriginHash = "some unique random string";
            disount_token.RedemptionCode = "12345678901234567890";
            disount_token.Sign(PrivateKey1);

            SendDiscountToken(disount_token);

            ProcessReceiveDiscountToken(disount_token);

            var encryptor = new ECC_DHA_AES_Encryptor();

            string decrypted_redemption_code = encryptor.Decrypt(PrivateKey2, AccountId1, "54CRv2pEjNj8c3UBPv4AxYmEKEojmVdAagTpgSjHieAq", "54CRv2pEjNj8c3UBPv4AxYmEKEojmVdAagTpgSjHieAq");

            //Assert.AreEqual("12345678901234567890", decrypted_redemption_code);
        }