Ejemplo n.º 1
0
        /// <summary>	Calculates the bitshares address from a bitcoin public key. </summary>
        ///
        /// <remarks>	Paul, 08/12/2014. </remarks>
        ///
        /// <param name="compressedBtcPubKey">	The compressed btc pub key. </param>
        /// <param name="ripe">				  	The ripe. </param>
        ///
        /// <returns>	The calculated bitshares address from btc pub key bytes. </returns>
        public static byte[] ComputeBitsharesAddressFromBtcPubKey(byte[] compressedBtcPubKey, RIPEMD160 ripe)
        {
            byte[] sha512 = Crypto.ComputeSha512(compressedBtcPubKey);
            byte[] addr = ripe.ComputeHash(sha512);
            byte[] check = ripe.ComputeHash(addr);

            byte[] addrFinal = new byte[20 + 4];
            addr.CopyTo(addrFinal, 0);

            Buffer.BlockCopy(check, 0, addrFinal, 20, 4);
            return addrFinal;
        }
Ejemplo n.º 2
0
        public void Execute()
        {
            Progress(0.5, 1.0);

            if (inputData != null && inputData.Length >= 0)
            {
                System.Security.Cryptography.RIPEMD160 ripeMd160Hash = System.Security.Cryptography.RIPEMD160.Create();
                using (CStreamReader reader = inputData.CreateReader())
                {
                    OutputData = ripeMd160Hash.ComputeHash(reader);
                }

                GuiLogMessage("Hash created.", NotificationLevel.Info);
                Progress(1, 1);
            }
            else
            {
                if (inputData == null)
                {
                    GuiLogMessage("Received null value for CryptoolStream.", NotificationLevel.Warning);
                }
                else
                {
                    GuiLogMessage("No input stream.", NotificationLevel.Warning);
                }
            }

            Progress(1.0, 1.0);
        }
Ejemplo n.º 3
0
        public override string StringHashAlgorithm(string value)
        {
            System.Security.Cryptography.RIPEMD160 md5_160Bit = System.Security.Cryptography.RIPEMD160.Create();
            byte[]        bytes = md5_160Bit.ComputeHash(System.Text.ASCIIEncoding.UTF8.GetBytes(value));
            StringBuilder sb    = new StringBuilder();

            foreach (var b in bytes)
            {
                sb.Append(b.ToString("x2"));
            }
            return(sb.ToString());
        }
		public void RIPEMD160_c (string testName, RIPEMD160 hash, byte[] input, byte[] result) 
		{
			MemoryStream ms = new MemoryStream (input);
			byte[] output = hash.ComputeHash (ms); 
			AssertEquals (testName + ".c.1", result, output);
			AssertEquals (testName + ".c.2", result, hash.Hash);
			// required or next operation will still return old hash
			hash.Initialize ();
		}
		public void RIPEMD160_b (string testName, RIPEMD160 hash, byte[] input, byte[] result) 
		{
			byte[] output = hash.ComputeHash (input, 0, input.Length); 
			AssertEquals (testName + ".b.1", result, output);
			AssertEquals (testName + ".b.2", result, hash.Hash);
			// required or next operation will still return old hash
			hash.Initialize ();
		}
Ejemplo n.º 6
0
 /// <summary>	Calculates the bitshares pubilc key from bitcoin public key. </summary>
 ///
 /// <remarks>	Paul, 08/12/2014. </remarks>
 ///
 /// <param name="compressedBtcPubKey">	The compressed btc pub key. </param>
 /// <param name="ripe">				  	The ripe. </param>
 ///
 /// <returns>	The calculated bitshares pub key from btc pub key bytes. </returns>
 public static byte[] ComputeBitsharesPubKeyFromBtcPubKey(byte[] compressedBtcPubKey, RIPEMD160 ripe)
 {
     byte[] pubkeyCheck = ripe.ComputeHash(compressedBtcPubKey);
     byte[] pubkeyFinal = new byte[37];
     compressedBtcPubKey.CopyTo(pubkeyFinal, 0);
     Buffer.BlockCopy(pubkeyCheck, 0, pubkeyFinal, 37 - 4, 4);
     return pubkeyFinal;
 }
Ejemplo n.º 7
0
 public override byte[] ByteHashAlgorithm(string value)
 {
     System.Security.Cryptography.RIPEMD160 md5_160Bit = System.Security.Cryptography.RIPEMD160.Create();
     byte[] bytes = md5_160Bit.ComputeHash(System.Text.ASCIIEncoding.UTF8.GetBytes(value));
     return(bytes);
 }