Payment Cryptography, Hands-On
A practical course

How card payments keep their secrets

HSMs, zone master keys, key check values, TR-31 (ANSI X9 Technical Report 31, the key block format) key blocks, CVVs, EMV (Europay, Mastercard, Visa — the chip card standard) cryptograms and PIN (Personal Identification Number) blocks — explained from zero, with a live calculator for every idea and exercises that go from warm-up to boss level.

Who this is for Software engineers who landed in a payments team and keep hearing “ZMK”, “KCV”, “key ceremony”, “IMK”, “TR-31” in meetings. You don’t need a maths background. You do need curiosity and about eight evenings.

The story in one picture

A card is a tiny computer that must prove it is genuine. Proof means cryptography; cryptography means shared secret keys. Three organisations need some of the same keys:

Card networkVisa, Mastercard
Issuer processorauthorises transactions, runs the HSM (Hardware Security Module)
Card bureaumakes and personalises the cards

Keys can never travel in clear, so each pair of organisations first shares a zone master key — split into paper components and typed into hardware by different people. Everything else in this course hangs off that one idea.

Modules

MODULE 1The cryptographer’s toolbox

Bytes and hex, XOR, DES/3DES and AES, ECB vs CBC, parity bits, and MACs — the only primitives payment systems really use.

MODULE 2HSMs and the key hierarchy

Why clear keys only exist inside a hardware security module, the three-level hierarchy (MFK/LMK → KEK → working keys), and the vendors you will meet.

MODULE 3Key exchange: ZMK, components, ceremonies and KCV

How two companies end up with the same secret key: zones, ZMK components, split knowledge, the key ceremony, and the key check value that proves it worked.

MODULE 4Key blocks: TR-31, AKB and X9.143

Why “a key encrypted under a ZMK” is not enough, how TR-31 binds a key to its purpose, and how to read a key block header character by character.

MODULE 5Card verification values: CVV, CVV2, iCVV

How a three-digit code is computed from the card number with a secret key, why there are three different ones on every card, and what service codes have to do with it.

MODULE 6EMV chip keys: IMK → card key → session key → ARQC

How one issuer master key becomes millions of card-unique keys, how a chip proves each transaction is genuine (ARQC/ARPC), and what MK-AC, MK-SMI, MK-SMC, IDN and CVC3 keys are for.

MODULE 7PINs: PIN blocks, ZPKs and translation

How a PIN travels from the keypad to the issuer without ever being in clear: ISO PIN blocks, PIN encryption keys per zone, PIN translation in the HSM, and PIN verification values.

MODULE 8Putting it together: launching a new BIN

The whole process an issuer processor goes through when a new card range goes live — parties, zones, which keys go where, the checklist, and a final boss exercise that uses every module.

REFERENCEGlossary

Every acronym in the course, one line each — AKB to ZPK.

REFERENCEReading list and the book map

Where to go deeper — free official docs, books, open-source libraries, and which pages of “Criptografía esencial” back up which module.

How to use this course

  • Read, then play. Every concept has a calculator next to it. Change the inputs and watch what moves.
  • Do the exercises in order. warm-up checks you followed the text; practice uses a calculator; challenge needs you to combine ideas; boss is what the job actually looks like. Numbers are random on each visit, so you can repeat them.
  • Progress is saved in this browser (green bars in the menu).
  • Companion book: if you have Criptografía esencial (González Vasco & Pérez del Pozo, Ra-Ma 2021), each module points to the pages that back it up. ~60 pages in total — the rest of the book you can skip.
Safety rule These tools are for learning. Never paste real production keys, components, PINs or card numbers into any website — including this one. Real keys live only inside HSMs.