Org.BouncyCastle.Math.BigInteger.CompareTo C# (CSharp) Method

CompareTo() public method

public CompareTo ( BigInteger value ) : int
value BigInteger
return int
		public int CompareTo(
			BigInteger value)
		{
			return sign < value.sign ? -1
				: sign > value.sign ? 1
				: sign == 0 ? 0
				: sign * CompareNoLeadingZeroes(0, magnitude, 0, value.magnitude);
		}

Same methods

BigInteger::CompareTo ( int xIndx, int x, int yIndx, int y ) : int
BigInteger::CompareTo ( object obj ) : int

Usage Example

Ejemplo n.º 1
1
        /// <summary>
        /// Generates a KeyPair using a BigInteger as a private key.
        /// BigInteger is checked for appropriate range.
        /// </summary>
        public KeyPair(BigInteger bi, bool compressed = false, byte addressType = 0)
        {
            this.IsCompressedPoint = compressed;
            this.AddressType = addressType;

            var ps = Org.BouncyCastle.Asn1.Sec.SecNamedCurves.GetByName("secp256k1");
            if (bi.CompareTo(ps.N) >= 0 || bi.SignValue <= 0) {
                throw new ArgumentException("BigInteger is out of range of valid private keys");
            }
            byte[] bb = Util.Force32Bytes(bi.ToByteArrayUnsigned());
            PrivateKeyBytes = bb;
        }
All Usage Examples Of Org.BouncyCastle.Math.BigInteger::CompareTo