◀ THE FOLD0ROOT.AI // WORLD II · GRIND · THE MAINFRAME◆ .dlw.fold
THE FOLD / GRIND / THE MAINFRAME / THE BARREL SHIFTER

THE BARREL SHIFTER

any distance in log n stages, no loop
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
A shift by k is a cascade of fixed shifts by powers of two, each switched on by one bit of k. No iteration, no variable latency.

LIT verified live. every value and distance matches a direct shift across all 2,048 combinations at eight bits; the stage count is log₂ of the width — 3, 4, 5, 6 for widths 8 through 64 — and the latency is identical for a shift by 0 and a shift by 7, so there is no data-dependent timing at all.
2 HOW IT WAS WEAVED · AI + HUMAN
The barrel shifter is why a variable shift costs the same as a fixed one on modern hardware, and why bit-manipulation code can be written without worrying about the shift amount.

AVAN (AI) verified the constant-latency property specifically, because it is the part with a security consequence: a shifter whose timing depended on k would leak k, and cryptographic code shifts by secret amounts.
3 ONE DIMENSION
Log-many stages, each one a power of two.
4 TWO DIMENSIONS · INTERACTIVE
Set a distance and watch which stages switch on.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object.
AVAN’s addition (the inverse-companion): the forward reading is that constant latency removes the timing channel. The inverse is that it moves the cost into area and power, where it is still observable. Every stage is wired whether or not it is enabled, and the enabled ones switch — so the energy drawn still depends on k even though the time does not. Read backwards, making an operation constant-time closes one side channel and leaves the power trace wide open, which is why hardened implementations worry about both.
LIT every value and distance matches a direct shift across all 2,048 combinations at eight bits; the stage count is log2 of the width - 3, 4, 5 and 6 for widths 8 through 64 - and the latency is identical for a shift by 0 and a shift by 7, so there is no data-dependent timing at all

FIG The barrel shifter is why a variable shift costs the same as a fixed one on modern hardware, and why bit-manipulation code can be written without worrying about the shift amount. AVAN verified the constant-latency property specifically, because it is the part with a security consequence: a shifter whose timing depended on k would leak k, and cryptographic code shifts by secret amounts.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE MAINFRAME · David Lee Wise (ROOT0), with AVAN