How Shor and Grover Change Cryptographic Risk: A Practical Quantum Demonstration
Quantum computing is often discussed through future scenarios: what might happen when sufficiently powerful quantum computers become available, which algorithms may become vulnerable, and when organizations should begin preparing.
A more useful way to understand the risk is to look at the mechanisms behind it.
Two quantum algorithms are particularly important for cybersecurity: Shor’s algorithm and Grover’s algorithm. They affect cryptography in fundamentally different ways. Shor targets mathematical problems that support widely used public-key cryptography, while Grover accelerates the search through large spaces of possible values, including cryptographic keys.
To demonstrate these differences, DIAMATIX CISO Krasimir Koev, PhD, developed programmatic implementations using Python and the Qiskit software development kit. The examples deliberately use small or simplified values. They are not attacks against production RSA or AES systems. Their purpose is to make the underlying security implications visible.
Understanding that distinction matters. Quantum risk is not a single event that affects every cryptographic mechanism in the same way.
Shor’s Algorithm: Why Public-Key Cryptography Requires Attention
RSA, Rivest-Shamir-Adleman, is based on a mathematical asymmetry.
Multiplying two large prime numbers is computationally easy. Starting with their product and recovering those original factors becomes extremely difficult when the numbers are sufficiently large.
That difficulty is what gives RSA much of its security.
Shor’s algorithm changes the model by providing a quantum method for solving integer factorization much more efficiently than known classical approaches.
Rather than testing potential factors sequentially, the quantum part of the algorithm transforms factorization into a period-finding problem. Quantum superposition allows information about many possible values to be processed, while the Quantum Fourier Transform, QFT, helps extract the periodic structure required to recover the factors.
This is why a sufficiently capable quantum computer would create a fundamentally different problem for RSA. The concern is not simply that an attacker receives “more computing power”. The algorithm targets the mathematical assumption on which the cryptographic system depends.
A Small RSA Example
To make the mechanism visible, the demonstration uses a deliberately small RSA-style example:
N = 35 = 5 × 7
The public information contains N. An attacker does not initially know its prime factors, 5 and 7.
In the demonstration, Shor’s algorithm uses period finding for a selected value. After identifying a suitable period, classical calculations based on the greatest common divisor recover the two factors.
For the example used in the demonstration:
- a value of 4 is selected;
- the relevant period is 6;
- half of the period is 3;
- 4³ mod 35 gives 29;
- the greatest common divisors of 28 and 35, and of 30 and 35, reveal 7 and 5.
The result is the factorization of N.
With these factors, the mathematical information required to reconstruct the private RSA parameters becomes available.
This example uses tiny numbers that would be trivial to factor classically. That is intentional. It demonstrates the logic of the algorithm rather than the computational scale required to attack real production RSA keys.

