diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-19 15:47:12 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-19 15:47:12 +0700 |
commit | 3f747e4fc26b9b55f91b5898ba774af001e30247 (patch) | |
tree | b4bef4badc22d4849c5f60f6320c5a45a8eaa83b /crypto/src/math | |
parent | Move classes up into Org.BC.Crypto (diff) | |
download | BouncyCastle.NET-ed25519-3f747e4fc26b9b55f91b5898ba774af001e30247.tar.xz |
Save an inversion in ECDSA verification for common cases
Diffstat (limited to '')
-rw-r--r-- | crypto/src/math/ec/ECCurve.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crypto/src/math/ec/ECCurve.cs b/crypto/src/math/ec/ECCurve.cs index fa2c72570..6ccd97e7b 100644 --- a/crypto/src/math/ec/ECCurve.cs +++ b/crypto/src/math/ec/ECCurve.cs @@ -96,6 +96,7 @@ namespace Org.BouncyCastle.Math.EC public abstract int FieldSize { get; } public abstract ECFieldElement FromBigInteger(BigInteger x); + public abstract bool IsValidFieldElement(BigInteger x); public virtual Config Configure() { @@ -477,6 +478,11 @@ namespace Org.BouncyCastle.Math.EC { } + public override bool IsValidFieldElement(BigInteger x) + { + return x != null && x.SignValue >= 0 && x.CompareTo(Field.Characteristic) < 0; + } + protected override ECPoint DecompressPoint(int yTilde, BigInteger X1) { ECFieldElement x = FromBigInteger(X1); @@ -670,6 +676,11 @@ namespace Org.BouncyCastle.Math.EC { } + public override bool IsValidFieldElement(BigInteger x) + { + return x != null && x.SignValue >= 0 && x.BitLength <= FieldSize; + } + [Obsolete("Per-point compression property will be removed")] public override ECPoint CreatePoint(BigInteger x, BigInteger y, bool withCompression) { |