QC — Cracking RSA with Shor’s Algorithm (2024)

QC — Cracking RSA with Shor’s Algorithm (2)

RSA is the standard cryptographic algorithm on the Internet. The method is publicly known but extremely hard to crack. It uses two keys for encryption. The public key is open and the client uses it to encrypt a random session key. Anyone intercepts the encrypted key must use the second key, the private key, to decrypt it. Otherwise, it is just garbage. Once the session key is decrypted, the server uses it to encrypt and decrypt further messages with a faster algorithm. So, as long as we keep the private key safe, the communication will be secure.

RSA encryption is based on a simple idea: prime factorization. Multiplying two prime numbers is pretty simple, but it is hard to factorize its result. For example, what are the factors for 507,906,452,803? Answer: 566,557 × 896,479.

QC — Cracking RSA with Shor’s Algorithm (3)

Based on this asymmetry in complexity, we can distribute a public key based on the product of two prime numbers to encrypt a message. But without knowing the prime factors, we cannot decrypt the message to its original intention. In 2014, WraithX used a budget of $7,600 on Amazon EC2 and his/her own resources to factorize a 696-bit number. We can break a 1024-bit key with a sizeable budget within months or a year. This is devasting because SSL certificates holding the public key last for 28 months. Fortunately, the complexity of the prime factorization problem grows exponentially with the key length. So, we are pretty safe since we switch to 2048-bit keys already.

But as you may guess, the curse of its complexity has been solved by the Shor’s algorithm. Shor’s algorithm is published in 1994. Before that, quantum computing is more like a curiosity. The introduction of Shor’s algorithm really changes the tone. It solves a real problem that cannot be solved by classical computers efficiently. It is the kind of paradigm shift that attracts investments. While we have discussed algorithms with a “to be done” oracle function, Shor’s algorithm is a real deal. We are just waiting for a quantum computer with enough qubits.

Shor’s algorithm involves many disciplines of knowledge. We try to be comprehensive and wish you can proceed with the speed you like. But we will not cover every implementation details since we have a lot to cover already.

The following is the RSA algorithm. You can take our words for now that if we know how to do prime factorization effectively, RSA will be history.

QC — Cracking RSA with Shor’s Algorithm (4)

However, we do need to understand a couple terms above. Greatest common divisor (gcd) finds the largest divisor between two numbers. For example,

QC — Cracking RSA with Shor’s Algorithm (5)

Two numbers are co-prime if they don’t have any common factors.

QC — Cracking RSA with Shor’s Algorithm (6)

mod” is the modulo operator that programmers familiar with (e.g. 14 % 10 = 4). Let’s review some of the modulo calculations.

QC — Cracking RSA with Shor’s Algorithm (7)

For example,

QC — Cracking RSA with Shor’s Algorithm (8)

These tricks become handy to compute

QC — Cracking RSA with Shor’s Algorithm (9)

With classical computing, the best we can solve prime factorization is:

QC — Cracking RSA with Shor’s Algorithm (10)

where n is the number of bits to represent the product of the prime numbers. Shor’s algorithm can do it in

QC — Cracking RSA with Shor’s Algorithm (11)

with the number of gates about

QC — Cracking RSA with Shor’s Algorithm (12)

But to solve it, we need to formalize the solution in an unusual way. Let’s find the prime factors for 21 with the equations below. Magically, these equations end with the number 7 and 3 which is our answer.

QC — Cracking RSA with Shor’s Algorithm (13)

But, this is not simple luck. There are many mathematical theories behind them. The basic idea is to find a number (8 in our case) with its square equals the term on the right below.

QC — Cracking RSA with Shor’s Algorithm (14)

So, let try our luck again. Start with a random guess x=2. First, we want to know whether x and N are coprime. That can be done with the Euclid’s Algorithm. Below is an example to find the common factor between 21 and 15.

QC — Cracking RSA with Shor’s Algorithm (15)

So 3 is the common factor for 21 and 15 and therefore 21 and 15 are not co-prime. If x and 21 are not co-prime, gcd(x, 21) will be one of the prime factors and we are done. But don’t expect it happen frequently in a real problem. Most likely, x is a co-prime with N. Now, we compute the following series of powers function.

