Beispiel #1
0
 private static void MineAddresses()
 {
     while (true)
     {
         var key = WalletKey.Create();
         if (key.Address.StartsWith("1Onur"))
         {
             Console.WriteLine(key.Address);
         }
     }
 }
Beispiel #2
0
        public void TestSignature()
        {
            var wk = WalletKey.Create();

            const string signedMessage   = "Wallet Test 2017";
            const string unsignedMessage = "Tallet West 1720";

            var signature = wk.DSA.SignData(Encoding.UTF8.GetBytes(signedMessage), HashAlgorithmName.SHA256);

            Assert.True(wk.DSA.VerifyData(Encoding.UTF8.GetBytes(signedMessage), signature, HashAlgorithmName.SHA256));
            Assert.False(wk.DSA.VerifyData(Encoding.UTF8.GetBytes(unsignedMessage), signature, HashAlgorithmName.SHA256));
            Assert.False(wk.DSA.VerifyData(Encoding.UTF8.GetBytes(signedMessage), signature, HashAlgorithmName.MD5));
        }
Beispiel #3
0
        private static void TestSpeed()
        {
            const uint ITERATIONS = 10_000_000;

            var key = WalletKey.Create();

            var txs = new List <Transaction>()
            {
                new Transaction()
                {
                    OpCode    = OperationCode.Claim,
                    Timestamp = DateTime.UtcNow,
                },
            };

            txs.First().Outputs.Add(Tuple.Create <string, ulong>(key.Address, 50 * 100_000));

            var blk = new Block
            {
                PreviousBlock = "00".ToHash(),
                TxMerkleRoot  = txs
                                .OrderBy(tx => tx.Timestamp)
                                .Select(tx => tx.GetProof())
                                .GetMerkleRoot(),
                Timestamp    = DateTime.UtcNow,
                Throttle     = 0,
                Transactions = txs.ToList(),
            };

            {
                var sw = Stopwatch.StartNew();
                for (var i = 0; i < ITERATIONS; i++)
                {
                    blk.GetProof();
                }
                sw.Stop();
                Console.WriteLine($"{ITERATIONS} GetProof calls took {sw.Elapsed}");
            }

            //{
            //    var sw = Stopwatch.StartNew();
            //    for (var i = 0; i < 1000000; i++)
            //        blk.GetAltProof();
            //    sw.Stop();
            //    Console.WriteLine($"1000000 GetAltProof {sw.Elapsed}");
            //}
        }