Beispiel #1
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());
        }
        /// <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>
        /// <param name="m">The M value to use.</param>
        public GolombRiceFilter(byte[] data, byte p, uint m)
        {
            P = p;
            M = m;
            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);
        }