Introduction to QuantCrypt: A Python Library for Quantum-Resistant Cryptography
Tags: postquantum, cryptography, quantumcomputing, cybersecurity
Published: 2024-02-05 18:56:52

As we stand on the brink of a quantum computing era, the cryptographic landscape is undergoing a transformative shift. Traditional encryption methods, such as [RSA](https://en.wikipedia.org/wiki/RSA_(cryptosystem)), [ECC](https://en.wikipedia.org/wiki/Elliptic-curve_cryptography), and [DH](https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange), which form the backbone of current internet security, are poised to become vulnerable against the formidable computational capabilities of quantum machines. This impending reality underscores the necessity for quantum-resistant cryptography, which the [QuantCrypt](https://github.com/aabmets/quantcrypt) library together with the [PQClean](https://github.com/PQClean/PQClean) project seeks to fulfill. 

This article explores the features of the QuantCrypt library, its alignment with the Commercial National Security Algorithm ([CNSA](https://en.wikipedia.org/wiki/Commercial_National_Security_Algorithm_Suite)) Suite advisories by the [NSA](https://en.wikipedia.org/wiki/National_Security_Agency), and the ongoing NIST Post-Quantum Cryptography ([PQC](https://csrc.nist.gov/projects/post-quantum-cryptography)) Standardization efforts, highlighting how it prepares developers for a post-quantum world.

## Features
QuantCrypt merges quantum-resistant algorithms with an accessible design and extensive documentation, marking it as an indispensable asset for those looking to protect data against quantum threats. It offers a versatile set of features for secure communication, data integrity, and file protection, addressing modern cryptographic needs. Here are its standout features:

**Shared-Secret Exchange:** Utilizes advanced KEM algorithms to facilitate the secure exchange of shared secrets between parties. This feature is crucial for establishing secure communication channels, ensuring that the exchanged data remains confidential and tamper-proof.

**Signing and Verifying Data:** Incorporates DSS algorithms that allow users to sign and verify data, ensuring its integrity and authenticity. This feature is vital for scenarios where the verification of the sender's identity and the integrity of the transmitted data is paramount.

**File Signing and Verification:** Offers helper methods specifically designed for signing and verifying files of any type and size. This functionality extends the utility of DSS algorithms beyond simple data packets to comprehensive file management.

**Symmetric Encryption:** Introduces the Krypton Cipher, a symmetric encryption algorithm based on AES-256, that implements additional protection mechanisms for increased data security and brute-force resistance. Krypton uses 64-byte keys, which is double that of basic AES-256. Read more about Krypton from [here](https://github.com/aabmets/quantcrypt/wiki/The-Krypton-Cipher).

**File Encryption and Decryption:** The Krypton cipher provides helper methods to encrypt and decrypt files of any type and size using symmetric keys for data encryption and also asymmetric KEM keys in a hybrid cryptosystem.

**Detailed Documentation:** The library is thoroughly documented either through its GitHub [Wiki](https://github.com/aabmets/quantcrypt/wiki) page or source-code docstrings, which are readily accessible through autocomplete and intellisense helpers of compatible IDE-s.

**Argon2 and KKDF (KMAC-KDF) Methods:** Incorporates Argon2 and KKDF helper methods, which are integral to the functioning of the Krypton Cipher for key derivation, but are also available for standalone use. These methods provide additional layers of security and flexibility in cryptographic operations.

**Comprehensive CLI Support:** The majority of QuantCrypt’s functionality, including file encryption, signatures, and generating Post-Quantum Cryptography (PQC) algorithm keys, is accessible via a user-friendly command-line interface, powered by [Typer](https://typer.tiangolo.com/). This feature enables users to integrate and automate QuantCrypt’s capabilities into their workflows efficiently, making Post-Quantum Cryptography accessible for everybody, including those with minimal programming experience.

## CNSA and NIST PQC Standardization
The National Institute of Standards and Technology (NIST) is at the forefront of the PQC Standardization effort, aiming to establish a set of secure and efficient cryptographic standards resistant to quantum attacks.

The first event held by NIST on PQC standardization took place on April 2, 2015, nearly **nine** years ago from today (Feb 5, 2024). The process has evolved so far that on April 10, **this year**, during the [Fifth Conference](https://csrc.nist.gov/events/2024/fifth-pqc-standardization-conference), we will very likely see the publication of the standardized PQC algorithms. Since NIST has already written draft FIPS proposals [203](https://csrc.nist.gov/pubs/fips/203/ipd), [204](https://csrc.nist.gov/pubs/fips/204/ipd) and [205](https://csrc.nist.gov/pubs/fips/205/ipd), we already know which algorithms are going to be standardized. Note that we might see an [additional](https://csrc.nist.gov/projects/post-quantum-cryptography/round-4-submissions) KEM algorithm being standardized during the conference.

The National Security Agency (NSA), whose task is to protect US National Security Systems information up to the [top secret](https://en.wikipedia.org/wiki/Top_secret) level, has provided us with a helpful timeline for implementing PQC algorithms across various systems. We can see that by the beginning of the next year (2025), multiple essential systems should use PQC algorithms by default: 

- Software and firmware signatures 
- HTTPS connections between web browsers and servers

![CNSA Timeline](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8n0dz0nv8zfmlcl9fgy1.png)

The combination of these events and timelines has made it possible and even essential to develop these vital PQC libraries for tomorrow, today. The [looming danger](https://www.livescience.com/technology/computing/worlds-1st-fault-tolerant-quantum-computer-coming-2024-10000-qubit-in-2026) posed by quantum computers necessitates the migration to quantum-resistant algorithms before the machines become powerful enough to wreak havoc on legacy cryptosystems. This is the goal and purpose of [QuantCrypt](https://github.com/aabmets/quantcrypt) - to provide the necessary tools in an easily-accessible package to facilitate this migration away from the vulnerable algorithms towards the new standards.