PostQuantum.Hybrid — VS Code SnippetsC# snippets for the PostQuantum.Hybrid library — hybrid post-quantum cryptography (X25519 + ML-KEM-768 for KEM, Ed25519 + ML-DSA-65 for signatures) on .NET 8 and .NET 10 — and for the PostQuantum.FileEncryption family (fail-closed file/stream encryption, passphrase-protected key files, detached signing, DI, KMS envelopes). Every snippet follows the secure patterns the libraries' Roslyn analyzers enforce — PQH001 – PQH005 ( This version focuses on the repo's safest default surfaces first: FeaturesProvides IntelliSense snippets for C# files to accelerate working with the PostQuantum.Hybrid cryptography library. Recommended starting points:
PostQuantum.FileEncryption (
|
| Prefix | What it expands to |
|---|---|
pqfe-encrypt |
Passphrase file round-trip done right: runtime passphrase (PQFE101), Argon2id, atomic output, fail-closed catch (PQFE104). |
pqfe-decrypt-untrusted |
Decryptor with PqDecryptionLimits.Untrusted — the mandatory shape for uploads and shared storage. |
pqfe-hybrid-keygen |
X25519 + ML-KEM-768 key pair with the private half stored as a passphrase-protected PQKF key file (PQFE102). |
pqfe-hybrid-roundtrip |
Encrypt to a recipient public key; decrypt after ImportEncrypted of the protected key file. |
pqfe-sign-verify |
Detached Ed25519 + ML-DSA-65 signing with verify-before-use and no swallowed PqSignatureException. |
pqfe-di |
One-line DI registration, including the limits overload for services decrypting untrusted containers. |
pqfe-upload |
ASP.NET Core streaming upload encryption — the web server holds only the public key and can read nothing it stores. |
pqfe-kms |
AWS KMS / Azure Key Vault envelope encryption — the master key never enters your process. |
Why These Snippets First?
- Envelope snippets are the safest default. They collapse KEM + HKDF + AEAD into one misuse-resistant API.
- ASP.NET snippets reflect real deployment patterns. Configuration-based registration and rotating KEM keys are more useful to service authors than only demo-style inline PEM wiring.
- Readiness matters in production. A snippet that exercises real crypto at startup is far more useful than a static support probe.
Requirements
The snippets emit code that depends on the NuGet packages — install them in your project or they will not compile:
# For the pqh-* snippets:
dotnet add package PostQuantum.Hybrid
dotnet add package PostQuantum.Hybrid.Analyzers # strongly recommended
dotnet add package PostQuantum.Hybrid.Envelopes # for Seal/Open helpers
dotnet add package PostQuantum.Hybrid.AspNetCore # for the ASP.NET Core wiring
# For the pqfe-* snippets:
dotnet add package PostQuantum.FileEncryption
dotnet add package PostQuantum.FileEncryption.Analyzers # strongly recommended
dotnet add package PostQuantum.FileEncryption.Hybrid # recipient encryption
dotnet add package PostQuantum.FileEncryption.Signing # detached signatures
dotnet add package PostQuantum.FileEncryption.Extensions.DependencyInjection
Known Issues
See the main repository's KNOWN-GAPS.md for current library limitations.
Release Notes
See CHANGELOG.md for detailed release notes.
1.2.0
- Added the
pqfe-*snippet family for the PostQuantum.FileEncryption NuGet family: fail-closed file encryption, untrusted-input limits, PQKF key files, detached signing, DI registration, streaming upload encryption, and KMS envelopes. - Every
pqfe-*snippet is analyzer-clean againstPostQuantum.FileEncryption.Analyzers(PQFE101 – PQFE104) and mirrors that repo's cookbook recipes.
1.1.0
- Added
Envelopes, ASP.NET Core configuration/rotation, and readiness-check snippets. - Repositioned the snippet set around the safest high-level APIs first.
- Tightened packaging/docs consistency for Marketplace publishing.
1.0.1
- Marketplace polish release with icon, listing metadata, and packaging updates.
1.0.0
- Initial release of C# snippets for
PostQuantum.Hybrid.
To God be the glory — 1 Corinthians 10:31.