The simple math behind public key cryptography

Original version of This story Appeared in Quanta Magazine.

For thousands of years, if you wanted to send a secret message, there was actually a way to do it. You will rotate the message using a special rule, known only to you and your intended audience. This rule worked like a key to a lock. If you had the key, you could open the message; Otherwise, you will need to pick the lock. some locks are so effective that they can never be selected, despite unlimited time and resources. But even those schemes suffer from the same Achilles’ heel that afflicts all such encryption systems: How do you get that key into the right hands while keeping it out of the wrong people?

Known as the counter-intuitive solution Public key cryptographyDepends not on keeping a key secret, but on making it widely available. The trick is also to use a second key that you never share with anyone, not even the person you’re communicating with. It is only by using this combination of two keys—one public, one private—that someone can scramble and open a message.

To understand how this works, it’s easy to think of the “keys” not as objects that fit into a lock, but as two complementary elements in an invisible ink. The first content makes the messages disappear, and the second makes them reappear. If a detective named Boris wants to send a secret message to his counterpart Natasha, he writes a message and then uses the first material to make it invisible on the page. (This is easy for her to do: Natasha has published an easy and well-known formula for making the ink disappear.) When Natasha receives the paper in the mail, she applies the second ingredient to Boris’s message. reappears.

In this scheme, anyone can make messages invisible, but only Natasha can make them visible again. And since she never shares the formula for the second ingredient with anyone—not even Boris—she can be sure the message isn’t misunderstood along the way. When Boris wants to get secret messages, he simply adopts the same method: he publishes an easy recipe for making the messages disappear (which Natasha or anyone else can use), while keeping another one just for himself. is what reveals them again.

In public key cryptography, the “public” and “private” keys act like the first and second elements in this special invisible ink: one encrypts messages, the other decrypts them. But instead of using chemicals, public key uses mathematical puzzles called cryptography Trapdoor function. These functions are easy to calculate in one direction and very difficult to inverse. But they also contain “trap doors,” pieces of information that, if known, make functions marginally easier to compute in both directions.

A common trapdoor function involves multiplying two large prime numbers, an easy operation to perform. But reversing it—that is, starting with the product and finding each prime factor—is computationally impractical. To create a public key, start with two large prime numbers. These are your trap doors. Multiply the two numbers together, then add something Mathematical operations. This public key can now encrypt messages. To decrypt them, you’ll need the corresponding private key, which contains the prime factor – the required trapdoor. With those numbers, the message is easy to decrypt. Keep those two key factors secret, and the message will remain secret.

Leave a Comment