Skip to content

OnixLabs.Security.Cryptography.IEcdsaPublicKey

matthew edited this page May 27, 2026 · 1 revision

IEcdsaPublicKey Interface

Defines an ECDSA cryptographic public key.

Namespace OnixLabs.Security.Cryptography
Assembly OnixLabs.Security.Cryptography.dll (NuGet)
Implements IPublicKeyImportable<EcdsaPublicKey>, IPublicKeyExportable, IBinaryConvertible

Definition

public interface IEcdsaPublicKey :
    IPublicKeyImportable<EcdsaPublicKey>,
    IPublicKeyExportable,
    IBinaryConvertible

Remarks

IEcdsaPublicKey provides two families of verification operation:

  • IsDataValid — returns true or false without throwing.
  • VerifyData — throws if the signature is invalid (useful for fail-fast paths).

Both families operate on data (hashing before verifying) or on a pre-computed hash (IsHashValid / VerifyHash). Data overloads accept raw bytes, byte-range slices, Stream, and IBinaryConvertible. Signature overloads accept either a raw ReadOnlySpan<byte> or a DigitalSignature value. Hash-algorithm overloads accept either a HashAlgorithm instance or a HashAlgorithmName. All overloads accept an optional DSASignatureFormat.

Methods

Member Returns Description
IsDataValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>, HashAlgorithm, DSASignatureFormat) bool Checks if a span of data was signed with the given signature (HashAlgorithm).
IsDataValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>, int, int, HashAlgorithm, DSASignatureFormat) bool Checks if a byte-range slice was signed with the given signature (HashAlgorithm).
IsDataValid(ReadOnlySpan<byte>, Stream, HashAlgorithm, DSASignatureFormat) bool Checks if a stream was signed with the given signature (HashAlgorithm).
IsDataValid(ReadOnlySpan<byte>, IBinaryConvertible, HashAlgorithm, DSASignatureFormat) bool Checks if an IBinaryConvertible was signed with the given signature (HashAlgorithm).
IsDataValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>, HashAlgorithmName, DSASignatureFormat) bool Checks if a span of data was signed with the given signature (HashAlgorithmName).
IsDataValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>, int, int, HashAlgorithmName, DSASignatureFormat) bool Checks if a byte-range slice was signed with the given signature (HashAlgorithmName).
IsDataValid(ReadOnlySpan<byte>, Stream, HashAlgorithmName, DSASignatureFormat) bool Checks if a stream was signed with the given signature (HashAlgorithmName).
IsDataValid(ReadOnlySpan<byte>, IBinaryConvertible, HashAlgorithmName, DSASignatureFormat) bool Checks if an IBinaryConvertible was signed with the given signature (HashAlgorithmName).
IsDataValid(DigitalSignature, ReadOnlySpan<byte>, HashAlgorithm, DSASignatureFormat) bool Checks if a span was signed with a DigitalSignature (HashAlgorithm).
IsDataValid(DigitalSignature, ReadOnlySpan<byte>, int, int, HashAlgorithm, DSASignatureFormat) bool Checks if a byte-range slice was signed with a DigitalSignature (HashAlgorithm).
IsDataValid(DigitalSignature, Stream, HashAlgorithm, DSASignatureFormat) bool Checks if a stream was signed with a DigitalSignature (HashAlgorithm).
IsDataValid(DigitalSignature, IBinaryConvertible, HashAlgorithm, DSASignatureFormat) bool Checks if an IBinaryConvertible was signed with a DigitalSignature (HashAlgorithm).
IsDataValid(DigitalSignature, ReadOnlySpan<byte>, HashAlgorithmName, DSASignatureFormat) bool Checks if a span was signed with a DigitalSignature (HashAlgorithmName).
IsDataValid(DigitalSignature, ReadOnlySpan<byte>, int, int, HashAlgorithmName, DSASignatureFormat) bool Checks if a byte-range slice was signed with a DigitalSignature (HashAlgorithmName).
IsDataValid(DigitalSignature, Stream, HashAlgorithmName, DSASignatureFormat) bool Checks if a stream was signed with a DigitalSignature (HashAlgorithmName).
IsDataValid(DigitalSignature, IBinaryConvertible, HashAlgorithmName, DSASignatureFormat) bool Checks if an IBinaryConvertible was signed with a DigitalSignature (HashAlgorithmName).
IsHashValid(ReadOnlySpan<byte>, Hash, DSASignatureFormat) bool Checks if a Hash was signed with the given raw signature.
IsHashValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>, DSASignatureFormat) bool Checks if a raw hash span was signed with the given raw signature.
IsHashValid(DigitalSignature, Hash, DSASignatureFormat) bool Checks if a Hash was signed with a DigitalSignature.
IsHashValid(DigitalSignature, ReadOnlySpan<byte>, DSASignatureFormat) bool Checks if a raw hash span was signed with a DigitalSignature.
VerifyData(ReadOnlySpan<byte>, ReadOnlySpan<byte>, HashAlgorithm, DSASignatureFormat) void Verifies a span of data (HashAlgorithm); throws on failure.
VerifyData(ReadOnlySpan<byte>, ReadOnlySpan<byte>, int, int, HashAlgorithm, DSASignatureFormat) void Verifies a byte-range slice (HashAlgorithm); throws on failure.
VerifyData(ReadOnlySpan<byte>, Stream, HashAlgorithm, DSASignatureFormat) void Verifies a stream (HashAlgorithm); throws on failure.
VerifyData(ReadOnlySpan<byte>, IBinaryConvertible, HashAlgorithm, DSASignatureFormat) void Verifies an IBinaryConvertible (HashAlgorithm); throws on failure.
VerifyData(ReadOnlySpan<byte>, ReadOnlySpan<byte>, HashAlgorithmName, DSASignatureFormat) void Verifies a span of data (HashAlgorithmName); throws on failure.
VerifyData(ReadOnlySpan<byte>, ReadOnlySpan<byte>, int, int, HashAlgorithmName, DSASignatureFormat) void Verifies a byte-range slice (HashAlgorithmName); throws on failure.
VerifyData(ReadOnlySpan<byte>, Stream, HashAlgorithmName, DSASignatureFormat) void Verifies a stream (HashAlgorithmName); throws on failure.
VerifyData(ReadOnlySpan<byte>, IBinaryConvertible, HashAlgorithmName, DSASignatureFormat) void Verifies an IBinaryConvertible (HashAlgorithmName); throws on failure.
VerifyData(DigitalSignature, ReadOnlySpan<byte>, HashAlgorithm, DSASignatureFormat) void Verifies a span using a DigitalSignature (HashAlgorithm); throws on failure.
VerifyData(DigitalSignature, ReadOnlySpan<byte>, int, int, HashAlgorithm, DSASignatureFormat) void Verifies a byte-range slice using a DigitalSignature (HashAlgorithm); throws on failure.
VerifyData(DigitalSignature, Stream, HashAlgorithm, DSASignatureFormat) void Verifies a stream using a DigitalSignature (HashAlgorithm); throws on failure.
VerifyData(DigitalSignature, IBinaryConvertible, HashAlgorithm, DSASignatureFormat) void Verifies an IBinaryConvertible using a DigitalSignature (HashAlgorithm); throws on failure.
VerifyData(DigitalSignature, ReadOnlySpan<byte>, HashAlgorithmName, DSASignatureFormat) void Verifies a span using a DigitalSignature (HashAlgorithmName); throws on failure.
VerifyData(DigitalSignature, ReadOnlySpan<byte>, int, int, HashAlgorithmName, DSASignatureFormat) void Verifies a byte-range slice using a DigitalSignature (HashAlgorithmName); throws on failure.
VerifyData(DigitalSignature, Stream, HashAlgorithmName, DSASignatureFormat) void Verifies a stream using a DigitalSignature (HashAlgorithmName); throws on failure.
VerifyData(DigitalSignature, IBinaryConvertible, HashAlgorithmName, DSASignatureFormat) void Verifies an IBinaryConvertible using a DigitalSignature (HashAlgorithmName); throws on failure.
VerifyHash(ReadOnlySpan<byte>, Hash, DSASignatureFormat) void Verifies a Hash with a raw signature; throws on failure.
VerifyHash(ReadOnlySpan<byte>, ReadOnlySpan<byte>, DSASignatureFormat) void Verifies a raw hash span with a raw signature; throws on failure.
VerifyHash(DigitalSignature, Hash, DSASignatureFormat) void Verifies a Hash with a DigitalSignature; throws on failure.
VerifyHash(DigitalSignature, ReadOnlySpan<byte>, DSASignatureFormat) void Verifies a raw hash span with a DigitalSignature; throws on failure.

