Quantum Cryptography
The universe’s original code meets modern cyber defense
Co-authored with Nandanaranjish
We live in a world where almost our entire lives, our bank details, private chats, medical records, and digital identities float silently through thin air and undersea cables every single second. Have you ever wondered why any random person with a Wi-Fi card can’t just pluck your secrets out of the air and read them? It feels almost like magic, but behind the scenes, there is a silent mathematical war being fought to keep our digital world safe. Today, as super-fast quantum computers step out of theoretical physics and into reality, this invisible shield is on the verge of facing its biggest test yet. But before we see how quantum physics can shatter our digital locks or help us build completely unhackable ones, we first need to understand the fundamental engine that makes this entire digital security possible in the first place:
What is Cryptography?
At its simplest, cryptography is the science of scrambling information into complete gibberish using mathematical rules, so that only someone with the right secret “key” can unscramble and read it. Whenever you send a WhatsApp text or check your bank account, your data flies across open networks, but cryptography ensures that any eavesdropper only sees useless noise.
To pull off this digital lock-and-key trick, modern systems rely on two main types of cryptography:
The Two Pillars: Symmetric vs. Asymmetric Cryptography
1) symmetric cryptography where the exact same key is used to both encrypt and decrypt the data and relies heavily on algorithms like AES to secure large amounts of information 2) Since sharing the single key across the internet can be risky, we have asymmetric cryptography where we have a linked pair of keys: a public key that one can use to lock the message and a private key held only the receiver to unlock it. This method relies on algorithms like RSA and ECC. Hence, both these techniques ensure that even if someone intercepts the data, they cannot read it without proper keys.
AES(Advanced Encryption Standard) is a symmetric block cipher algorithm with block size of 128, 192 or 256 bits and it uses the same key for encryption and decryption. It secures data through multiple mathematical rounds each involving processes like SubBytes, ShiftRows, MixColumns and AddRoundKey. The reverse of these operations can be performed to decrypt the message. Unlike AES, RSA(Rivest-Shamir-Adleman) uses two distinct keys:
- Public key is shared openly with the world and anyone can use it to encrypt a message intended for you.
- Private key is kept secretly by you and is the only key that can decrypt a message locked by your public key.
RSA’s security relies on the ‘trapdoor function’: factoring of large prime numbers. A large number formed by multiplying two prime numbers together forms the core part of both the public and private key, and factoring this massive number is computationally heavy. The internet uses a hybrid approach of using RSA to securely lock and share a temporary AES secret key. ECC(Elliptical Curve Cryptography) provides strong security with smaller keys than RSA and is ideal for IoT devices and blockchain wallets. It relies on the algebraic geometry of elliptical curves where the system starts at a point, jumps around the curve to reach the destination. But knowing the starting point and destination cannot trace the path backward to figure out the original number of jumps.
A New Paradigm: Mechanics of Quantum computers
Unlike classical computers that store information in definite states (0 or 1), quantum computers fundamentally use quantum bits, or qubits. The computational power of a qubit is driven by two primary quantum phenomenon:
- Superposition: An unmeasured qubit can exist in a complex probability distribution of both states(0,1) simultaneously. It is only when it is physically observed that it collapses to be definitive. Hence, we can evaluate many possibilities at the exact same time.
- Entanglement: Multiple qubits become linked at the quantum level such that the state of one qubit instantly dictates the state of the other regardless of the physical distance of separation.
Now, how do these strange quantum properties actually translate into real-world attacks against our digital locks? While classical machines take thousands of years to pick apart large mathematical problems, a quantum computer can exploit superposition and wave interference to crack our public-key systems wide open, a breakthrough discovered through Shor’s Algorithm.
Shattering Public-Key Encryption: Shor’s Algorithm
As we know, it is much easier to multiply any numbers together and find a larger number, but computationally heavy and difficult to find the factors from which a very large number was formed. Imagine finding the factor of 352749200427182747281910247478213! Widely used cryptographic algorithms like the RSA, at its core, rely on this difficulty of factoring large numbers. A normal computer basically uses our pen and paper method (but much faster) of guessing a prime factor, seeing if it actually is a factor, finding the other prime factors if it is correct or making a new guess if it’s wrong. This method takes maybe 10min, or maybe 2000 years depending on a single computer depending on the number to be factored. The same problem can be solved by someone who has access to a server using 20 computers for the same computation and get the factors in a lesser time than 2000 years. So, encrypting data isn’t a guarantee of protection, but it is a way of making it harder to access, harder enough so that no one thinks it is worth trying for. You can imagine multiple locks, strong enough that no physical weapon can crack it easily but one can use a ‘lightsaber’ to make this seem like a piece of cake! Shor’s algorithm is basically this ‘lightsaber’.
Consider a number N, that you will have to find its prime factors to break into some encrypted data. We start by guessing a number g, that is a pure factor of N or it can also share factors with N(common factors of numbers can be found using Euclid’s algorithm). But for a very large number it is very unlikely that a random guess, say g, will actually share a factor with N. Hence, we proceed to make this random guess into better ones that are way more likely to share factors with N.
We begin with the fact that any 2 whole numbers that doesn’t share a common factor can be expressed as
A.A.A.A.A….A = k.B + 1 , where k is a random whole number.
kB = Aᵖ — 1 , where p is some power. (Check on this yourself with examples!)
So, for N and g, gᵖ -1 = mN
mN = ( gᵖ/²+1)(gᵖ/²-1), thereby providing 2 new improved guesses( gᵖ/²+1, gᵖ/²-1) for pure factors or numbers that share factors with N.
But this is not what Shor’s algorithm is. There are mainly 3 problems associated with this method:
One of these improved factors can be multiples of N, then the other would be multiples of m making these improved guesses useless.
The power p can be odd. It is also the case that we are approximately 37.5% sure of making a guess where p will not be odd, and hence around 99% sure to conclude on the correct factor with fewer than 10 guesses.
To find p it takes a ridiculous amount of trial and error for a normal computer!!!
This is where quantum mechanics enters the field and speeds things up by an insane amount. By superposition we are able to calculate the outputs for more than one input at the same time scaled by their probabilities and these outputs destructively interfere in such a way that we finally get a single output that is most likely to be the right answer (the right power p). The problem of arranging the quantum computation in such a way that all the wrong answers destructively interfere is what is solved by Shor’s algorithm.
For a single input x, this is what a quantum computer does:
|x⟩ → [ gˣ ] → |x, gˣ⟩ → [ ÷mN ](compares for remainder) → |x,r⟩, where x is the input power and r is the remainder.
This can be done by any normal computer also, but a quantum computer has the capability of sending a superposition of inputs at a time and outputs the superposition of a combination of input and the remainder for each input. Now, all the unwanted outputs destructively interfere to produce our desired output |p,+1⟩. This crux is solved by the fact that
gˣ=mN+r
gˣ⁺ᵖ=m₁N+r, that is p has a repeating property and provides a relationship between different powers. This relationship across different powers can be discovered easily since quantum computation can be performed over a superposition of powers. If we design the quantum computer so as to output a remainder |+r⟩ then the output would be a superposition of all possible inputs that can result in the remainder r, and these individual inputs would be a period p apart (repeating property, with a frequency 1/p).
By far, the best way to find frequencies is a fourier transform(eg: can analyse an audio signal in time domain in its frequency domain based on the different frequencies contained in the fourier transform). A quantum fourier transform outputs a superposition of states scaled by their different probabilities such that they produce a sine wave with a characteristic frequency for a specific input. Hence, the input of different states separated by a factor p, will result in a single quantum state represented by |1/p⟩, thereby improving our guess and taking us close to breaking the locks on the internet multiple times faster than by using any classical algorithms on normal computers.
While Shor’s algorithm takes a direct sledgehammer to asymmetric systems like RSA by exploiting their hidden mathematical periods, it cannot touch symmetric encryption like AES. But this doesn’t mean our symmetric ciphers escape completely unharmed because a quantum computer has another ace up its sleeve to speed through brute-force searches: Grover’s Algorithm.
Speeding Up the Search: Grover’s Algorithm
Imagine you are looking for one specific person, say John, inside a massive football stadium with 1,000,000 attendees. On average, you will have to check 500,000 people (half the stadium) before you bump into him. If you are incredibly unlucky, you might have to check all 1,000,000. This is a linear search. As the crowd gets bigger, the time it takes to find John grows at the exact same rate. Grover’s algorithm uses quantum physics to find John drastically faster. It doesn’t look at people one by one. Instead, it looks at the entire stadium at the exact same time using two quantum superpowers. A quantum computer sets up a state where every single seat in the stadium is being looked at simultaneously. Think of it like a massive wave of light washing over the entire crowd at once. The algorithm applies a mathematical filter called an Oracle. The Oracle doesn’t know where John is, but it knows what John looks like. When the quantum wave hits John, the Oracle “flips” his wave upside down. Everyone else stays normal. John is now uniquely marked, but his signal is still way too quiet to see clearly. This is where the magic happens. The algorithm performs a mathematical trick that amplifies the wave where it flipped and shrinks the waves everywhere else.Imagine it like turning down the stadium lights on all 999,999 wrong people, while simultaneously turning a bright spotlight directly onto John.The algorithm repeats this spotlight trick a few times. Suddenly, John’s signal becomes so overwhelmingly loud that when you finally look at the data, you see him instantly. Instead of checking 500,000 people using linear search, Grover’s algorithm only needs to repeat this trick √1,000,000 times (1000times).
Grover’s algorithm is like a supercharged search engine that looks for a secret cryptographic key out of N possible combinations by √N steps (faster than classical linear search where order is N). It effectively halves the security bit length of a key, thereby weakening AES encryption. As a result, AES-128 drops to a highly vulnerable 64 bits of security, while AES-256 is reduced to 128 bits — which remains computationally secure against quantum attacks.
Now that we have seen how Shor’s and Grover’s algorithms use quantum mechanics to tear down our classical locks like paper, the big question is: can we use the exact same weird rules of quantum physics to build a lock that no one can pick?
The Idea Behind Quantum Key Distribution: Catching the Eavesdropper
Suppose you wish to send a secret message to a friend across town, but you have a nosy neighbour who might intercept the mail carrier(eavesdropper), read your message and then reseal it without you ever knowing. As a solution to this you can wrap your message in a highly sensitive seal that would cause a permanent mark or deformation once somebody intercepts. Hence, your friend who receives the message might know if somebody has intercepted the message transfer. If yes, you know that your secrets are being compromised and can try again on a fresh channel. QKD is theoretically the strongest way to share these secrets, but real-world strength depends entirely on the physical security and calibration of the hardware used to run it.
Get Sabari Nath’s stories in your inbox
Join Medium for free to get updates from this writer.
QKD uses quantum mechanical concepts, especially quantum entanglement, to construct a cryptographic protocol in order to secure data against any computational attack, including those from future quantum computers. It works on 3 basic properties of ‘No-Cloning theorem’, immediate alteration of data once intercepted and tamper detection by sender and receiver. It allows two people to share a randomly generated key with which they can encrypt and decrypt messages. Be sure not to confuse QKD with quantum cryptography in general.
The core idea of QKD is that the process of measuring a quantum system disturbs it. This unique property ensures that the distributed keys remain secure, as any attempt at interception will be immediately apparent and will invalidate the exchanged key. Quantum communication involves encoding information in quantum states usually with photons and there are mainly 2 ways to use these quantum states to ensure the security of this channel.
1.Prepare and Measure: The BB84 Protocol
Two parties, Alice and Bob exploit 2 communication channels, ie, an insecure quantum channel and an authenticated classical channel. To establish a secure cryptographic key. The communication begins by Alice preparing the quantum states according to her basis(pairs of orthogonal states: rectilinear(0°,90°), diagonal(45°,135°), circular(left and right handedness)) and sends them through the quantum channel to Bob who retrieves it and uses it to create a shared secret key. Then using a small sample of their data they check if Bob’s measurement outcomes are compatible with Alice. If yes, then the quantum states are undisturbed, else this suggests the presence of an eavesdropper. It is important to emphasize that the classical channel is authenticated. This allows Alice and Bob to be sure that they are talking only to each other and are not being impersonated.As such the eavesdropper can only listen to the communication but cannot modify the messages being sent between Alice and Bob.
The BB84 protocol based on this was described using photon polarisation states to transmit information. The quantum communication channel mostly used here was optical fibre and classical channel is mostly broadcast radio or even internet. The security of the protocol comes from encoding the information in non-orthogonal states. Initially, Alice selects one of the two bases, rectilinear or diagonal, to transmit a random bit(0 or1) by preparing a photon polarisation state depending on the bit value and the basis. For example, in rectilinear basis 0 is encoded as vertical polarisation and 1 is encoded in diagonal as 135°. She then transmits this to Bob via the quantum channel. This is repeated with Alice recording the state, basis and time of each photon sent.
If a photon which was created in the rectilinear basis is measured using the diagonal basis it returns horizontal or vertical at random, and after this measurement the photon becomes polarised in the state it was measured and all information on initial polarisation is lost. As Bob does not know the basis the photons were encoded in, all he can do is to select a basis at random to measure in, either rectilinear or diagonal. He does this for each photon he receives, recording the time, measurement basis used and measurement result. After Bob has measured all the photons, he communicates with Alice over the public classical channel. Alice broadcasts the basis each photon was sent in, and Bob the basis each was measured in. They both discard photon measurements (bits) where Bob used a different basis, which is half on average, leaving half the bits as a shared key. By comparing a predetermined set of bits they can determine the presence of an eavesdropper by checking the errors in Bob’s measurements.
2.Entanglement Protocols: The E91 Approach
Alice and Bob share pairs of entangled photons meaning the state of one photon is inherently linked to the state of the other, no matter what the distance between them is and hence is described by a combined quantum state. . Here, performing a measurement on one affects the other and anyone intercepting alters the overall system.
E91 communication relies on two properties of entanglement: 1) if Alice and Bob both measure whether their particles have vertical or horizontal polarizations, they always get opposite answers with 100% probability 2) any attempt at eavesdropping by Eve destroys these correlations in a way that Alice and Bob can detect.
This way QKD creates a completely unhackable “lock and key” system to secure it. That key is used in standard encryption software like AES-256.
But setting up dedicated optical fibers and laser detectors across the entire globe to protect our daily internet is practically impossible and ridiculously expensive. This brings us to the next big question: can we make our normal laptops and phones quantum-proof without buying any new quantum hardware?
The answer is yes, and this is where Post-Quantum Cryptography (PQC) enters the field.
Post-Quantum Cryptography (PQC): Software Shields for Normal Computers
While QKD uses quantum physics to protect data by sending physical photons, PQC takes a completely different path: it is pure mathematics and software. That means it runs right on our normal computers, laptops, and phones using the exact same internet cables and Wi-Fi we use every day! We don’t need a single piece of quantum hardware. The only difference is that we are swapping out the underlying math. We throw away prime factorization because Shor’s algorithm can easily find its repeating periods, and replace it with brand new mathematical locks that have no repeating properties or periodic cycles for a quantum computer to exploit.
There are mainly 3 mathematical methods leading this field:
1. Lattice-Based Cryptography:
Imagine an infinite grid of dots like a graph paper, but instead of 2 or 3 dimensions, it extends into 500 or 1000 dimensions! This multi-dimensional grid is called a lattice.
Its core trick is based on a problem called “Learning With Errors” (LWE). In simple algebra, finding unknowns in a system of linear equations like A.s = b is very easy for any normal computer. But if we add a tiny bit of random noise or error e to each equation, making it A.s + e = b, the whole thing collapses! Without knowing the exact error, finding the secret s becomes impossible because the error multiplies at every step. To encrypt, Alice adds this tiny noise to her message. Bob, who has the secret key, can cancel out the equations and simply round off the tiny leftover noise to 0 to read the message. Because a 1000-dimensional grid with noise has no repeating frequencies, Shor’s algorithm’s fourier transform trick is completely useless here. This is why lattice algorithms like ML-KEM and ML-DSA are the top choices today.
2.Hash-Based Cryptography:
This method doesn’t use complex geometry at all. Instead, it relies on standard one-way hash functions (like SHA-256) that we already trust. A hash function works like a one-way blender: it is super fast to turn an input into a hash, but mathematically impossible to go backwards and find what was put in.
Imagine you want to sign a 256-bit message. You can create pairs of random secret numbers, hash them to make a public key, and then reveal one secret number for each 0 or 1 in your message (Lamport One-Time Signature). Anyone can check if your revealed numbers match your public hashes. Since revealing these numbers uses up the key, modern systems connect thousands of these keys into a single master tree structure (Merkle Tree) so they can be reused without running out. Because hash functions have zero algebraic structure or periods, Shor’s algorithm cannot touch them, and Grover’s algorithm can only cut the search time to half its power ,which is still millions of years!
3.Code-Based Cryptography:
Invented by Robert McEliece in 1978, this relies on error-correcting codes which is the exact same technology your phone uses to fix corrupted data when you have a weak mobile signal.
Here, we take a special code that has a hidden shortcut to easily detect and correct bit errors. We scramble this code until it looks completely random and publish it as our public key. When sending a secret, you intentionally flip a few random bits to create errors. To any eavesdropper, finding and fixing errors in a completely random-looking code is an NP-hard problem that neither normal nor quantum computers can solve. But the receiver knows the secret unscrambling trick, turns it back into the clean code, and fixes the errors instantly to see the message. This method has stayed undefeated for nearly 50 years, though its main downside is that the public keys are much larger in data size compared to lattices.
Example :
Original Message: [ 1 0 1 1 ]
Add Redundancy: [ 1 0 1 1 0 1 0 ] (Codeword)
Noise Introduced: [ 1 1 1 1 0 1 0 ] (Bit 2 flipped)
Error Correction: [ 1 0 1 1 ] (Original recovered)
Harvest Now, Decrypt Later:
You might ask, if quantum computers with enough qubits to run Shor’s algorithm are still years away, why worry about PQC right now?
The problem is a strategy called “Harvest Now, Decrypt Later”. Hackers and intelligence agencies are intercepting and saving encrypted data right now. They cannot read it today, but they are storing it so that years later, when a powerful quantum computer is built, they can feed our stored messages to Shor’s algorithm and crack all our past secrets! To prevent this, companies are already shifting to “hybrid” encryption i.e combining our classical algorithms with PQC so that our data stays completely safe both today and in the future.
The Road Ahead: Winning the Quantum Race
The quantum revolution isn’t just about building faster supercomputers; it is fundamentally redrawing the boundaries of digital trust. As algorithms like Shor’s and Grover’s move from blackboard mathematics into real-world machines, the illusion of permanent security vanishes. Yet, as history has shown time and again, cryptography always evolves to meet its greatest threats. Whether through the physics-backed certainty of QKD or the clever, period-free mathematics of Post-Quantum Cryptography, we are already building the shields before the weapons are fully forged. The race between codebreakers and codemakers is far from over and as we step into this quantum era, our digital world is gearing up to stay one step ahead.
REFERENCES :
1. https://www.researchgate.net/figure/BB84-protocol-basic-scheme_fig11_309731586
2. https://en.wikipedia.org/wiki/BB84
3. youtube.com/watch?si=ueOhF-bgHQkVObXP&v=lvTqbM5Dq4Q&feature=youtu.be





