Skip to content
KinPilot™Learn & Explore
Menu

Grades 9–12 · Computing

How does a toy RSA system use different keys to encrypt and decrypt?

Public-key encryption separates two roles. A recipient publishes an encryption key while protecting a paired decryption key. A sender uses the recipient’s public key to produce ciphertext, a transformed representation intended to hide the message. The recipient uses the private key to recover the encoded message. Publishing the encryption key is part of the design, not an accidental disclosure.

D18 visual explanationInsecure toy RSA uses modulus 33 and public encryption exponent 3. Message number 2 encrypts to 8. Decryption with exponent 7 recovers 2, matching the original number. The proper private exponent is 7. Real encoding, randomized padding, key sizes, key trust and implementation security are absent.Toy public-key encryption — no securityn = 33 · encryption exponent e = 3Senderm = 2Public keyc = 8Receiverd = 7Private keyc = m³ mod 33 = 8Recovered 2: matches mEncryption and signatures have different security goals.

In the diagramToy public-key encryption — no securityn = 33 · encryption exponent e = 3Senderm = 2Public keyc = 8Receiverd = 7Private keyc = m³ mod 33 = 8Recovered 2: matches mEncryption and signatures have different security goals.

Message two encrypts to eight with e = 3 and returns to two with the proper d = 7.

The arithmetic example is intentionally insecure. Its modulus is n = 33 and its public exponent is e = 3. A pre-encoded message number m is transformed into c = m³ mod 33. The notation mod means the remainder after division. For the initial message two, eight is the ciphertext.

The paired private exponent is d = 7. Applying c⁷ mod 33 recovers two. The factors of 33 are three and eleven. Among the integers from one through thirty-two, twenty share no factor with 33 except one; that count is written φ(33) = 20. The exponents are paired because 3 × 7 = 21 leaves remainder one when divided by twenty. This relationship supports the reversible arithmetic here, but the tiny factors and message space make it unsuitable for secrecy.

Real RSA encryption needs a carefully specified encoding scheme with appropriate randomized padding, suitable key sizes and secure implementation. A sender also needs a trustworthy association between a public key and the intended recipient. A mathematically valid round trip alone does not establish those properties.

Encryption and digital signatures serve different purposes. Encryption aims at confidentiality for a recipient; signatures support verification associated with a signing key. Simply reversing the labels of raw exponent operations does not produce interchangeable secure schemes. This lesson shows public-to-private encryption roles, not proof of a sender’s identity or factual truth.

About this explanation

Starting knowledge: Calculate small powers and remainders and distinguish public information from a protected secret.

Sources

  • Cornell University, CS 2800 — RSA: Public-key encryption and signing roles
  • RFC Editor — PKCS #1: RSA encryption and OAEP encoding
← Grades 9–12 topics