IsDataValid overloads

bool IsDataValid(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, HashAlgorithm algorithm, DSASignatureFormat format = default);
bool IsDataValid(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithm algorithm, DSASignatureFormat format = default);
bool IsDataValid(ReadOnlySpan<byte> signature, Stream data, HashAlgorithm algorithm, DSASignatureFormat format = default);
bool IsDataValid(ReadOnlySpan<byte> signature, IBinaryConvertible data, HashAlgorithm algorithm, DSASignatureFormat format = default);
bool IsDataValid(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, HashAlgorithmName algorithm, DSASignatureFormat format = default);
bool IsDataValid(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithmName algorithm, DSASignatureFormat format = default);
bool IsDataValid(ReadOnlySpan<byte> signature, Stream data, HashAlgorithmName algorithm, DSASignatureFormat format = default);
bool IsDataValid(ReadOnlySpan<byte> signature, IBinaryConvertible data, HashAlgorithmName algorithm, DSASignatureFormat format = default);
bool IsDataValid(DigitalSignature signature, ReadOnlySpan<byte> data, HashAlgorithm algorithm, DSASignatureFormat format = default);
bool IsDataValid(DigitalSignature signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithm algorithm, DSASignatureFormat format = default);
bool IsDataValid(DigitalSignature signature, Stream data, HashAlgorithm algorithm, DSASignatureFormat format = default);
bool IsDataValid(DigitalSignature signature, IBinaryConvertible data, HashAlgorithm algorithm, DSASignatureFormat format = default);
bool IsDataValid(DigitalSignature signature, ReadOnlySpan<byte> data, HashAlgorithmName algorithm, DSASignatureFormat format = default);
bool IsDataValid(DigitalSignature signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithmName algorithm, DSASignatureFormat format = default);
bool IsDataValid(DigitalSignature signature, Stream data, HashAlgorithmName algorithm, DSASignatureFormat format = default);
bool IsDataValid(DigitalSignature signature, IBinaryConvertible data, HashAlgorithmName algorithm, DSASignatureFormat format = default);

