RSA is a public-key construction: a public key and a related private key have different roles. In the simplified two-prime model, the modulus n is the product of primes p and q. A prime is an integer greater than one with no positive divisors except one and itself. A modulus sets the remainder arithmetic used in the operation.
The public pair is (n,e), where e is an exponent. A corresponding private exponent d is kept private in a real system. The tiny numbers here let you follow arithmetic. They are far too small for protection, and raw exponentiation without a specified secure encoding scheme is not production RSA encryption.
Before you begin
- Recommended first
- Hex, Base64, and XOR in code, Encoding, hashing, and encryption, Notes: scope, command, result, time, Block ciphers and the ECB picture
- Estimated time
- 15 min reading, 15 min activity. Setup and optional practice may take longer.
- Where you work
- Read the printed evidence in a desktop or mobile browser and keep notes on paper or in a text editor. No installation, recovery tool, GPU, real password, live lookup or external account is required. Any later optional tool setup is outside the estimates.
- Without a lab
- All evidence needed for the activity appears on this page. Copy it into notes if downloads are unavailable. Read the labeled model and predict each result; a paper trace practises the reasoning while tool operation waits for a lab. Reading needs no JavaScript. Answer checking needs JavaScript and a secure context; saving progress also needs usable browser storage.
After this lesson you can:
- Multiply the activity primes 3 and 5.
- Follow the worked message 4 out to 31 and back under modulus 33.
- Name the public pair (n, e) and the private exponent d as different roles.
01Example
Original tiny arithmetic model. Here ^ denotes exponentiation in mathematical prose; Python uses pow or ** for powers.
p=3, q=11 → n=33
Message m=4; public exponent e=3
4^3 = 64; remainder after division by 33 is 31
Cipher number c=31; private exponent d=7
31^7 mod 33 returns 4 in this toy model.02The pair you can publish is (n, e)
The phrase x mod n means the remainder when x is divided by n. The toy encryption raises m to e and keeps that remainder; the inverse operation uses d. These powers explain roles but omit the encoded-message processing that real RSA schemes require.
RFC 8017 separates key types, primitives and encryption schemes such as RSAES-OAEP. A scheme specifies more than n=p×q. The earlier 2026-10-12 course record reports toy-rsa.py printing worked n=33, activity n=15 and round trip 4. Those are historical toy outputs, not a new key-generation run or proof of usable security.
Compute the product used as a toy RSA modulus while keeping raw arithmetic separate from real schemes.Model. A teaching model drawn by hand. It shows the idea, not real tool output.
Read the full explanation below.
3 × 11 = 33Toy integers illustrate the calculation; these values do not provide secrecy.
The supplied toy factors give 3 × 11 = 33.
Follow the explanation
- The supplied toy factors give 3 × 11 = 33.
- The public pair is (n, e) = (33, 3).
- The supplied message power is 4³ = 64.
- 64 divided by 33 leaves remainder 31.
- The supplied private exponent returns the original toy message.
Read every state and value
1. The supplied toy factors give 3 × 11 = 33.
- Stage
- product
- Equation
- 3 × 11 = 33
- Visible Role
- p · q · n
2. The public pair is (n, e) = (33, 3).
- Stage
- public-pair
- Equation
- (n, e) = (33, 3)
- Visible Role
- n · e · m
3. The supplied message power is 4³ = 64.
- Stage
- power
- Equation
- 4^3 = 64
- Visible Role
- m · e · n
4. 64 divided by 33 leaves remainder 31.
- Stage
- remainder
- Equation
- 64 mod 33 = 31
- Visible Role
- m · e · n · c
5. The supplied private exponent returns the original toy message.
- Stage
- return
- Equation
- 31^7 mod 33 = 4
- Visible Role
- c · d · n · m
03Multiply the activity primes
The guided case asks only for a product, with p=3 and q=5. No encryption, private-exponent search or real key is required.
Label: toy hand arithmetic. Historical 2026-10-12 QA separately recorded toy-rsa.py printing worked n 33, activity n 15 and round trip 4.
Public pair on the worked card: n=33, e=3. Private exponent on that card: d=7.
Message m=4. Cipher c = 4^3 mod 33 = 64 mod 33 = 31.
Return: 31^7 mod 33.
31^2 = 961 = 29*33 + 4
31^4 = 16 mod 33.
31^5 = 1 mod 33.
31^7 = (31^5)*(31^2) = 4 mod 33.
31^7 = 4 mod 33.
Predicted return: 4.
Activity primes: p=3, q=5.
Predicted modulus: 15.
"""Print the worked and activity moduli. Authoring did not run this file.
The numbers are a classroom size. They are not a deployable key.
The file does not contain the field primes. Do not use the result as a real key.
"""
def main():
print("worked n", 3 * 11)
print("activity n", 3 * 5)
print("worked round trip", pow(31, 7, 33))
if __name__ == "__main__":
main()
- Write n=p×q using the two activity primes rather than the worked pair.
- Multiply 3×5 and compare your result with the activity modulus 15.
- Write one limit beside the result: a product this small is educational and must not be deployed as a key.
- Stop after the calculation. The later checkpoint supplies its own prime pair; leave it for that independent question.
04Optional challenge
For about ten optional minutes, make a three-row vocabulary note: modulus n, public exponent e and private exponent d. Then add a separate line for a complete encryption scheme’s encoding/padding requirements. The rubric is correct roles and an explicit warning that the toy arithmetic is incomplete for real protection.
05Fresh cases for the checks
Use these fictional cases for the checks below. They have different inputs from the worked examples. Read them here or make notes; no installation or external service is needed.
Modulus card A: independent tiny prime pairOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
Worksheet primes: p=11, q=13.
Rule: n=p×q. Only the modulus is requested; this is not a usable key.
Power card B: separate supplied arithmetic traceOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
Toy parameters: n=35; public exponent e=5; corresponding private exponent d=5.
Message m=2. Forward rule: c=m^e mod n. Here ^ means a mathematical power.
Supplied arithmetic: 2^5=32; 32=35×0+32.
For a separate reverse check: 32^5=33554432; 33554432=35×958698+2.
These are raw arithmetic statements, not production RSA encryption.
Roles card C: independent parameter descriptionOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
For this tiny two-prime model: n sets the remainder arithmetic; e is the public exponent; d is the corresponding private exponent.
The public key pair is (n,e). The private exponent is kept separate.
Real encryption schemes require additional encoding/padding and appropriate security parameters.
06Explain the evidence and its limit
Optional self-check: state modulus, public pair and private exponent, then connect one raw forward and reverse remainder trace.
Review it: keep powers distinct from remainders, do not copy mathematical ^ into Python as exponentiation, and explain that tiny raw RSA omits required production scheme details.
07Common mistakes
If the guided modulus is 33, you copied the worked pair instead of multiplying the activity primes.
If ^ is copied into Python expecting a power, recall that Python uses it for XOR. Read pow in the supplied source rather than executing a mistaken expression.
If a round trip seems sufficient for security, separate arithmetic consistency from suitable key sizes and scheme requirements.
References
- RFC 8017: PKCS #1 v2.2
Key types and RSA scheme requirements provide context for the deliberately incomplete classroom arithmetic.
- Python 3.12: pow
The three-argument pow(base, exp, mod) form performs modular exponentiation.