Skip to content

OnixLabs.Security.Cryptography.EddsaPublicKey

matthew edited this page May 27, 2026 · 2 revisions

EddsaPublicKey Class

Represents an EdDSA (Edwards-curve Digital Signature Algorithm) cryptographic public key, as specified in RFC 8032 (Ed25519, PureEdDSA).

Namespace OnixLabs.Security.Cryptography
Assembly OnixLabs.Security.Cryptography.dll (NuGet)
Inheritance object → PublicKey → EddsaPublicKey
Implements IEddsaPublicKey, ISpanParsable<EddsaPublicKey>, IPublicKeyImportable<EddsaPublicKey>, IPublicKeyRawImportable<EddsaPublicKey>, IPublicKeyPemImportable<EddsaPublicKey>, IPublicKeyExportable, IPublicKeyRawExportable, IPublicKeyPemExportable, ICryptoPrimitive<PublicKey>, IValueEquatable<PublicKey>, IEquatable<PublicKey>, IBinaryConvertible

Definition

public sealed partial class EddsaPublicKey : PublicKey, IEddsaPublicKey, ISpanParsable<EddsaPublicKey>

Remarks

EddsaPublicKey holds a 32-byte Ed25519 public-key point. Unlike its counterpart EddsaPrivateKey, it carries no sensitive material and therefore does not implement IDisposable.

Signature verification is performed by the IsDataValid family of methods. Each overload accepts a signature (as ReadOnlySpan<byte> or DigitalSignature) paired with the original message in one of four forms: ReadOnlySpan<byte>, a sliced span with offset and count, Stream, or IBinaryConvertible. All overloads return true when the signature is valid and false otherwise — they never throw on a bad signature.

The VerifyData family mirrors IsDataValid but throws CryptographicException on verification failure, which is convenient when a failed signature should terminate the execution path rather than be handled as a conditional.

Note Because PureEdDSA hashes the message twice internally, IsDataValid and VerifyData must hold the entire message in memory. The Stream overloads read the stream to completion into a buffer before verifying.

Key material can be imported and exported in two formats:

  • Raw public-key bytes — the bare 32-byte Ed25519 public point (Import / Export).
  • RFC 7468 PEM — a SubjectPublicKeyInfo structure armored in Base64 (ImportPem / ExportPem). The PEM label is PUBLIC KEY.

Text parsing (Parse / TryParse) decodes a hex (Base16) string by default; pass an alternative IFormatProvider (for example, a Base58 or Base64 provider) to accept other encodings.

EddsaPublicKey inherits value semantics, ToString, equality operators, GetHash, and all base PublicKey methods from PublicKey. Equality comparisons use CryptographicOperations.FixedTimeEquals to avoid timing side-channels.

Examples

Deriving a public key and verifying a signature

using OnixLabs.Security.Cryptography;

using EddsaPrivateKey privateKey = EddsaPrivateKey.Create();

// Derive the corresponding public key.
EddsaPublicKey publicKey = privateKey.GetPublicKey();

byte[] message = System.Text.Encoding.UTF8.GetBytes("Hello, ONIXLabs!");
byte[] signature = privateKey.SignData(message);

// IsDataValid returns true/false without throwing.
bool valid = publicKey.IsDataValid(signature, message);
Console.WriteLine(valid); // True

// VerifyData throws CryptographicException on failure.
publicKey.VerifyData(signature, message);

Using a DigitalSignature value

using OnixLabs.Security.Cryptography;

using EddsaPrivateKey privateKey = EddsaPrivateKey.Create();
EddsaPublicKey publicKey = privateKey.GetPublicKey();

byte[] message = System.Text.Encoding.UTF8.GetBytes("Hello, ONIXLabs!");
byte[] rawSignature = privateKey.SignData(message);

// Wrap the raw bytes in a DigitalSignature value.
DigitalSignature signature = new(rawSignature);

bool valid = publicKey.IsDataValid(signature, message);
Console.WriteLine(valid); // True

Exporting and importing in PEM format

using OnixLabs.Security.Cryptography;

using EddsaPrivateKey privateKey = EddsaPrivateKey.Create();
EddsaPublicKey original = privateKey.GetPublicKey();

