Example #1
0
 public Transfer PayTo(Transfer trans, byte[] destinyPk)
 {
     var prevHash = new TransferHash(trans, mySig);
     return new Transfer(prevHash, destinyPk);
 }
Example #2
0
        public TransferHash(Transfer trans, Signature mySignature)
        {
            this.transfer = trans;
            var serializedTrans = SerializeObject(trans);

            this.sgndTrans     = mySignature.SignHash(serializedTrans);
            this.hashSgndTrans = Hash(sgndTrans.SignedData);


            //var hexStr = ByteArrayToString(transHash);
            //Console.WriteLine(hexStr);
            //Console.WriteLine(ToString(transHash));
            //Console.WriteLine(EndianFlip32BitChunks(ToString(transHash)));
            //var hashcomp = StringToByteArray(hexStr);

            //bool bRet;
            //for (int x = 0; x < transHash.Length; x++)
            //{
            //    if (this.transHash[x] != hashcomp[x])
            //    {
            //        bRet = false;
            //    }
            //}

            //bRet = true;

            ////var text = Encoding.ASCII.GetBytes("hello");
            ////var Hash1 = Hash(text);
            ////var Hash2 = Hash(Hash1);
            ////Console.WriteLine(ByteArrayToString(Hash2));

            //Console.WriteLine("test");

            ////var test = "8c14f0db3df150123e6f3dbbf30f8b955a8249b62ac1d1ff16284aefa3d06d87";
            ////var bytet = StringToByteArray(test);

            ////Console.WriteLine(Encoding.Default.GetString(bytet));
            ////var hexStr = BitConverter.ToString(transHash).Replace("-", "").ToLowerInvariant();
            ////Console.WriteLine("0x" + hexStr);
            ////Console.WriteLine(ToHexString(transHash));



            //var a = "8c14f0db3df150123e6f3dbbf30f8b955a8249b62ac1d1ff16284aefa3d06d87";
            //var b = "fff2525b8931402dd09222c50775608f75787bd2b87e56995a7bdd30f79702c4";

            ////error 204ee246463fecd48b2071a6512204cf952a006f8fc08bb61d0cbd8f53b063e0
            //var hash1b = StringToByteArray(a + b);
            //var hash1 = Hash(Hash(hash1b));
            //var hash2 = Hash(hash1);

            //Console.WriteLine(ByteArrayToString(hash2));

            //Console.WriteLine("Reverse");

            //var revA = Reverse(a);
            //var revB = Reverse(b);

            ////expected ccdafb73d8dcd0173d5d5c3c9a0770d0b3953db889dab99ef05b1907518cb815
            //var hasha = Hash(ToBytes(revA + revB));
            //var hashb = Hash(hasha);
            ////var hashc = Hash(StringToByteArray(Reverse(ByteArrayToString(hash12))));
            //var ret = ByteArrayToString(hashb);
            //Console.WriteLine(ret);



            //Console.WriteLine("bitcoin");
            //var a2 = "b1fea52486ce0c62bb442b530a3f0132b826c74e473d1f2c220bfa78111c5082";
            //var b2 = "f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16";
            //var reva2 = Reverse(a2);
            //var revb2 = Reverse(b2);
            //var bhash2 = StringToByteArray(reva2 + revb2);
            ////var bhash2 = StringToByteArray(Reverse(b2+a2));
            //var hash2 = Hash(bhash2);
            //var revhash2 = Reverse(ByteArrayToString(hash2));
            //var revhash2b = StringToByteArray(revhash2);
            //Console.WriteLine(ByteArrayToString(revhash2b));



            //Console.ReadKey();
        }
Example #3
0
        public TransferHash(Transfer trans, Signature mySignature)
        {
            this.transfer = trans;
            var serializedTrans = SerializeObject(trans);
            this.sgndTrans = mySignature.SignHash(serializedTrans);
            this.hashSgndTrans = Hash(sgndTrans.SignedData);

            //var hexStr = ByteArrayToString(transHash);
            //Console.WriteLine(hexStr);
            //Console.WriteLine(ToString(transHash));
            //Console.WriteLine(EndianFlip32BitChunks(ToString(transHash)));
            //var hashcomp = StringToByteArray(hexStr);

            //bool bRet;
            //for (int x = 0; x < transHash.Length; x++)
            //{
            //    if (this.transHash[x] != hashcomp[x])
            //    {
            //        bRet = false;
            //    }
            //}

            //bRet = true;

            ////var text = Encoding.ASCII.GetBytes("hello");
            ////var Hash1 = Hash(text);
            ////var Hash2 = Hash(Hash1);
            ////Console.WriteLine(ByteArrayToString(Hash2));

            //Console.WriteLine("test");

            ////var test = "8c14f0db3df150123e6f3dbbf30f8b955a8249b62ac1d1ff16284aefa3d06d87";
            ////var bytet = StringToByteArray(test);

            ////Console.WriteLine(Encoding.Default.GetString(bytet));
            ////var hexStr = BitConverter.ToString(transHash).Replace("-", "").ToLowerInvariant();
            ////Console.WriteLine("0x" + hexStr);
            ////Console.WriteLine(ToHexString(transHash));

            //var a = "8c14f0db3df150123e6f3dbbf30f8b955a8249b62ac1d1ff16284aefa3d06d87";
            //var b = "fff2525b8931402dd09222c50775608f75787bd2b87e56995a7bdd30f79702c4";

            ////error 204ee246463fecd48b2071a6512204cf952a006f8fc08bb61d0cbd8f53b063e0
            //var hash1b = StringToByteArray(a + b);
            //var hash1 = Hash(Hash(hash1b));
            //var hash2 = Hash(hash1);

            //Console.WriteLine(ByteArrayToString(hash2));

            //Console.WriteLine("Reverse");

            //var revA = Reverse(a);
            //var revB = Reverse(b);

            ////expected ccdafb73d8dcd0173d5d5c3c9a0770d0b3953db889dab99ef05b1907518cb815
            //var hasha = Hash(ToBytes(revA + revB));
            //var hashb = Hash(hasha);
            ////var hashc = Hash(StringToByteArray(Reverse(ByteArrayToString(hash12))));
            //var ret = ByteArrayToString(hashb);
            //Console.WriteLine(ret);

            //Console.WriteLine("bitcoin");
            //var a2 = "b1fea52486ce0c62bb442b530a3f0132b826c74e473d1f2c220bfa78111c5082";
            //var b2 = "f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16";
            //var reva2 = Reverse(a2);
            //var revb2 = Reverse(b2);
            //var bhash2 = StringToByteArray(reva2 + revb2);
            ////var bhash2 = StringToByteArray(Reverse(b2+a2));
            //var hash2 = Hash(bhash2);
            //var revhash2 = Reverse(ByteArrayToString(hash2));
            //var revhash2b = StringToByteArray(revhash2);
            //Console.WriteLine(ByteArrayToString(revhash2b));

            //Console.ReadKey();
        }
Example #4
0
        public Transfer PayTo(Transfer trans, byte[] destinyPk)
        {
            var prevHash = new TransferHash(trans, mySig);

            return(new Transfer(prevHash, destinyPk));
        }