diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-17 00:32:42 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-17 00:32:42 +0700 |
commit | 53a114b1704b0833c2d99c8d0e4ba4fcb6ed09c1 (patch) | |
tree | 36d10593bc4b21a9841b6747d81c2eecfa7217e6 | |
parent | EdDSA improvements (diff) | |
download | BouncyCastle.NET-ed25519-53a114b1704b0833c2d99c8d0e4ba4fcb6ed09c1.tar.xz |
BigInteger implements IComparable
-rw-r--r-- | crypto/src/math/BigInteger.cs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crypto/src/math/BigInteger.cs b/crypto/src/math/BigInteger.cs index c8581775d..5b2ea0d87 100644 --- a/crypto/src/math/BigInteger.cs +++ b/crypto/src/math/BigInteger.cs @@ -16,7 +16,7 @@ namespace Org.BouncyCastle.Math { [Serializable] public sealed class BigInteger - : IComparable<BigInteger>, IEquatable<BigInteger> + : IComparable, IComparable<BigInteger>, IEquatable<BigInteger> { // The first few odd primes /* @@ -1051,6 +1051,17 @@ namespace Org.BouncyCastle.Math return sign > 0 && nBits == 1; } + public int CompareTo(object obj) + { + if (obj == null) + return 1; + + if (!(obj is BigInteger other)) + throw new ArgumentException("Object is not a BigInteger", nameof(obj)); + + return CompareTo(other); + } + public int CompareTo(BigInteger other) { if (other == null) |