// Export as a SubjectPublicKeyInfo PEM string.
string pem = original.ExportPem();
Console.WriteLine(pem);
// -----BEGIN PUBLIC KEY-----
// ...
// -----END PUBLIC KEY-----

// Re-import from PEM.
EddsaPublicKey restored = EddsaPublicKey.ImportPem(pem.AsSpan());
Console.WriteLine(original == restored); // True

Computing a key fingerprint

using System.Security.Cryptography;
using OnixLabs.Security.Cryptography;

using EddsaPrivateKey privateKey = EddsaPrivateKey.Create();
EddsaPublicKey publicKey = privateKey.GetPublicKey();

Hash fingerprint = publicKey.GetHash(SHA256.Create());
Console.WriteLine(fingerprint); // SHA2-256:<hex>

Obtaining a self-describing named key

using OnixLabs.Security.Cryptography;

using EddsaPrivateKey privateKey = EddsaPrivateKey.Create();
EddsaPublicKey publicKey = privateKey.GetPublicKey();

NamedPublicKey named = publicKey.ToNamedPublicKey();

Console.WriteLine(named.AlgorithmName); // EDDSA
Console.WriteLine(named);               // EDDSA:<hex-encoded key bytes>

Constructors

Constructor Description
EddsaPublicKey(ReadOnlySpan<byte>) Initializes a new instance of the EddsaPublicKey class from a span of bytes.
EddsaPublicKey(ReadOnlyMemory<byte>) Initializes a new instance of the EddsaPublicKey class from a memory region.
EddsaPublicKey(ReadOnlySequence<byte>) Initializes a new instance of the EddsaPublicKey class from a byte sequence.

EddsaPublicKey(ReadOnlySpan<byte>)

public EddsaPublicKey(ReadOnlySpan<byte> keyData)

Initializes a new instance of the EddsaPublicKey class. The provided span is copied to an internal array; the span itself is not retained.

Parameter Type Description
keyData ReadOnlySpan<byte> The underlying key data of the EdDSA cryptographic public key.

EddsaPublicKey(ReadOnlyMemory<byte>)

public EddsaPublicKey(ReadOnlyMemory<byte> keyData)

Initializes a new instance of the EddsaPublicKey class. The provided memory region is copied to an internal array; the original memory is not retained.

Parameter Type Description
keyData ReadOnlyMemory<byte> The underlying key data of the EdDSA cryptographic public key.

EddsaPublicKey(ReadOnlySequence<byte>)

public EddsaPublicKey(ReadOnlySequence<byte> keyData)

Initializes a new instance of the EddsaPublicKey class. The provided byte sequence is copied to an internal array; the original sequence is not retained.

Parameter Type Description
keyData ReadOnlySequence<byte> The underlying key data of the EdDSA cryptographic public key.

Static Methods

Method Returns Description
Import(ReadOnlySpan<byte>) EddsaPublicKey Imports a raw 32-byte Ed25519 public key.
Import(ReadOnlySpan<byte>, out int) EddsaPublicKey Imports a raw 32-byte Ed25519 public key and reports bytes consumed.
Import(IBinaryConvertible) EddsaPublicKey Imports a raw Ed25519 public key from an IBinaryConvertible.
Import(IBinaryConvertible, out int) EddsaPublicKey Imports a raw Ed25519 public key from an IBinaryConvertible and reports bytes consumed.
ImportPem(ReadOnlySpan<char>) EddsaPublicKey Imports an Ed25519 public key from an RFC 7468 PEM document.
ImportPem(ReadOnlySpan<char>, ReadOnlySpan<char>) EddsaPublicKey Imports an Ed25519 public key from a PEM document (password parameter is accepted but ignored for public keys).
ImportPem(ReadOnlySpan<char>, ReadOnlySpan<byte>) EddsaPublicKey Imports an Ed25519 public key from a PEM document (password parameter is accepted but ignored for public keys).
Parse(string, IFormatProvider?) EddsaPublicKey Parses a string into an EddsaPublicKey.
Parse(ReadOnlySpan<char>, IFormatProvider?) EddsaPublicKey Parses a character span into an EddsaPublicKey.
TryParse(string?, IFormatProvider?, out EddsaPublicKey) bool Attempts to parse a string into an EddsaPublicKey.
TryParse(ReadOnlySpan<char>, IFormatProvider?, out EddsaPublicKey) bool Attempts to parse a character span into an EddsaPublicKey.

