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.

triangle-exclamation
circle-exclamation

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

ArgumentOutOfRangeExceptionarrow-up-right

publicKey has a length not equal to PublicKeySize.

ArgumentOutOfRangeExceptionarrow-up-right

privateKey has a length not equal to PrivateKeySize.

CryptographicExceptionarrow-up-right

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

ArgumentOutOfRangeExceptionarrow-up-right

publicKey has a length not equal to PublicKeySize.

ArgumentOutOfRangeExceptionarrow-up-right

privateKey has a length not equal to PrivateKeySize.

ArgumentOutOfRangeExceptionarrow-up-right

seed has a length not equal to SeedSize.

CryptographicExceptionarrow-up-right

Unable to generate key pair from seed.

ComputePublicKey

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

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

publicKey has a length not equal to PublicKeySize.

ArgumentOutOfRangeExceptionarrow-up-right

privateKey has a length not equal to PrivateKeySize.

CryptographicExceptionarrow-up-right

Unable to compute public key from private key.

Sign

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

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

signature has a length not equal to SignatureSize.

ArgumentOutOfRangeExceptionarrow-up-right

privateKey has a length not equal to PrivateKeySize.

CryptographicExceptionarrow-up-right

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

ArgumentOutOfRangeExceptionarrow-up-right

signature has a length not equal to SignatureSize.

ArgumentOutOfRangeExceptionarrow-up-right

publicKey has a length not equal to PublicKeySize.

IncrementalEd25519ph

Provides support for computing/verifying a signature from a sequence of messages using Ed25519pharrow-up-right.

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.

circle-exclamation

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

signature has a length not equal to SignatureSize.

ArgumentOutOfRangeExceptionarrow-up-right

privateKey has a length not equal to PrivateKeySize.

ArgumentOutOfRangeExceptionarrow-up-right

publicKey has a length not equal to PublicKeySize.

CryptographicExceptionarrow-up-right

The signature could not be computed.

InvalidOperationExceptionarrow-up-right

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

ObjectDisposedExceptionarrow-up-right

The object has been disposed.

Constants

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

Notes

circle-info

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.

triangle-exclamation
circle-exclamation

Last updated