Пример #1
0
        /// <summary>
        /// Creates a new Golomb-Rice filter from the data byte array which
        /// contains a serialized filter.
        /// </summary>
        /// <param name="data">A serialized Golomb-Rice filter.</param>
        /// <param name="p">The P value to use.</param>
        public GolombRiceFilter(byte[] data, byte p)
        {
            P = p;
            var n      = new VarInt();
            var stream = new BitcoinStream(data);

            stream.ReadWrite(ref n);
            N = (int)n.ToLong();
            var l = n.ToBytes().Length;

            Data = data.SafeSubarray(l);
        }
Пример #2
0
        //http://bitcoinj.googlecode.com/git-history/keychain/core/src/main/java/com/google/bitcoin/core/Utils.java
        internal static byte[] FormatMessageForSigning(byte[] messageBytes)
        {
            MemoryStream ms = new MemoryStream();

            ms.WriteByte((byte)BITCOIN_SIGNED_MESSAGE_HEADER_BYTES.Length);
            Write(ms, BITCOIN_SIGNED_MESSAGE_HEADER_BYTES);

            VarInt size = new VarInt((ulong)messageBytes.Length);

            Write(ms, size.ToBytes());
            Write(ms, messageBytes);
            return(ms.ToArray());
        }
Пример #3
0
		//http://bitcoinj.googlecode.com/git-history/keychain/core/src/main/java/com/google/bitcoin/core/Utils.java
		public static byte[] FormatMessageForSigning(string messageText)
		{
			MemoryStream ms = new MemoryStream();
			var message = Encoding.UTF8.GetBytes(messageText);

			ms.WriteByte((byte)BITCOIN_SIGNED_MESSAGE_HEADER_BYTES.Length);
			Write(ms, BITCOIN_SIGNED_MESSAGE_HEADER_BYTES);

			VarInt size = new VarInt((ulong)message.Length);
			Write(ms, size.ToBytes());
			Write(ms, message);
			return ms.ToArray();
		}