diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-04 19:45:17 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-04 19:45:17 +0700 |
commit | 43746f99d8a5d44fd3ffff149f6941583a9a1cec (patch) | |
tree | 4649f6f49441a11d6d217157bab1cf7e5c5bcf0a /crypto/src | |
parent | Span-based variants for XDH/EdDSA (diff) | |
download | BouncyCastle.NET-ed25519-43746f99d8a5d44fd3ffff149f6941583a9a1cec.tar.xz |
Save heap allocations
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/math/ec/ECAlgorithms.cs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/src/math/ec/ECAlgorithms.cs b/crypto/src/math/ec/ECAlgorithms.cs index 64e68fccc..fcfab06f7 100644 --- a/crypto/src/math/ec/ECAlgorithms.cs +++ b/crypto/src/math/ec/ECAlgorithms.cs @@ -213,9 +213,15 @@ namespace Org.BouncyCastle.Math.EC { ECCurve cp = p.Curve; if (!c.Equals(cp)) - throw new ArgumentException("Point must be on the same curve", "p"); + throw new ArgumentException("Point must be on the same curve", nameof(p)); +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + Span<byte> encoding = stackalloc byte[p.GetEncodedLength(false)]; + p.EncodeTo(false, encoding); + return c.DecodePoint(encoding); +#else return c.DecodePoint(p.GetEncoded(false)); +#endif } internal static ECPoint ImplCheckResult(ECPoint p) |