Determines whether the specified data was signed by the ECDSA private key corresponding to this public key, and that the signed data matches the provided signature.

Parameter Type Description
signature ReadOnlySpan<byte> or DigitalSignature The signature to validate.
data ReadOnlySpan<byte> / Stream / IBinaryConvertible The unsigned data to validate.
offset int (slice overloads) The offset into the span from which to begin reading.
count int (slice overloads) The number of bytes to read from the span.
algorithm HashAlgorithm or HashAlgorithmName The hash algorithm used when signing.
format DSASignatureFormat The digital signature format (IEEE P1363 or DER). Defaults to DSASignatureFormat.IeeeP1363FixedFieldConcatenation.

Returns — true if the signature is valid for the supplied data; otherwise false.


IsHashValid overloads

bool IsHashValid(ReadOnlySpan<byte> signature, Hash hash, DSASignatureFormat format = default);
bool IsHashValid(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> hash, DSASignatureFormat format = default);
bool IsHashValid(DigitalSignature signature, Hash hash, DSASignatureFormat format = default);
bool IsHashValid(DigitalSignature signature, ReadOnlySpan<byte> hash, DSASignatureFormat format = default);

Determines whether the specified pre-computed hash was signed by the ECDSA private key corresponding to this public key, and that the hash matches the provided signature.

