An Ed448 context is an application label bound into the signature. Signing and verification must use the same context bytes.
dotnet add package RecursiveAI.OneCrypto --prereleaseRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using RecursiveAI.OneCrypto.Keys; using RecursiveAI.OneCrypto.Primitives; using var raw = Ed448PrivateKey.Generate(); using var key = PrivateKey.FromEd448(raw); var spec = SignatureSpec.Ed448("orders"u8); byte[] signature = key.Sign("hello"u8, spec); Console.WriteLine(spec.Verify( key.PublicKey, "hello"u8, signature).IsValid);
TrueUnzip the example, then dotnet run.
The full program
The program also rejects a mismatched context.
using RecursiveAI.OneCrypto.Keys; using RecursiveAI.OneCrypto.Primitives; using var raw = Ed448PrivateKey.Generate(); using var key = PrivateKey.FromEd448(raw); var spec = SignatureSpec.Ed448("orders"u8); byte[] signature = key.Sign("hello"u8, spec); Console.WriteLine(spec.Verify( key.PublicKey, "hello"u8, signature).IsValid); Console.WriteLine($"Signature: {signature.Length} bytes"); var other = SignatureSpec.Ed448("invoices"u8); Console.WriteLine($"Other context: {other.Verify(key.PublicKey, "hello"u8, signature).IsValid}");
True Signature: 114 bytes Other context: False
SignatureSpec.Verify returns a verification result for invalid signatures; check IsValid before accepting the message.
Variations
Use the default empty context.
using RecursiveAI.OneCrypto.Keys; using RecursiveAI.OneCrypto.Primitives; using var raw = Ed448PrivateKey.Generate(); using var key = PrivateKey.FromEd448(raw); var spec = SignatureSpec.Ed448(); byte[] signature = key.Sign("hello"u8, spec); Console.WriteLine(spec.Verify( key.PublicKey, "hello"u8, signature).IsValid);
TrueRelated recipes
- Wrap and unwrap an AES key in C# (RFC 3394)
- Prepare and complete a detached signature in C#
- Read and write ASN.1 DER in C#
The short answer
Use Ed448PrivateKey with SignatureSpec.Ed448(context). Sign and verify the same message bytes with the same context. The full program demonstrates that the same signature fails with another context.
How do I sign and verify with Ed448 in C#?
Generate an Ed448PrivateKey, wrap it with PrivateKey.FromEd448, and use SignatureSpec.Ed448 for signing and verification. The signature is separate from the message. The example signs the UTF-8 bytes of hello, then verifies with the public key and the same specification.
The key interface documentation identifies Ed448 as a library implementation, not a platform-only signing backend. ISigningKey exposes the same Sign interface used for other key types. The wrapper does not own the raw key by default, so the sample disposes both using declarations in the appropriate order.
A verifier needs only the public key, original message and signature. Keep the private key on the signing side. This example generates a temporary key each time; it does not establish the identity of an external signer or load a trusted key from storage.
What is the context in an Ed448 signature?
The context is a byte string included in the Ed448 operation, not an extra message prefix that you concatenate yourself. The example uses the UTF-8 bytes of orders. The signature-spec documentation permits at most 255 context bytes and defaults to an empty context. The underlying construction is described in RFC 8032, section 5.2.6.
Agree on the exact label and encoding with the verifier. orders, Orders and an empty context are different inputs. Do not assume that displaying a context next to a signature makes the receiving library use it; pass it into the verification specification explicitly.
The full program keeps the message and public key unchanged but verifies once with invoices instead. That result is False. This is useful when distinct application operations need distinct signing contexts, but both ends must implement the same convention.
How many bytes is an Ed448 signature?
The documented signature size is 114 bytes, and the full program prints that length. It is not the length of a key file, PEM text or a DER container. If you encode the signature as hexadecimal or Base64 for transport, decode it back to the original signature bytes before verification.
The API returns a SignatureVerification, whose IsValid property is the acceptance check in the snippets. A nonvalid result must not be treated as a verified message. Keep the original bytes rather than reconstructing text after parsing or normalizing it; signing checks bytes, not a visual rendering.
Can I use an Ed448 context in an X.509 signature?
Not with the X.509 algorithm identifier exposed by this API. The documentation says X.509 uses an empty context, and ToAlgorithmIdentifier throws NotSupportedException for a specification with a context. A raw signature with an application context is therefore a different integration task from producing a certificate signature.
This example uses ordinary Ed448 message signing. It does not select a prehash variant or sign an externally computed digest. The key interface’s scheme table lists Ed448 as signing the message plus context, unlike RSA and ECDSA digest signing. Keep that distinction when adapting a generic signing pipeline: hashing first and passing the digest as the message changes what is signed.