QC — Cracking RSA with Shor’s Algorithm (16)

i.e with x=2.

QC — Cracking RSA with Shor’s Algorithm (17)

This function has a period of 6 (r = 6), i.e. the function values repeat itself every other 6 values. If r is divided by 2, it becomes 3. The number 8 we want is simply pow(2, 3), i.e. pow(x, 3).

QC — Cracking RSA with Shor’s Algorithm (18)

In summary, we start with a guess on x and verify whether it is co-prime with N. If not, we use gcd to find the prime factors. Otherwise, we compute the period of the power function.

QC — Cracking RSA with Shor’s Algorithm (19)

If the period r is even, the number we are seeking is pow(x, r/2) — the one underlined in red below. If r is not even, we take another guess on x and try again.

QC — Cracking RSA with Shor’s Algorithm (20)

In practice, you should have a pretty even chance of getter the period to be even. Consider the case for N = 15. We have

QC — Cracking RSA with Shor’s Algorithm (21)

So many choices of x will lead us to the right solution. The odds are pretty favorable. The difficult part is finding the period of the modulo function. Shor’s algorithm leads us to a class of algorithms called Bounded-error probabilistic polynomial time (BPP). In complexity theory, we calculate the complexity for the worst case scenario, say O(n). In practice, there are problems that finding the solution in polynomial time is the common norm even though the worst case scenario is still exponential (but the chance is usually extreme small).

Unfortunately, finding the period of the modulo function above cannot be solved easily by classical computing. That is where quantum computing comes in. Once the period of the following function

QC — Cracking RSA with Shor’s Algorithm (22)

is found by quantum computing and it is even, we compute the gcd. This is easily done with Euclid’s Algorithm as we discussed before.

QC — Cracking RSA with Shor’s Algorithm (23)

But to understand the period finding method, we need to cover a few basic concepts first.

Now, we finish the pre-processing and the post-processing part of Shor’s algorithm. Next, we will talk about Quantum Fourier Transform — our first piece of the puzzle.

QC — Quantum Fourier TransformQuantum Fourier Transform is a very critical part in Shor’s Algorithm and many other quantum algorithms. Its classical…medium.com

Here is the link for the whole series:

QC — Quantum Computing SeriesThis series covers the basics of quantum computing. The first 2 articles cover the basics followed by how it is built…medium.com
QC — Cracking RSA with Shor’s Algorithm (2024)

FAQs

Can Shor's algorithm break RSA? ›

Shor's algorithm, a quantum algorithm used to factorize large numbers, poses significant threats to RSA, a widely used public key cryptosystem.

Can RSA algorithm be cracked? ›

"Breaking RSA is usually attempted by using Shor's algorithm in a quantum computer but there are no quantum computers in existence that can produce enough gates to implement Shor's algorithm that would break 2048 keys," Woodward said.

How fast could a quantum computer crack RSA? ›

Most implementations of RSA rely on at least 2048-bit keys, which is equivalent to a number 617 digits long. Fujitsu researchers recently calculated that it would take a completely fault-tolerant quantum computer with 10,000 qubits 104 days to crack a number that large.

How long does it take to break RSA algorithm? ›

Time Required for 10^40 Operations:

So, even with the assumed computational capacity of Google's data centers, it would take approximately 19.8 quadrillion years to crack RSA-2048 using brute force. This is an astronomical time frame, far longer than the current age of the universe (which is about 13.8 billion years).

What is the largest RSA key cracked? ›

As of 2020 the largest RSA key publicly known to be cracked is RSA-250 with 829 bits. The Finite Field Diffie-Hellman algorithm has roughly the same key strength as RSA for the same key sizes.

How many years to break RSA 2048? ›

With the world's fastest supercomputers, it would take around 300 trillion years to break the 2048-bit RSA encryption. A quantum computer would be finished with a similar task in merely eight hours.

Why is RSA hard to decrypt? ›

