Quantum-Safe Cryptography in .NET

Cryptographic algorithms hide behind the curtain of so much of the digital communication that supports our daily lives online. As quantum computers continue to advance, the likelihood increases of computers that can defeat all of our current cryptography algorithms, threatening to unravel the very fabric of our digital world.

With this threat looming, I want to give .NET developers everything they need to know so they are prepared for this eventuality.

Understanding the Status Quo

Present-day cryptography, the bedrock of all secure communications, operates on algorithms like RSA, AES, Triple DES, ECC, and others. Most of these algorithms employ two keys, a public key used for encryption and a private key used for decryption, and are based on the computational difficulty of factoring large numbers into their prime factors. As of now, the amount of time it takes a traditional computer, even a modern supercomputer, to do this prime factoring is infeasible within a reasonable timeframe.

Quantum Computing: A Game-Changer

The advent of quantum computers, which work very differently than binary computers, threatens the security of these techniques due to new algorithms like Shor’s algorithm, specifically designed to efficiently factor large numbers using a quantum computer. Quantum computers can perform factoring calculations exponentially faster than classical computers by leveraging quantum states and operations, jeopardizing the foundation of traditional encryption algorithms that rely on prime factorization for security.

Here’s a simplified overview of how Shor’s algorithm works to undo traditional encryption:

  1. Quantum Superposition: Unlike classical bits that are either 0 or 1, quantum bits (or qubits) can exist in a superposition of both states simultaneously. This property allows quantum computers to perform multiple computations at once.
  2. Quantum Fourier Transform (QFT): Shor’s algorithm utilizes a quantum version of the Fourier transform. By applying the QFT to the quantum state of the input number, it transforms the problem of finding periodicity into a problem of finding the period of a function.
  3. Finding Periodicity: The core of Shor’s algorithm involves finding the period of a particular modular exponential function. For factoring large numbers, this function is related to the factorization problem.
  4. Quantum Parallelism: Quantum computers can evaluate the function for many possible values simultaneously, exploiting quantum parallelism. This enables Shor’s algorithm to explore a vast number of possibilities in parallel, significantly reducing the time required compared to classical algorithms.
  5. Entanglement and Measurement: Entanglement is another crucial quantum property utilized by Shor’s algorithm. The qubits become entangled during the computation, allowing the quantum computer to obtain information about the period of the function when measured.

By combining these quantum principles, Shor’s algorithm can efficiently find the period of the modular exponential function, ultimately leading to the very quick factorization of large numbers. This might seem like an obscure mathematical ability until you realize it means that all our traditional cryptographic systems are no longer safe, with all of our encrypted data becoming vulnerable to decryption.

Post-Quantum Cryptography Options

The National Institute of Standards and Technology (NIST) initiated a process to standardize post-quantum cryptography algorithms to prepare for the advent of quantum computing.

Here’s a brief overview of some of the algorithms selected by NIST for post-quantum cryptography:

Key Encapsulation Mechanisms (KEMs)

Key Encapsulation Mechanisms (KEMs) are cryptographic techniques that facilitate the secure exchange of secret keys over a public channel by encapsulating the key within a ciphertext.

  • Kyber: A key encapsulation mechanism based on the hardness of the Learning With Errors (LWE) problem. Kyber offers security by leveraging the difficulty of finding a secret key when given a collection of noisy key equations.
  • NTRU: Utilizes lattice-based cryptography, specifically the NTRUEncrypt algorithm. It relies on the difficulty of the NTRU lattice problem, which involves finding short vectors in a certain type of lattice.
  • Saber: A KEM derived from the Ring Learning With Errors (Ring-LWE) problem. Saber offers security by exploiting the complexity of finding information about a random secret in a noisy environment.

Digital Signature Schemes

Digital Signature Schemes are cryptographic methods that provide a way to verify the authenticity and integrity of digital messages or documents through the use of a private key to generate a unique digital signature.

  • Dilithium: A digital signature scheme based on the hardness of the Module-LWE problem. Dilithium provides digital signature security by making it computationally difficult to forge signatures.
  • Falcon: Another digital signature scheme based on the difficulty of the Short Integer Solution (SIS) problem. Falcon relies on the challenge of finding short vectors in a certain space to ensure signature security.
  • Rainbow: A signature scheme built upon multivariate quadratic equations. Rainbow’s security is rooted in the complexity of solving systems of multivariate polynomial equations.

Public Key Encryption (PKE) Schemes

Public Key Encryption (PKE) Schemes are cryptographic systems that use a pair of public and private keys, enabling the encryption of messages with the public key and decryption with the corresponding private key. They ensure secure communication between two parties.

  • BIKE: A PKE scheme based on the problem of finding short vectors in a certain space. BIKE leverages the difficulty of the Integer Ring-LWE problem to ensure encryption security.
  • NTRUEncrypt: Not only a KEM but also a PKE scheme based on lattice-based cryptography. NTRUEncrypt’s security is derived from the challenge of solving lattice problems.

NIST’s selection process focused on algorithms resistant to quantum attacks while also considering efficiency, feasibility, and security. These algorithms underwent rigorous evaluation and testing phases to determine their suitability for adoption in the post-quantum era.

Preparing Your .NET Application for the Quantum Leap

To fortify your applications against the coming quantum storm, it’s crucial to embrace these post-quantum cryptography (PQC) algorithms. They offer a formidable defense to even quantum computers.

