The documentation is currently being reviewed, so you may see some inconsistencies between sections.
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Digital signatures

Purpose

A digital signature verifies the authenticity of a message and provides non-repudiation. This means any change to the message causes signature verification to fail, you know who signed the message, and someone cannot deny having signed a message.

Signing is done using a private key. The associated public key can then be publicly shared to allow others to verify signatures.

Usage

GenerateKeyPair

Fills a span with a randomly generated private key and another span with the associated public key.

Ed25519.GenerateKeyPair(Span<byte> publicKey, Span<byte> privateKey)

Exceptions

ArgumentOutOfRangeException

publicKey has a length not equal to PublicKeySize.

ArgumentOutOfRangeException

privateKey has a length not equal to PrivateKeySize.

CryptographicException

Unable to generate key pair.

GenerateKeyPair

Fills a span with a private key generated using a random seed and another span with the associated public key.

Exceptions

ArgumentOutOfRangeException

publicKey has a length not equal to PublicKeySize.

ArgumentOutOfRangeException

privateKey has a length not equal to PrivateKeySize.

ArgumentOutOfRangeException

seed has a length not equal to SeedSize.

CryptographicException

Unable to generate key pair from seed.

GetPublicKey

Fills a span with the public key retrieved from a private key.

Exceptions

ArgumentOutOfRangeException

publicKey has a length not equal to PublicKeySize.

ArgumentOutOfRangeException

privateKey has a length not equal to PrivateKeySize.

CryptographicException

Error retrieving public key from private key.

GetSeed

Fills a span with the seed retrieved from a private key.

Exceptions

ArgumentOutOfRangeException

seed has a length not equal to SeedSize.

ArgumentOutOfRangeException

privateKey has a length not equal to PrivateKeySize.

CryptographicException

Error retrieving seed from private key.

Sign

Fills a span with the signature for a message signed using a private key.

Exceptions

ArgumentOutOfRangeException

signature has a length not equal to SignatureSize.

ArgumentOutOfRangeException

privateKey has a length not equal to PrivateKeySize.

CryptographicException

Unable to compute signature.

Verify

Determines if a signature is valid for a message and public key. It returns true if the signature is valid and false otherwise.

Exceptions

ArgumentOutOfRangeException

signature has a length not equal to SignatureSize.

ArgumentOutOfRangeException

publicKey has a length not equal to PublicKeySize.

IncrementalEd25519ph

Provides support for computing/verifying a signature from a sequence of messages using Ed25519ph.

IncrementalEd25519ph.Finalize() fills a span with the signature for a chunked message signed using a private key.

IncrementalEd25519ph.FinalizeAndVerify() determines if a signature is valid for a chunked message and public key. It returns true if the signature is valid and false otherwise.

Exceptions

ArgumentOutOfRangeException

signature has a length not equal to SignatureSize.

ArgumentOutOfRangeException

privateKey has a length not equal to PrivateKeySize.

ArgumentOutOfRangeException

publicKey has a length not equal to PublicKeySize.

OutOfMemoryException

Allocating memory for the state failed.

CryptographicException

The signature could not be computed.

InvalidOperationException

Cannot update after finalizing or finalize twice (without reinitializing).

InvalidOperationException

Methods cannot be called from multiple threads simultaneously.

ObjectDisposedException

The object has been disposed.

Constants

These are used for validation and/or save you defining your own constants.

Notes

If you want to use BLAKE2b for prehashing instead of Ed25519ph, which uses SHA-512 internally, you can hash a domain separation constant (e.g., the protocol name) concatenated with the message and sign the 512-bit hash.

Last updated