Messages can be encrypted by anyone, via the public key, but can only be decrypted by someone who knows the private key. The security of RSA relies on the practical difficulty of factoring the product of two large prime numbers, the "factoring problem". Breaking RSA encryption is known as the RSA problem.

Has RSA ever been hacked? ›

The RSA SecurID breach was a highly sophisticated cyberattack that occurred in March 2011, in which hackers accessed the computer systems of RSA, a company that provides two-factor authentication solutions to many organizations.

Which encryption Cannot be cracked? ›

In cryptography, the one-time pad (OTP) is an encryption technique that cannot be cracked, but requires the use of a single-use pre-shared key that is larger than or equal to the size of the message being sent. In this technique, a plaintext is paired with a random secret key (also referred to as a one-time pad).

How long would it take a quantum computer to crack AES-256? ›

A 256-bit encryption is considered to be highly secure and it would take classical computers millions of years to crack it. However, quantum computers could potentially crack this level of encryption in mere seconds or minutes.

How long does it take a quantum computer to crack a password? ›

With today's computers, deciphering the key through trial and error can take millions of years. However, quantum computing changes the timeline for cracking today's encryption. By exponentially increasing processing speed, quantum computers could break the most advanced keys commonly used today in minutes.

Is RSA vulnerable to quantum computing? ›

Quantum computers are able to factor large numbers much faster than classical computers, so they could potentially break RSA encryption.

How long does it take to crack 4096-bit RSA? ›

Leading security system manufacturers predict that quantum computers will be able to break 2048-bit RSA encryption within 3-7 years. At the same time, mathematicians and various experts maintain that we will also see the ability to break ECC as well as 4096-bit RSA within 4-14 years.

What is the math behind RSA algorithm? ›

The Mathematics behind RSA. In RSA, we have two large primes p and q, a modulus N = pq, an encryption exponent e and a decryption exponent d that satisfy ed = 1 mod (p - 1)(q - 1). The public key is the pair (N,e) and the private key is d. C = Me mod N.

Is RSA algorithm weak? ›

It is now considered weak due to its vulnerability to collision attacks. RSA (Rivest-Shamir-Adleman): is a public key encryption algorithm that is widely used for secure data transmission. However, it is vulnerable to attacks if the key size is too small.

How does Shor's algorithm break ECC? ›

Shor's algorithm can be used to break elliptic curve cryptography by computing discrete logarithms on a hypothetical quantum computer. The latest quantum resource estimates for breaking a curve with a 256-bit modulus (128-bit security level) are 2330 qubits and 126 billion Toffoli gates.

What is the complexity of Shor's algorithm? ›

Shor's algorithm complexity is exponentially more efficient than known classical algorithms, such as Quadratic Sieve or General Number Field Sieve. Shor's factoring algorithm also highlights the computational power of QPE and QFT, which have applications beyond integer factorization.

What quantum algorithm can break sha256? ›

Quantum computers also threaten the security of hash functions like SHA-256 by utilizing Grover's algorithm. Grover's algorithm can search unsorted databases quadratically faster than classical algorithms, making brute-force attacks on hash functions more feasible.

Can quantum computers break SHA3? ›

The only known algorithm to break hash functions is also Grover's algorithm. Lengths of 384 bits are theoretically safe even when universal quantum computers are available. This concerns SHA-384, SHA-512, SHA3-384 and SHA3-512.

Top Articles
Automatic Investment Plan: How to Make Investing Easy
Mobile ID (MiD) | NY DMV
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Dmv In Anoka
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Umn Biology
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Selly Medaline
Latest Posts
Article information

Author: Nicola Considine CPA

Last Updated:

Views: 6317

Rating: 4.9 / 5 (69 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Nicola Considine CPA

Birthday: 1993-02-26

Address: 3809 Clinton Inlet, East Aleisha, UT 46318-2392

Phone: +2681424145499

Job: Government Technician

Hobby: Calligraphy, Lego building, Worldbuilding, Shooting, Bird watching, Shopping, Cooking

Introduction: My name is Nicola Considine CPA, I am a determined, witty, powerful, brainy, open, smiling, proud person who loves writing and wants to share my knowledge and understanding with you.