<PackageReference Include="BouncyCastle.Cryptography" Version="2.6.0" />

ECKeyParameters

public abstract class ECKeyParameters : AsymmetricKeyParameter
using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Security; using System; using System.Collections.Generic; namespace Org.BouncyCastle.Crypto.Parameters { public abstract class ECKeyParameters : AsymmetricKeyParameter { private static readonly Dictionary<string, string> Algorithms = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "EC", "EC" }, { "ECDSA", "ECDSA" }, { "ECDH", "ECDH" }, { "ECDHC", "ECDHC" }, { "ECGOST3410", "ECGOST3410" }, { "ECMQV", "ECMQV" } }; private readonly string m_algorithm; private readonly ECDomainParameters m_parameters; public string AlgorithmName => m_algorithm; public ECDomainParameters Parameters => m_parameters; public DerObjectIdentifier PublicKeyParamSet => (m_parameters as ECNamedDomainParameters)?.Name; protected ECKeyParameters(string algorithm, bool isPrivate, ECDomainParameters parameters) : base(isPrivate) { if (algorithm == null) throw new ArgumentNullException("algorithm"); if (parameters == null) throw new ArgumentNullException("parameters"); m_algorithm = VerifyAlgorithmName(algorithm); m_parameters = parameters; } protected ECKeyParameters(string algorithm, bool isPrivate, DerObjectIdentifier publicKeyParamSet) : base(isPrivate) { if (algorithm == null) throw new ArgumentNullException("algorithm"); if (publicKeyParamSet == null) throw new ArgumentNullException("publicKeyParamSet"); m_algorithm = VerifyAlgorithmName(algorithm); m_parameters = ECNamedDomainParameters.LookupOid(publicKeyParamSet); } public override bool Equals(object obj) { ECKeyParameters eCKeyParameters = obj as ECKeyParameters; if (eCKeyParameters != null) return Equals(eCKeyParameters); return false; } protected bool Equals(ECKeyParameters other) { if (m_parameters.Equals(other.m_parameters)) return Equals((AsymmetricKeyParameter)other); return false; } public override int GetHashCode() { return m_parameters.GetHashCode() ^ base.GetHashCode(); } internal ECKeyGenerationParameters CreateKeyGenerationParameters(SecureRandom random) { return new ECKeyGenerationParameters(m_parameters, random); } internal static string VerifyAlgorithmName(string algorithm) { if (!Algorithms.TryGetValue(algorithm, out string value)) throw new ArgumentException("unrecognised algorithm: " + algorithm, "algorithm"); return value; } } }