Close

Thank you Bob!

A project log for PEAC Pisano with End-Around Carry algorithm

Add X to Y and Y to X, says the song. And carry on.

yann-guidon-ygdesYann Guidon / YGDES 02/04/2022 at 00:560 Comments

If you don't know http://www.burtleburtle.net/bob/hash/ then you miss a lot of great ideas, publicly published while they are probably well known and taught in the secret circles of state-sponsored cryptogeeks. It's only a modest personal research though it contains a lot of essential background so go read it.

When I was exploring the field of CRC/block checksums for my custom protocols (mostly 2006-2009) I was seduced by Bob's lookup3.c and examined it for a while. Scanning a block would apply this transform for each triplet of 32-bit words:

#define mix(a,b,c) \
{ \
  a -= c;  a ^= rot(c, 4);  c += b; \
  b -= a;  b ^= rot(a, 6);  a += c; \
  c -= b;  c ^= rot(b, 8);  b += a; \
  a -= c;  a ^= rot(c,16);  c += b; \
  b -= a;  b ^= rot(a,19);  a += c; \
  c -= b;  c ^= rot(b, 4);  b += a; \
}

Going back to this today, several similarities and parallels strike me. It now feels familiar... And I'm connecting the dots tonight.

Hindsight is 20/20 they say and I have learned a lot since then. Today, while exchanging a message with him, I realise:

That and a few other things (such as when I scrambled the output of a LFSR) came to my mind, and I wondered:

Why don't I use X × PEAC scramblers that scramble each other's states in a ring ?

why, oh why...

Such a system, for example with 4 or 8× PEAC16x2, would be simple, fast and provably robust. It could still work as scrambler, PRNG and checksum. And I wouldn't have to spend ages to prove that w32 (or larger) is or is not perfect or maximal.

And if mixing is really important for you, between steps you can also perform LUT scrambling (or similar non-linear operations) because PEAC can't be 0-crashed (just don't mess with the carry bit).

I still need some time to unfold everything in my head so stay tuned...

Discussions