Import(ReadOnlySpan<byte>)

public static EddsaPublicKey Import(ReadOnlySpan<byte> data)

Imports an EddsaPublicKey from the raw 32-byte Ed25519 public key point.

Parameter Type Description
data ReadOnlySpan<byte> The raw Ed25519 public key bytes to import.

Returns — A new EddsaPublicKey backed by the supplied public key bytes.

Exceptions

Exception Condition
CryptographicException data is not exactly 32 bytes in length.

Import(ReadOnlySpan<byte>, out int)

public static EddsaPublicKey Import(ReadOnlySpan<byte> data, out int bytesRead)

Imports an EddsaPublicKey from the raw 32-byte Ed25519 public key point and reports bytes consumed.

Parameter Type Description
data ReadOnlySpan<byte> The raw Ed25519 public key bytes to import.
bytesRead out int When this method returns, contains the number of bytes consumed from data (always 32 on success).

Returns — A new EddsaPublicKey backed by the supplied public key bytes.

Exceptions

Exception Condition
CryptographicException data is not exactly 32 bytes in length.

Import(IBinaryConvertible)

public static EddsaPublicKey Import(IBinaryConvertible data)

Imports an EddsaPublicKey from the raw Ed25519 public key point held in an IBinaryConvertible value.

Parameter Type Description
data IBinaryConvertible The binary-convertible value whose raw bytes are the Ed25519 public key.

Returns — A new EddsaPublicKey backed by the supplied public key bytes.

Exceptions

Exception Condition
CryptographicException The binary data is not exactly 32 bytes in length.

Import(IBinaryConvertible, out int)

public static EddsaPublicKey Import(IBinaryConvertible data, out int bytesRead)

Imports an EddsaPublicKey from the raw Ed25519 public key point held in an IBinaryConvertible value and reports bytes consumed.

Parameter Type Description
data IBinaryConvertible The binary-convertible value whose raw bytes are the Ed25519 public key.
bytesRead out int When this method returns, contains the number of bytes consumed (always 32 on success).

Returns — A new EddsaPublicKey backed by the supplied public key bytes.

Exceptions

Exception Condition
CryptographicException The binary data is not exactly 32 bytes in length.

ImportPem(ReadOnlySpan<char>)

public static EddsaPublicKey ImportPem(ReadOnlySpan<char> data)

Imports an EddsaPublicKey from an RFC 7468 PEM-encoded SubjectPublicKeyInfo document. The PEM label must be PUBLIC KEY.

Parameter Type Description
data ReadOnlySpan<char> The PEM-encoded text containing the Ed25519 public key.

Returns — A new EddsaPublicKey imported from the PEM document.

Exceptions

Exception Condition
CryptographicException data does not contain a valid PEM document, the label is not PUBLIC KEY, or the Base64 payload cannot be decoded.

ImportPem(ReadOnlySpan<char>, ReadOnlySpan<char>)

public static EddsaPublicKey ImportPem(ReadOnlySpan<char> data, ReadOnlySpan<char> password)

Imports an EddsaPublicKey from an RFC 7468 PEM document. The password parameter is accepted for interface compatibility but is ignored; Ed25519 public keys are never encrypted.

Parameter Type Description
data ReadOnlySpan<char> The PEM-encoded text containing the Ed25519 public key.
password ReadOnlySpan<char> Ignored. Present for interface compatibility.

Returns — A new EddsaPublicKey imported from the PEM document.

Exceptions

Exception Condition
CryptographicException data does not contain a valid PEM document with label PUBLIC KEY.

ImportPem(ReadOnlySpan<char>, ReadOnlySpan<byte>)

public static EddsaPublicKey ImportPem(ReadOnlySpan<char> data, ReadOnlySpan<byte> password)

Imports an EddsaPublicKey from an RFC 7468 PEM document. The password parameter is accepted for interface compatibility but is ignored; Ed25519 public keys are never encrypted.

