Introduction
You most likely carry a computer in your pocket. Not a phone — a card. The little gold square on a bank card hides a real tiny computer: a processor, memory and a program. It keeps a secret and decides by itself what to answer the terminal. In this kit you will build such a computer from transistors — and at the end fold it into one chip with eight legs, like the contact pad on a card.
Inside:
- its own processor — 8 bits, 16 commands, one command per clock;
- a ROM with the program — a chip; how the program is written in assembly we will go through in lesson 7;
- RAM from latches — 8 cells of 8 bits, made of transistors;
- the card's personal data — account number, PIN and secret key — a transistor matrix, like in the "Character Generator";
- one data wire — like on real cards: the card and the terminal talk in turn;
- a card tester — switches, a "send" button and a display: that is how developers test cards.
How big it is
The card is 6,495 transistors and 8 resistors, the tester another 1,729 and a resistor. More than half of the card is the processor and the RAM: the 64 memory latches are the longest part of the build, and the repeated rows are handy to paste ready-made (Cmd+I).
The lessons have ⚠ A common mistake boxes — mistakes that really happened while this card was being built. None of them is visible right away: the card answers, but wrongly. So after every lesson there is a check by the table, step by step.
This is a model, not a real card
We build the principle: how the computer in a card is made, how it talks to the terminal over one wire, how it checks the PIN and proves that it is genuine. Everything works in the simulator — but the sizes and the strength are for learning, so that the circuit can be built by hand and seen right through. How our card differs from a real one:
| What | A real card | Our card |
|---|---|---|
| processor | 8–32 bits + a crypto coprocessor | 8 bits, 16 commands |
| where the PIN is | EEPROM: changed at an ATM by a bank command signed with the bank's key | hard-wired in a transistor matrix — can be changed only by rewiring |
| secret key | 128 bits and more (3DES, AES) | 32 bits |
| cipher | strong: 3DES, AES; RSA/ECC signatures | a teaching one: 4 rounds "+, XOR, rot" |
| challenge / answer | 4 bytes / 8 bytes | 2 bytes / 2 bytes |
| data wire | the ISO 7816 standard, from ~1000 bytes/s | our own frame, 16 clocks per bit |
| who checks the answer | the bank, keys in a protected vault (HSM) | we do, by the check table |
Our 32-bit key with a teaching cipher can be found by brute force in seconds — a real one cannot be found in the whole lifetime of the Universe. But the idea is the same: the key never leaves the card, and the answer depends both on the challenge and on the key.
What you need
The gates NOT, NAND, NOR, AND, OR, XOR: already in the library — take them; want to build them from scratch out of transistors — lesson 0; straight to the point — the lesson 0 paste. Everything else we build here.
What you will get
Eight lessons: a calculator on switches → lights by the program → memory → loops → the wire and the tester → the PIN → challenge-response → the card as a chip. At the end there are two cards on the table that look the same from outside. One accepts PIN 1234, the other 4321, and they answer the same challenge differently. The difference is a few dozen transistors out of six and a half thousand.