
This project implements SEA(48,8) from the Scalable Encryption Algorithm family (Standaert,
Piret, Gershenfeld, Quisquater, CARDIS 2006). SEA(n,b) is a Feistel cipher parameterised by
block/key size n and word size b. Here b = 8 and n = 6b = 48, so the block and the key are
both 48 bits, and the cipher runs nr = 51 rounds (the paper's minimum 3n/4 + 2(nb + floor(b/2)),
rounded up to an odd number). The paper's headline configuration is SEA(96,8); SEA(48,8) is a
smaller, valid member of the same family that fits a single Tiny Tapeout tile.
The chip can both encrypt and decrypt (pin ui[3]). Decryption uses the same key schedule and
the same single datapath with a different Feistel round function.
Each round uses only XOR, 8-bit modular addition, a 3-bit S-box applied bit-sliced across three words, a word rotation and a bit rotation. The round key is derived on the fly: the key register is itself run through a key-round every cycle (the master key is "encrypted" for half the rounds and "decrypted" for the other half, so the key registers return to the master key, halves swapped, when the run ends).
The hardware does one cipher round and one key round per clock cycle (51 cycles per block), in
either direction. State is 96 flops, loaded and read as a single serial shift chain {KL, KR, L, R}
(four 24-bit registers).
Security note: SEA(48,8) is a reduced-size member of the family. A 48-bit key is far too small to be secure today. This is a demonstration of a compact lightweight cipher, not a production cryptosystem.
Pins: ui[0]=SIN, ui[1]=SHIFT_EN, ui[2]=START, ui[3]=DEC (0 = encrypt, 1 = decrypt),
uo[0]=SOUT, uo[1]=BUSY, uo[2]=DONE, uo[7:3]=low 5 bits of the round counter.
rst_n low for a few clocks, then high).SHIFT_EN=1 for 96 clocks, presenting on SIN first the 48 key bits (MSB first), then the
48 plaintext bits (MSB first).SHIFT_EN=0, set DEC (0 = encrypt, 1 = decrypt) and pulse START=1 for one clock; DEC is
sampled on that clock. BUSY goes high for 51 clocks, then DONE goes high.SHIFT_EN=1 for 96 clocks, sampling SOUT before each clock edge. The first 48 bits are
the key registers (the master key with its two 24-bit halves swapped, a handy sanity check). The
last 48 bits are L_nr & R_nr.C = R_nr & L_nr is those last 48 bits with the two 24-bit halves swapped.Shifting or START while BUSY is ignored.
Test vector (hex): key 123456789ABC, plaintext ABCDEF012345 -> last 48 bits streamed out
E93A9CCE3926, i.e. ciphertext C = CE3926E93A9C.
Decryption: load the key, then the SEA ciphertext C (paper order, R_nr & L_nr) in place of the
plaintext, set DEC=1 and run as above. As for encryption, the last 48 bits streamed out have their
two 24-bit halves swapped relative to the result. Example: key 123456789ABC, ciphertext
CE3926E93A9C with DEC=1 -> last 48 bits 012345ABCDEF, i.e. plaintext ABCDEF012345.
A bit-exact Python reference model (test/sea_ref.py) follows the paper's pseudo-code literally and
is used by the cocotb test; it also checks that its own decryption inverts encryption.
None. Any microcontroller (e.g. the RP2040 on the Tiny Tapeout demo board) can drive the three input pins and read the outputs.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | SIN: serial data in (MSB first) | SOUT: serial data out (MSB first) | |
| 1 | SHIFT_EN: shift the 48-bit chain one bit per clock | BUSY: encryption running | |
| 2 | START: pulse (with SHIFT_EN=0) to start encryption | DONE: encryption finished (cleared by next shift/start) | |
| 3 | DEC: 0 = encrypt, 1 = decrypt (sampled at START) | ROUND[0] (debug) | |
| 4 | ROUND[1] (debug) | ||
| 5 | ROUND[2] (debug) | ||
| 6 | ROUND[3] (debug) | ||
| 7 | ROUND[4] (debug) |