Figure 1. Demonstration circuit for Shor’s algorithm implemented with Qiskit.
The circuit may look complex at first, but it can be read as several functional stages.
The counting qubits form the upper part of the circuit. Hadamard gates, marked H, place them into superposition so that information about multiple possible values can be represented during the computation.
The lower register contains the target qubits, where controlled unitary operations perform the modular calculations associated with period finding.
The large block toward the end represents the inverse Quantum Fourier Transform, QFT. Its role is to convert the accumulated quantum phase information into a form from which the period can be extracted.
Finally, the counting qubits are measured and their results are stored in classical bits. Classical post-processing then uses this information to calculate the period and ultimately recover the factors.
The important security point is not the number of gates shown in the diagram. It is the computational structure behind them: Shor’s algorithm provides a fundamentally different route to the factorization problem that RSA relies on being difficult.
What the Shor Demonstration Does and Does Not Show
The demonstration does not show that operational RSA systems can currently be broken using an ordinary laptop or today’s publicly available quantum hardware.
It shows why RSA belongs to the group of cryptographic systems that require a migration strategy before cryptographically relevant quantum computers become practical.
The same broader concern applies to other public-key systems whose security depends on mathematical problems for which efficient quantum algorithms are known, including elliptic-curve cryptography.
This difference matters for security planning. Organizations need to know where these mechanisms are used across certificates, VPNs, authentication systems, digital signatures, applications, devices, and third-party services.
That is one of the reasons cryptographic inventory is becoming an important part of post-quantum readiness.
Grover’s Algorithm: A Different Type of Quantum Advantage
Grover’s algorithm addresses a different problem.
Imagine searching an unsorted set of possible answers. A classical search may need to inspect up to N possibilities. Grover’s algorithm can reduce the search complexity to approximately √N quantum iterations.
It does this through a repeated process.
First, possible states are placed into superposition.
An oracle then identifies the desired state by changing its phase.
A diffusion operator amplifies the probability of the marked state while reducing the probability associated with the others.
After several repetitions, measuring the system is much more likely to return the desired result.
For cybersecurity, this matters because key searching is fundamentally a search problem.
Demonstrating Grover with a Quantum State
The first demonstration uses three qubits, creating eight possible states.
The target state is:
|101⟩
Hadamard gates initially place all eight states into superposition.
The oracle marks |101⟩. The diffusion operation then increases its probability relative to the other states.
Repeating this process makes |101⟩ increasingly likely to appear when the system is measured.
Figure 2. Grover search demonstration using three qubits.
The three horizontal quantum lines represent the qubits used to encode the search space.
The initial H gates create an equal superposition of the possible states.
The oracle blocks identify the target state through a phase change. They do not simply reveal the answer. Instead, they mark it in a way that allows the next stage of the algorithm to amplify its probability.
The operations following each oracle form the diffusion process. Repeating the oracle and diffusion stages gradually concentrates probability around the target state.
The measurement symbols at the end convert the quantum state into classical information.
Conceptually, Grover’s algorithm does not know the correct answer in advance. It reshapes the probability distribution so that the correct candidate becomes substantially more likely to be observed.
What Does This Mean for Cryptographic Keys?
The second Grover demonstration connects the same principle directly to cryptography.
It uses a deliberately simplified AES-like cipher with a 5-bit key. There are only 32 possible keys, making the example small enough to demonstrate clearly.
The example uses:
- plaintext: 00000
- ciphertext: 10110
- unknown 5-bit key
The possible keys are placed into superposition.
The oracle evaluates which candidate key produces the expected ciphertext and marks that candidate. The diffusion process then amplifies its probability.
For a search space of 2⁵ possibilities, the demonstration requires approximately four Grover iterations before measurement produces the strongest candidate for the key.
This is a teaching model. The cipher is not AES-128, and the demonstration should not be interpreted as a practical break of AES.
Its value is in showing how quantum search changes the economics of exhaustive key search.
Shor and Grover Affect Cryptography Differently
This distinction is one of the most important points for organizations planning for post-quantum security.
Shor’s algorithm changes the security assumptions behind important public-key systems.
For RSA and related public-key mechanisms, sufficiently capable quantum computation could undermine the mathematical problem on which their security is based. This is why post-quantum migration focuses heavily on key establishment, certificates, digital signatures, and public-key infrastructure.
Grover’s algorithm provides a quadratic speedup for search problems.
For symmetric cryptography, the impact is therefore different. A key space does not suddenly disappear. The effective cost of exhaustive search is reduced.
That means symmetric cryptography and public-key cryptography should not be treated as if they face identical quantum risks.
This distinction is also why statements such as “quantum computers will break encryption” are too broad to be operationally useful.
Security teams need to know which cryptography is used, where it is used, what it protects, and how the quantum threat model applies to that particular mechanism.
Why These Small Demonstrations Matter for Real Security
Neither demonstration represents an immediate attack against a production environment.
Their value is architectural.
They show that post-quantum planning is driven by known computational properties, rather than by a hypothetical idea that quantum computers will simply become “very fast computers”.
For organizations, this has several practical consequences.
Public-key dependencies need to be discoverable
RSA and elliptic-curve cryptography can appear in many places:
- TLS certificates;
- virtual private networks;
- digital signatures;
- device identities;
- authentication systems;
- software and firmware signing;
- cloud services;
- third-party products.
If an organization does not know where those dependencies exist, planning their replacement becomes difficult.
Symmetric cryptography needs a different risk assessment
AES and other symmetric mechanisms are not affected in the same way as RSA.
Key length, implementation, data sensitivity, performance requirements, and expected confidentiality lifetime all influence the appropriate response.
Replacing every cryptographic mechanism with the same solution would therefore create new operational problems rather than solve the existing ones.
Migration needs crypto-agility
Algorithms and standards will continue to evolve.
Systems should therefore be designed so that cryptographic mechanisms can be changed without rebuilding the entire application or infrastructure.
Crypto-agility means being able to update algorithms, certificates, keys, libraries, and policies in a controlled way as standards mature and vendor support becomes available.
The goal is not to predict the precise date of a future quantum breakthrough. It is to reduce the amount of infrastructure that becomes difficult to change when migration is required.
From Demonstration to Post-Quantum Readiness
The technical lesson from Shor and Grover leads to a practical security question:
How easily could your organization identify and change the cryptography it depends on today?
A useful starting point includes:
- identifying public-key and symmetric cryptographic dependencies;
- mapping certificates, VPNs, keys, digital signatures, and cryptographic libraries;
- identifying systems protecting long-lived sensitive information;
- reviewing vendor post-quantum roadmaps;
- testing interoperability and performance before migration;
- designing new systems with crypto-agility in mind.
This is where technical demonstrations become relevant to operational security.
The quantum circuit itself does not tell an organization what to migrate first. Understanding how the algorithms affect different cryptographic mechanisms helps determine where the highest-priority dependencies are likely to exist.
The DIAMATIX Perspective
Quantum computing does not create one uniform cryptographic risk.
Shor’s algorithm demonstrates why widely deployed public-key mechanisms require a planned transition. Grover’s algorithm shows why symmetric cryptography requires a different assessment based on key strength, implementation, and operational context.
For DIAMATIX, the practical question is therefore not whether an organization should replace all cryptography immediately.
The first questions are more fundamental:
- Where is cryptography used?
- What security function does each mechanism perform?
- Which systems protect information that must remain confidential for years?
- Which dependencies can be changed easily, and which are embedded in long-lived infrastructure?
- Are vendors able to support a controlled post-quantum transition?
Technical demonstrations help explain the risk. Cryptographic visibility and crypto-agility determine how manageable that risk becomes in practice.
Post-quantum readiness starts by understanding the current environment before changing it.
For the broader context behind this transition, read our first article, “Post-Quantum Cryptography: Why Preparation Needs to Start Now,” where we explain why post-quantum readiness is already becoming an operational issue, from cryptographic inventory and long-lived sensitive data to vendor planning and crypto-agility.
Conclusion
Shor and Grover illustrate two different ways quantum computing can affect cybersecurity.
Shor targets mathematical structures used by important public-key cryptographic systems. Grover changes the computational cost of exhaustive search and therefore affects symmetric cryptography differently.
The small demonstrations shown here do not represent attacks against production RSA or AES implementations. They make the underlying principles observable.
That is their practical value.
Organizations do not need to react to quantum computing with immediate, large-scale replacement projects. They do need to understand which cryptographic assumptions their systems depend on and whether those systems can adapt when migration becomes necessary.
The technical problem starts with algorithms. The operational problem starts with visibility.
Sources
- DIAMATIX technical demonstration by Krasimir Koev, PhD, Chief Information Security Officer, using Python and Qiskit.
- NIST. Post-Quantum Cryptography Standardization.
- NIST. FIPS 203, FIPS 204 and FIPS 205.
- IBM Qiskit documentation. Quantum algorithms and circuit implementation.







