Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("----==== Norn Wallet ====----");
            Console.WriteLine();
            Console.WriteLine("Norn Wallet created by Norn Community: https://t.me/invest_flood");
            Console.WriteLine();
            Console.WriteLine("Choose action:");
            Console.WriteLine("1 - Import mnemonic");
            Console.WriteLine("2 - Import private key");
            Console.WriteLine("Esc - exit");
            var key = Console.ReadKey().Key;

            Console.WriteLine();
            switch (key)
            {
            case ConsoleKey.D1:
                ImportSeed();
                break;

            case ConsoleKey.D2:
                ImportSk();
                break;

            default:
                return;
            }
            Console.WriteLine();
            Console.Write("Enter current block hash: ");
            hash = Console.ReadLine();
            Console.Write("Enter account counter: ");
            counter = Console.ReadLine();
            int cnt = int.Parse(counter);

            Console.Write("Enter destination address: ");
            string to = Console.ReadLine();

            Console.Write("Enter amount: ");
            string amount = Console.ReadLine();

            Console.Write("Enter fee: ");
            string fee = Console.ReadLine();

            var hashBytesString = CryptoServices.DecodePrefixed(HashType.Block, hash).ToHexString();
            var toBytesString   = CryptoServices.DecodePrefixed(HashType.PublicKeyHash, to).ToHexString();

            Console.WriteLine();
            cnt++;
            string transferOp = hashBytesString + "080000" + CryptoServices.DecodePrefixed(HashType.PublicKeyHash, tz1).ToHexString() + int.Parse(fee).EncodeInt32() + cnt.EncodeInt32() + 400.EncodeInt32() + 0.EncodeInt32() +
                                ((int)(decimal.Parse(amount, CultureInfo.InvariantCulture) * 1000000)).EncodeInt32() + "01" + toBytesString + "0000";
            var opBytes    = ("03" + transferOp).HexToByteArray();
            var hashedData = CryptoServices.Hash(opBytes, 32);
            var bsign      = CryptoServices.CreateSignature(privateKey, hashedData);
            var inject     = transferOp + bsign.ToHexString();

            Console.WriteLine("Operation hex:");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(inject);
            Console.ForegroundColor = ConsoleColor.Gray;
        }
Example #2
0
        public Task <bool> Sign(string identityID, byte[] data, out byte[] signature)
        {
            Assert.AreEqual(this.identityID, identityID);

            signature = CryptoServices.CreateSignature(privateKey, data);

            return(Task.FromResult(true));
        }
Example #3
0
        public Task <bool> Sign(string identityID, byte[] data, out byte[] signature)
        {
            signature = null;

            // Find identity
            var identity = Find(identityID);

            if (identity != null)
            {
                if (identity.IsUnlocked)
                {
                    // Sign
                    signature = CryptoServices.CreateSignature(identity.PrivateKeyData, data);

                    return(Task.FromResult(true));
                }
            }

            return(Task.FromResult(false));
        }