If you are a .NET developer with an application that is doing encryption, you can begin the journey of safeguarding your .NET applications by integrating libraries that already support post-quantum cryptographic algorithms. One such library is called Bouncy Castle. Below I outline a simple example of a .NET application using Bouncy Castle. This sample encrypts and decrypts data using the quantum-safe CRYSTALS-Kyber algorithm.


  1. Install Bouncy Castle: First, ensure you have Bouncy Castle installed in your .NET project. You can typically add it via NuGet Package Manager.
  2. Using Statements: Import the necessary namespaces:
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;

Steps to Implement CRYSTALS-Kyber Encryption:

With BouncyCastle installed, here are the steps to encrypt data using it:

1. Generate Key Pair:

// Create a CRYSTALS-Kyber key pair generator SecureRandom random = new SecureRandom(); KyberKem keyPairGenerator = new KyberKem(random); 

// Generate key pair AsymmetricCipherKeyPair keyPair = keyPairGenerator.GenerateKeyPair(); 
KyberPublicKeyParameters publicKey =   
KyberPrivateKeyParameters privateKey =  

2. Encrypting Data:

// Initialize the Kyber KEM encryption engine with the public key KyberKem kemEncrypt = new KyberKem(random); 

// Generate a shared secret and encapsulate it 
byte[] encapsulatedKey = new byte[kemEncrypt.CiphertextSize]; 
byte[] sharedSecret = new byte[kemEncrypt.KeyDataLength]; kemEncrypt.Encapsulate(encapsulatedKey, 0, sharedSecret, 0);
// Now encapsulatedKey contains the ciphertext to be sent along with the shared secret

3. Decrypting Data:

// Initialize the Kyber KEM decryption engine with the private key 
KyberKem kemDecrypt = new KyberKem(random); 

// Extract the shared secret from the received 
encapsulatedKey byte[] receivedSharedSecret = new 
kemDecrypt.Decapsulate(encapsulatedKey, 0, receivedSharedSecret, 0); 

// Now 'receivedSharedSecret' contains the decrypted shared secret

Please note that this example provides only a basic outline of using Bouncy Castle to implement CRYSTALS-Kyber encryption in .NET. It’s important to handle exceptions, manage key storage securely, and consider additional factors for a production-grade implementation.

The Path Forward

Trailhead Technology Partners is committed to securing our clients’ systems against emerging threats like the inevitability of quantum decryption. We bring a collaborative approach, our technical expertise, and innovative solutions to all software projects, and we’d love to help you review your existing applications to ensure they are ready for the quantum future.

If you’d like to know more, contact us to start the conversation about how Trailhead can help.

Related Blog Posts

We hope you’ve found this to be helpful and are walking away with some new, useful insights. If you want to learn more, here are a couple of related articles that others also usually find to be interesting:

Our Gear Is Packed and We're Excited to Explore With You

Ready to come with us? 

Together, we can map your company’s software journey and start down the right trails. If you’re set to take the first step, simply fill out our contact form. We’ll be in touch quickly – and you’ll have a partner who is ready to help your company take the next step on its software journey. 

We can’t wait to hear from you! 

Main Contact

This field is for validation purposes and should be left unchanged.

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the form below. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Montage Portal

Montage Furniture Services provides furniture protection plans and claims processing services to a wide selection of furniture retailers and consumers.

Project Background

Montage was looking to build a new web portal for both Retailers and Consumers, which would integrate with Dynamics CRM and other legacy systems. The portal needed to be multi tenant and support branding and configuration for different Retailers. Trailhead architected the new Montage Platform, including the Portal and all of it’s back end integrations, did the UI/UX and then delivered the new system, along with enhancements to DevOps and processes.


We’ve logged countless miles exploring the tech world. In doing so, we gained the experience that enables us to deliver your unique software and systems architecture needs. Our team of seasoned tech vets can provide you with:

Custom App and Software Development

We collaborate with you throughout the entire process because your customized tech should fit your needs, not just those of other clients.

Cloud and Mobile Applications

The modern world demands versatile technology, and this is exactly what your mobile and cloud-based apps will give you.

User Experience and Interface (UX/UI) Design

We want your end users to have optimal experiences with tech that is highly intuitive and responsive.


This combination of Agile software development and IT operations provides you with high-quality software at reduced cost, time, and risk.

Trailhead stepped into a challenging project – building our new web architecture and redeveloping our portals at the same time the business was migrating from a legacy system to our new CRM solution. They were able to not only significantly improve our web development architecture but our development and deployment processes as well as the functionality and performance of our portals. The feedback from customers has been overwhelmingly positive. Trailhead has proven themselves to be a valuable partner.

– BOB DOERKSEN, Vice President of Technology Services
at Montage Furniture Services

Technologies Used

When you hit the trails, it is essential to bring appropriate gear. The same holds true for your digital technology needs. That’s why Trailhead builds custom solutions on trusted platforms like .NET, Angular, React, and Xamarin.


We partner with businesses who need intuitive custom software, responsive mobile applications, and advanced cloud technologies. And our extensive experience in the tech field allows us to help you map out the right path for all your digital technology needs.

  • Project Management
  • Architecture
  • Web App Development
  • Cloud Development
  • DevOps
  • Process Improvements
  • Legacy System Integration
  • UI Design
  • Manual QA
  • Back end/API/Database development

We partner with businesses who need intuitive custom software, responsive mobile applications, and advanced cloud technologies. And our extensive experience in the tech field allows us to help you map out the right path for all your digital technology needs.

Our Gear Is Packed and We're Excited to Explore with You

Ready to come with us? 

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the contact form. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Thank you for reaching out.

You’ll be getting an email from our team shortly. If you need immediate assistance, please call (616) 371-1037.