Skip to content

Instantly share code, notes, and snippets.

@AnthonyGiretti
Created January 19, 2026 01:40
Show Gist options
  • Select an option

  • Save AnthonyGiretti/8f6304003b8e6ef0013be459a1e5418d to your computer and use it in GitHub Desktop.

Select an option

Save AnthonyGiretti/8f6304003b8e6ef0013be459a1e5418d to your computer and use it in GitHub Desktop.
.NET 10 Post Quantum Cryptography, example with SLH-DSA
using System;
using System.Security.Cryptography;
byte[] data = "critical firmware update"u8.ToArray();
// Generate SLH-DSA key
using var signingKey = SLHDSA.GenerateKey(SLHDSAAlgorithm.SLHDSA128S);
// Sign the data
byte[] signature = signingKey.SignData(data);
// Export public key
string publicPem = signingKey.ExportSubjectPublicKeyInfoPem();
// Import for verification
using var verifyKey = SLHDSA.ImportFromPem(publicPem);
// Verify signature
bool ok = verifyKey.VerifyData(data, signature);
Console.WriteLine(ok);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment