Esempio n. 1
0
		public DerInteger(
            BigInteger value)
        {
            if (value == null)
                throw new ArgumentNullException("value");

			bytes = value.ToByteArray();
        }
Esempio n. 2
0
        internal static Array BigIntegerToBytes(NBitcoin.BouncyCastle.Math.BigInteger b, int numBytes)
        {
            if (b == null)
            {
                return(null);
            }
            byte[] bytes   = new byte[numBytes];
            byte[] biBytes = b.ToByteArray();
            int    start   = (biBytes.Length == numBytes + 1) ? 1 : 0;
            int    length  = Math.Min(biBytes.Length, numBytes);

            Array.Copy(biBytes, start, bytes, numBytes - length, length);
            return(bytes);
        }
Esempio n. 3
0
		private byte[] int2octets(BigInteger v)
		{
			byte[] @out = v.ToByteArray();
			if(@out.Length < rolen)
			{
				byte[] out2 = new byte[rolen];
				Array.Copy(@out, 0,
						out2, rolen - @out.Length,
						@out.Length);
				return out2;
			}
			else if(@out.Length > rolen)
			{
				byte[] out2 = new byte[rolen];
				Array.Copy(@out, @out.Length - rolen,
						out2, 0, rolen);
				return out2;
			}
			else
			{
				return @out;
			}
		}
Esempio n. 4
0
 public DerEnumerated(
     BigInteger val)
 {
     bytes = val.ToByteArray();
 }