Exemplo n.º 1
0
        private static bool TryMirrorPubKey(PubKey pubKey, out PubKey mirrorPubKey)
        {
            var pubKeyStr = HexHashUtil.ByteArrayToString(pubKey.ToBytes());

            var reversedArray = pubKeyStr.Substring(10, 54).ToCharArray();

            Array.Reverse(reversedArray);

            var mirrorPubKeyStr =
                pubKeyStr.Substring(0, 8)
                + pubKeyStr.Substring(8, 2)
                + new string(reversedArray)
                + pubKeyStr.Substring(64, 2);
            var mirrorPubKeyBytes = HexHashUtil.StringToByteArray(mirrorPubKeyStr);

            try
            {
                mirrorPubKey = new PubKey(mirrorPubKeyBytes, false);
                return(false);
            }
            catch (Exception)
            {
                //Console.WriteLine(ex.InnerException);
                mirrorPubKey = new PubKey(mirrorPubKeyBytes, true);
                return(true);
            }
        }
Exemplo n.º 2
0
        public void HashSHA256Test()
        {
            Shift shift = new Shift(0D,
                                    1530914381,
                                    "32ad9e02792599dfdb6a9d0bc0b924da23bd96b1b7eb4f0a68",
                                    7234,
                                    "00000000090d6c6b058227bb61ca2915a84998703d4444cc2641e6a0da4ba37e",
                                    2,
                                    "163d2e383c77765232be1d9ed5e06749a814de49b4c0a8aebf324c0e9e2fd1cf",
                                    1.00m,
                                    0.0001m);

            var bytes       = HexHashUtil.StringToByteArray(shift.AdHex);
            var hashedBytes = HexHashUtil.HashSHA256(bytes);
            var hash        = HexHashUtil.ByteArrayToString(hashedBytes);

            Assert.AreEqual("bcd35d9f6de167fada34bfeb0c59d2b1a55974b9460c54f42dfff2e86cf8c58b", hash);
        }