Parameter Type Description
signature ReadOnlySpan<byte> or DigitalSignature The signature to validate.
hash Hash or ReadOnlySpan<byte> The pre-computed hash to validate.
format DSASignatureFormat The digital signature format. Defaults to DSASignatureFormat.IeeeP1363FixedFieldConcatenation.

Returns — true if the signature is valid for the supplied hash; otherwise false.


VerifyData overloads

void VerifyData(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, HashAlgorithm algorithm, DSASignatureFormat format = default);
void VerifyData(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithm algorithm, DSASignatureFormat format = default);
void VerifyData(ReadOnlySpan<byte> signature, Stream data, HashAlgorithm algorithm, DSASignatureFormat format = default);
void VerifyData(ReadOnlySpan<byte> signature, IBinaryConvertible data, HashAlgorithm algorithm, DSASignatureFormat format = default);
void VerifyData(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, HashAlgorithmName algorithm, DSASignatureFormat format = default);
void VerifyData(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithmName algorithm, DSASignatureFormat format = default);
void VerifyData(ReadOnlySpan<byte> signature, Stream data, HashAlgorithmName algorithm, DSASignatureFormat format = default);
void VerifyData(ReadOnlySpan<byte> signature, IBinaryConvertible data, HashAlgorithmName algorithm, DSASignatureFormat format = default);
void VerifyData(DigitalSignature signature, ReadOnlySpan<byte> data, HashAlgorithm algorithm, DSASignatureFormat format = default);
void VerifyData(DigitalSignature signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithm algorithm, DSASignatureFormat format = default);
void VerifyData(DigitalSignature signature, Stream data, HashAlgorithm algorithm, DSASignatureFormat format = default);
void VerifyData(DigitalSignature signature, IBinaryConvertible data, HashAlgorithm algorithm, DSASignatureFormat format = default);
void VerifyData(DigitalSignature signature, ReadOnlySpan<byte> data, HashAlgorithmName algorithm, DSASignatureFormat format = default);
void VerifyData(DigitalSignature signature, ReadOnlySpan<byte> data, int offset, int count, HashAlgorithmName algorithm, DSASignatureFormat format = default);
void VerifyData(DigitalSignature signature, Stream data, HashAlgorithmName algorithm, DSASignatureFormat format = default);
void VerifyData(DigitalSignature signature, IBinaryConvertible data, HashAlgorithmName algorithm, DSASignatureFormat format = default);

Verifies that the specified data was signed by the ECDSA private key corresponding to this public key. Throws if verification fails.

Parameters match those of the IsDataValid overloads above.

Exceptions — Throws (implementation-defined, typically CryptographicException) if the signature is not valid for the supplied data and key.


VerifyHash overloads

void VerifyHash(ReadOnlySpan<byte> signature, Hash hash, DSASignatureFormat format = default);
void VerifyHash(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> hash, DSASignatureFormat format = default);
void VerifyHash(DigitalSignature signature, Hash hash, DSASignatureFormat format = default);
void VerifyHash(DigitalSignature signature, ReadOnlySpan<byte> hash, DSASignatureFormat format = default);

Verifies that the specified pre-computed hash was signed by the ECDSA private key corresponding to this public key. Throws if verification fails.

Parameters match those of the IsHashValid overloads above.

Exceptions — Throws (implementation-defined, typically CryptographicException) if the signature is not valid for the supplied hash and key.

See Also

ONIXLabs .NET Library


Clone this wiki locally