---
title: "Sign and verify with Ed448 and a context in C#"
url: https://recursiveai.org/onecrypto/cookbook/ed448-sign-verify/
description: "Sign and verify with Ed448 and a context in C#: runnable .NET 10 example with OneCrypto, actual output and a downloadable project."
version: "0.4.0-preview.2"
---

# Sign and verify with Ed448 and a context in C#

**OneCrypto** is a free, open-source cryptography library for .NET from Recursive AI. MIT or Apache-2.0, preview, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneCrypto) · [GitHub](https://github.com/recursive-ai-oss/onecrypto-csharp) · [Docs](https://recursiveai.org/onecrypto/docs/) · [Download example (.zip)](https://recursiveai.org/onecrypto/cookbook/ed448-sign-verify/ed448-sign-verify.zip)

An Ed448 context is an application label bound into the signature. Signing and verification must use the same context bytes.

```shell
dotnet add package RecursiveAI.OneCrypto --prerelease
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
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);
```

```text
True
```

Unzip [the example](https://recursiveai.org/onecrypto/cookbook/ed448-sign-verify/ed448-sign-verify.zip), then `dotnet run`.

## The full program

The program also rejects a mismatched context.

```csharp
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}");
```

```text
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.

```csharp
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);
```

```text
True
```

## Related recipes

- [Wrap and unwrap an AES key in C# (RFC 3394)](https://recursiveai.org/onecrypto/cookbook/wrap-unwrap-aes-key-rfc3394/)
- [Prepare and complete a detached signature in C#](https://recursiveai.org/onecrypto/cookbook/prepare-and-complete-detached-signature/)
- [Read and write ASN.1 DER in C#](https://recursiveai.org/onecrypto/cookbook/read-write-asn1-der/)

---

## 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](https://recursiveai.org/onecrypto/docs/keys/) 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](https://recursiveai.org/onecrypto/docs/keys/#signature-specs) permits at most 255 context bytes and defaults to an empty context. The underlying construction is described in [RFC 8032, section 5.2.6](https://www.rfc-editor.org/rfc/rfc8032.html#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](https://recursiveai.org/onecrypto/docs/keys/#signature-specs) 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.
