Skip to content

Instantly share code, notes, and snippets.

@AnthonyGiretti
Created January 7, 2026 20:10
Show Gist options
  • Select an option

  • Save AnthonyGiretti/3466ad5494b7a44d37f16d3c00ce1761 to your computer and use it in GitHub Desktop.

Select an option

Save AnthonyGiretti/3466ad5494b7a44d37f16d3c00ce1761 to your computer and use it in GitHub Desktop.
.NET 10 Post Quantum cryptography; exemple with ML-DSA signature algo
using System;
using System.Security.Cryptography;
byte[] data = "hello PQC"u8.ToArray();
// 1) Generate a post-quantum signature key (ML-DSA)
using var signingKey = MLDSA.GenerateKey(MLDSAAlgorithm.MLDSA65);
// 2) Sign the data
byte[] signature = signingKey.SignData(data);
// 3) Export the public key (PEM) and re-import it for verification
string publicPem = signingKey.ExportSubjectPublicKeyInfoPem();
using var verifyKey = MLDSA.ImportFromPem(publicPem);
// 4) Verify the 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