Parameter Type Description
data ReadOnlySpan<char> The PEM-encoded text containing the Ed25519 public key.
password ReadOnlySpan<byte> Ignored. Present for interface compatibility.

Returns — A new EddsaPublicKey imported from the PEM document.

Exceptions

Exception Condition
CryptographicException data does not contain a valid PEM document with label PUBLIC KEY.

Parse(string, IFormatProvider?)

public static EddsaPublicKey Parse(string value, IFormatProvider? provider = null)

Parses a string into an EddsaPublicKey. The default encoding is uppercase hexadecimal (Base16, invariant culture); pass an alternative IFormatProvider to accept other encodings such as Base58 or Base64.

Parameter Type Description
value string The string representation of the key to parse.
provider IFormatProvider? An optional format provider that determines the encoding. Defaults to Base16FormatProvider.Invariant.

Returns — A new EddsaPublicKey decoded from the supplied string.

Exceptions

Exception Condition
FormatException value is not in a valid format for the specified provider.

Parse(ReadOnlySpan<char>, IFormatProvider?)

public static EddsaPublicKey Parse(ReadOnlySpan<char> value, IFormatProvider? provider = null)

Parses a character span into an EddsaPublicKey. The default encoding is uppercase hexadecimal (Base16, invariant culture); pass an alternative IFormatProvider to accept other encodings.

Parameter Type Description
value ReadOnlySpan<char> The character span representation of the key to parse.
provider IFormatProvider? An optional format provider that determines the encoding. Defaults to Base16FormatProvider.Invariant.

Returns — A new EddsaPublicKey decoded from the supplied span.

Exceptions

Exception Condition
FormatException value is not in a valid format for the specified provider.

TryParse(string?, IFormatProvider?, out EddsaPublicKey)

public static bool TryParse(string? value, IFormatProvider? provider, out EddsaPublicKey result)

Attempts to parse a string into an EddsaPublicKey without throwing on failure.

Parameter Type Description
value string? The string representation of the key to parse.
provider IFormatProvider? An optional format provider that determines the encoding. Defaults to Base16FormatProvider.Invariant.
result out EddsaPublicKey When this method returns true, contains the parsed key; otherwise, a default instance.

Returns — true if value was successfully parsed; otherwise, false.

TryParse(ReadOnlySpan<char>, IFormatProvider?, out EddsaPublicKey)

public static bool TryParse(ReadOnlySpan<char> value, IFormatProvider? provider, out EddsaPublicKey result)

Attempts to parse a character span into an EddsaPublicKey without throwing on failure.

Parameter Type Description
value ReadOnlySpan<char> The character span representation of the key to parse.
provider IFormatProvider? An optional format provider that determines the encoding. Defaults to Base16FormatProvider.Invariant.
result out EddsaPublicKey When this method returns true, contains the parsed key; otherwise, a default instance.

Returns — true if value was successfully parsed; otherwise, false.

Instance Methods

Method Returns Description
Export() byte[] Exports the raw 32-byte Ed25519 public key point.
ExportPem() string Exports the key as a SubjectPublicKeyInfo PEM string (PUBLIC KEY).
IsDataValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>) bool Determines whether the signature is valid for the given message.
IsDataValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>, int, int) bool Determines whether the signature is valid for a slice of the given message.
IsDataValid(ReadOnlySpan<byte>, Stream) bool Determines whether the signature is valid for a stream message.
IsDataValid(ReadOnlySpan<byte>, IBinaryConvertible) bool Determines whether the signature is valid for an IBinaryConvertible message.
IsDataValid(DigitalSignature, ReadOnlySpan<byte>) bool Determines whether a DigitalSignature is valid for the given message.
IsDataValid(DigitalSignature, ReadOnlySpan<byte>, int, int) bool Determines whether a DigitalSignature is valid for a slice of the given message.
IsDataValid(DigitalSignature, Stream) bool Determines whether a DigitalSignature is valid for a stream message.
IsDataValid(DigitalSignature, IBinaryConvertible) bool Determines whether a DigitalSignature is valid for an IBinaryConvertible message.
VerifyData(ReadOnlySpan<byte>, ReadOnlySpan<byte>) void Verifies the signature for the given message; throws on failure.
VerifyData(ReadOnlySpan<byte>, ReadOnlySpan<byte>, int, int) void Verifies the signature for a slice of the given message; throws on failure.
VerifyData(ReadOnlySpan<byte>, Stream) void Verifies the signature for a stream message; throws on failure.
VerifyData(ReadOnlySpan<byte>, IBinaryConvertible) void Verifies the signature for an IBinaryConvertible message; throws on failure.
VerifyData(DigitalSignature, ReadOnlySpan<byte>) void Verifies a DigitalSignature for the given message; throws on failure.
VerifyData(DigitalSignature, ReadOnlySpan<byte>, int, int) void Verifies a DigitalSignature for a slice of the given message; throws on failure.
VerifyData(DigitalSignature, Stream) void Verifies a DigitalSignature for a stream message; throws on failure.
VerifyData(DigitalSignature, IBinaryConvertible) void Verifies a DigitalSignature for an IBinaryConvertible message; throws on failure.
ToNamedPublicKey() NamedPublicKey Returns a NamedPublicKey wrapping this key with the algorithm name "EDDSA".

For all other instance methods inherited from the base class (AsReadOnlyMemory, AsReadOnlySpan, Equals, GetHash, GetHashCode, ToString, and the equality operators), see PublicKey.


Export()

public byte[] Export()

Exports the raw 32-byte Ed25519 public key point as a new byte array.

Returns — A byte[] containing the raw Ed25519 public key bytes.

ExportPem()

public string ExportPem()

Exports the Ed25519 public key as an RFC 7468 PEM-encoded SubjectPublicKeyInfo string. The PEM label is PUBLIC KEY.

Returns — A PEM string containing the SubjectPublicKeyInfo-encoded Ed25519 public key.


IsDataValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

public bool IsDataValid(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data)

Determines whether the specified raw signature and message were produced by the EdDSA private key corresponding to the current public key.

Parameter Type Description
signature ReadOnlySpan<byte> The 64-byte Ed25519 signature to validate.
data ReadOnlySpan<byte> The original unsigned message bytes.

Returns — true if the signature is valid for the message; otherwise, false.

IsDataValid(ReadOnlySpan<byte>, ReadOnlySpan<byte>, int, int)

public bool IsDataValid(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, int offset, int count)

Determines whether the specified raw signature and a slice of the message were produced by the EdDSA private key corresponding to the current public key.

Parameter Type Description
signature ReadOnlySpan<byte> The 64-byte Ed25519 signature to validate.
data ReadOnlySpan<byte> The buffer containing the original unsigned message.
offset int The zero-based offset into data at which the message begins.
count int The number of bytes in data to use as the message.

Returns — true if the signature is valid for the specified slice; otherwise, false.

IsDataValid(ReadOnlySpan<byte>, Stream)

public bool IsDataValid(ReadOnlySpan<byte> signature, Stream data)

Determines whether the specified raw signature and stream message were produced by the EdDSA private key corresponding to the current public key. The stream is read to completion before verification.

Parameter Type Description
signature ReadOnlySpan<byte> The 64-byte Ed25519 signature to validate.
data Stream The stream containing the original unsigned message.

Returns — true if the signature is valid for the stream contents; otherwise, false.

IsDataValid(ReadOnlySpan<byte>, IBinaryConvertible)

public bool IsDataValid(ReadOnlySpan<byte> signature, IBinaryConvertible data)

Determines whether the specified raw signature and IBinaryConvertible message were produced by the EdDSA private key corresponding to the current public key.

Parameter Type Description
signature ReadOnlySpan<byte> The 64-byte Ed25519 signature to validate.
data IBinaryConvertible The binary-convertible value containing the original unsigned message.

Returns — true if the signature is valid for the message; otherwise, false.

IsDataValid(DigitalSignature, ReadOnlySpan<byte>)

public bool IsDataValid(DigitalSignature signature, ReadOnlySpan<byte> data)

Determines whether the specified DigitalSignature and message were produced by the EdDSA private key corresponding to the current public key.

Parameter Type Description
signature DigitalSignature The Ed25519 digital signature to validate.
data ReadOnlySpan<byte> The original unsigned message bytes.

