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:
- 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.
- 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.
- 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.
- 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.
- 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.
- Install Bouncy Castle: First, ensure you have Bouncy Castle installed in your .NET project. You can typically add it via NuGet Package Manager.
- Using Statements: Import the necessary namespaces:
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.