Ulugh Beg-64: the workshop cipher
The Samarkand observatory workshop built a new 64-bit block cipher, Ulugh Beg-64 (v2): 7 rounds, 16 parallel 4-bit S-boxes, a bit-permutation layer and a 192-bit master key (three 64-bit words; the round keys come from it through an invertible schedule). The “wiring” of the last round is a workshop secret: it is derived from the master key (the rule is written in cipher.py).
To test it, the craftsmen encrypted plaintext pairs chosen with one common difference and kept the results. You get cipher.py (the full specification, without the key, with a test vector), pairs.bin (70,000 records P, P2, C, C2, 8 bytes each, big-endian) and flag.enc (AES-256-GCM; the key is the SHA-256 of the three master-key words, the format is described inside cipher.py).
Recover the master key and open the flag. Format: AIFT{...}.