Returns — true if the signature is valid for the message; otherwise, false.

IsDataValid(DigitalSignature, ReadOnlySpan<byte>, int, int)

public bool IsDataValid(DigitalSignature signature, ReadOnlySpan<byte> data, int offset, int count)

Determines whether the specified DigitalSignature and a slice of the message were produced by the EdDSA private key corresponding to the current public key.

Parameter Type Description
signature DigitalSignature The Ed25519 digital signature to validate.
data ReadOnlySpan<byte> The buffer containing the original unsigned message.
offset int The zero-based offset into data at which the message begins.
count int The number of bytes in data to use as the message.

Returns — true if the signature is valid for the specified slice; otherwise, false.

IsDataValid(DigitalSignature, Stream)

public bool IsDataValid(DigitalSignature signature, Stream data)

Determines whether the specified DigitalSignature and stream message were produced by the EdDSA private key corresponding to the current public key. The stream is read to completion before verification.

Parameter Type Description
signature DigitalSignature The Ed25519 digital signature to validate.
data Stream The stream containing the original unsigned message.

Returns — true if the signature is valid for the stream contents; otherwise, false.

IsDataValid(DigitalSignature, IBinaryConvertible)

public bool IsDataValid(DigitalSignature signature, IBinaryConvertible data)

Determines whether the specified DigitalSignature and IBinaryConvertible message were produced by the EdDSA private key corresponding to the current public key.

Parameter Type Description
signature DigitalSignature The Ed25519 digital signature to validate.
data IBinaryConvertible The binary-convertible value containing the original unsigned message.

Returns — true if the signature is valid for the message; otherwise, false.


