public void CheckVerificationMalformedSignature()
        {
            var randomKey = KeyWallet.Create();
            var from      = wallet.GetAddress();
            var to        = new Address("hx5bfdb090f43a808005ffc27c25b213145e80b7cd");

            var transaction = TransactionBuilder.CreateBuilder()
                              .Nid(NetworkId.Main)
                              .From(from)
                              .To(to)
                              .Value(BigInteger.Parse("0de0b6b3a7640000", NumberStyles.AllowHexSpecifier))
                              .StepLimit(BigInteger.Parse("12345", NumberStyles.AllowHexSpecifier))
                              .Timestamp(BigInteger.Parse("563a6cf330136", NumberStyles.AllowHexSpecifier))
                              .Nonce(BigInteger.Parse("1"))
                              .Build();

            var signedTransaction = new SignedTransaction(transaction, wallet);
            var transactionProps  = signedTransaction.GetTransactionProperties();
            var allProps          = signedTransaction.GetProperties();
            var hash      = SignedTransaction.GetTransactionHash(transactionProps);
            var signature = Base64.Decode(allProps.GetItem("signature").ToString());

            signature[64] = 212;
            var result = EcdsaSignature.VerifySignature(randomKey.GetAddress(), signature, hash);

            Assert.False(result);
        }
        public Task <(string Address, string AddressContext, string PrivateKey)> GenerateWalletAsync()
        {
            var wallet     = KeyWallet.Create();
            var address    = wallet.GetAddress().ToString();
            var privateKey = wallet.GetPrivateKey().ToHexString(false);

            return(Task.FromResult((address, nullAddresContext, privateKey)));
        }
示例#3
0
        public void TestCreate()
        {
            var wallet = KeyWallet.Create();

            Assert.True(IconKeys.IsValidAddress(wallet.GetAddress().ToString()));
            IWallet loadWallet = KeyWallet.Load(wallet.GetPrivateKey());

            Assert.Equal(wallet.GetAddress(), loadWallet.GetAddress());
        }
示例#4
0
        public byte[] GeneratePrivateKey()
        {
            var wallet = KeyWallet.Create();

            return(wallet.GetPrivateKey().ToByteArray());
        }