VerifyData(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

public void VerifyData(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data)

Verifies that the specified raw signature corresponds to the message and was produced by the EdDSA private key corresponding to the current public key. Throws if verification fails.

Parameter Type Description
signature ReadOnlySpan<byte> The 64-byte Ed25519 signature to verify.
data ReadOnlySpan<byte> The original unsigned message bytes.

Exceptions

Exception Condition
CryptographicException The signature is invalid or was not produced by the corresponding private key.

VerifyData(ReadOnlySpan<byte>, ReadOnlySpan<byte>, int, int)

public void VerifyData(ReadOnlySpan<byte> signature, ReadOnlySpan<byte> data, int offset, int count)

Verifies that the specified raw signature corresponds to the slice of the message and was produced by the EdDSA private key corresponding to the current public key. Throws if verification fails.

Parameter Type Description
signature ReadOnlySpan<byte> The 64-byte Ed25519 signature to verify.
data ReadOnlySpan<byte> The buffer containing the original unsigned message.
offset int The zero-based offset into data at which the message begins.
count int The number of bytes in data to use as the message.

Exceptions

Exception Condition
CryptographicException The signature is invalid or was not produced by the corresponding private key.

VerifyData(ReadOnlySpan<byte>, Stream)

public void VerifyData(ReadOnlySpan<byte> signature, Stream data)

Verifies that the specified raw signature corresponds to the stream message and was produced by the EdDSA private key corresponding to the current public key. The stream is read to completion before verification. Throws if verification fails.

Parameter Type Description
signature ReadOnlySpan<byte> The 64-byte Ed25519 signature to verify.
data Stream The stream containing the original unsigned message.

Exceptions

Exception Condition
CryptographicException The signature is invalid or was not produced by the corresponding private key.
IOException An I/O error occurred while reading data.

VerifyData(ReadOnlySpan<byte>, IBinaryConvertible)

public void VerifyData(ReadOnlySpan<byte> signature, IBinaryConvertible data)

Verifies that the specified raw signature corresponds to the IBinaryConvertible message and was produced by the EdDSA private key corresponding to the current public key. Throws if verification fails.

Parameter Type Description
signature ReadOnlySpan<byte> The 64-byte Ed25519 signature to verify.
data IBinaryConvertible The binary-convertible value containing the original unsigned message.

Exceptions

Exception Condition
CryptographicException The signature is invalid or was not produced by the corresponding private key.

VerifyData(DigitalSignature, ReadOnlySpan<byte>)

public void VerifyData(DigitalSignature signature, ReadOnlySpan<byte> data)

Verifies that the specified DigitalSignature corresponds to the message and was produced by the EdDSA private key corresponding to the current public key. Throws if verification fails.

Parameter Type Description
signature DigitalSignature The Ed25519 digital signature to verify.
data ReadOnlySpan<byte> The original unsigned message bytes.

Exceptions

Exception Condition
CryptographicException The signature is invalid or was not produced by the corresponding private key.

VerifyData(DigitalSignature, ReadOnlySpan<byte>, int, int)

public void VerifyData(DigitalSignature signature, ReadOnlySpan<byte> data, int offset, int count)

Verifies that the specified DigitalSignature corresponds to the slice of the message and was produced by the EdDSA private key corresponding to the current public key. Throws if verification fails.

Parameter Type Description
signature DigitalSignature The Ed25519 digital signature to verify.
data ReadOnlySpan<byte> The buffer containing the original unsigned message.
offset int The zero-based offset into data at which the message begins.
count int The number of bytes in data to use as the message.

Exceptions

Exception Condition
CryptographicException The signature is invalid or was not produced by the corresponding private key.

VerifyData(DigitalSignature, Stream)

public void VerifyData(DigitalSignature signature, Stream data)

Verifies that the specified DigitalSignature corresponds to the stream message and was produced by the EdDSA private key corresponding to the current public key. The stream is read to completion before verification. Throws if verification fails.

Parameter Type Description
signature DigitalSignature The Ed25519 digital signature to verify.
data Stream The stream containing the original unsigned message.

Exceptions

Exception Condition
CryptographicException The signature is invalid or was not produced by the corresponding private key.
IOException An I/O error occurred while reading data.

VerifyData(DigitalSignature, IBinaryConvertible)

public void VerifyData(DigitalSignature signature, IBinaryConvertible data)

Verifies that the specified DigitalSignature corresponds to the IBinaryConvertible message and was produced by the EdDSA private key corresponding to the current public key. Throws if verification fails.

Parameter Type Description
signature DigitalSignature The Ed25519 digital signature to verify.
data IBinaryConvertible The binary-convertible value containing the original unsigned message.

Exceptions

Exception Condition
CryptographicException The signature is invalid or was not produced by the corresponding private key.

ToNamedPublicKey()

public override NamedPublicKey ToNamedPublicKey()

Creates a new NamedPublicKey from this EddsaPublicKey, using the algorithm identifier "EDDSA".

Returns — A NamedPublicKey pairing this instance with the algorithm name "EDDSA".

Implicit Conversion Operators

Operator Description
implicit operator EddsaPublicKey(ReadOnlySpan<byte>) Creates an EddsaPublicKey from a ReadOnlySpan<byte>.
implicit operator EddsaPublicKey(ReadOnlyMemory<byte>) Creates an EddsaPublicKey from a ReadOnlyMemory<byte>.
implicit operator EddsaPublicKey(ReadOnlySequence<byte>) Creates an EddsaPublicKey from a ReadOnlySequence<byte>.

implicit operator EddsaPublicKey(ReadOnlySpan<byte>)

public static implicit operator EddsaPublicKey(ReadOnlySpan<byte> value)

Creates a new EddsaPublicKey from the specified ReadOnlySpan<byte> value.

Parameter Type Description
value ReadOnlySpan<byte> The span from which to create a new EddsaPublicKey instance.

implicit operator EddsaPublicKey(ReadOnlyMemory<byte>)

public static implicit operator EddsaPublicKey(ReadOnlyMemory<byte> value)

Creates a new EddsaPublicKey from the specified ReadOnlyMemory<byte> value.

Parameter Type Description
value ReadOnlyMemory<byte> The memory region from which to create a new EddsaPublicKey instance.

implicit operator EddsaPublicKey(ReadOnlySequence<byte>)

public static implicit operator EddsaPublicKey(ReadOnlySequence<byte> value)

Creates a new EddsaPublicKey from the specified ReadOnlySequence<byte> value.

Parameter Type Description
value ReadOnlySequence<byte> The byte sequence from which to create a new EddsaPublicKey instance.

See Also

ONIXLabs .NET Library


Clone this wiki locally