I have this C code to multiply by GF (8):
int32_t GaloisMultiply (int32_t a, int32_t b) { int32_t i; int32_t mask = 0x100; int32_t y = 0; for(i=0;i<8;i++) { if(b & mask) { y ^= a; } mask >>= 1; y <<= 1; } if(b & 0x1) { y ^= a; } return(y); }
This is more or less a textbook implementation.
I wonder if I have smart optimization for the above algorithm, if I can argue that a is always b, for example. I do squares instead of multiplication. I am not after cryptographic use by the way. I just want to use the fact that x * x in GF (8) interleaves the x bits with zero bits one by one.
There are already pretty clever methods for performing bit interleaving, but since I found that x * x in GF (8) does the bit interleaving operation (by accident), I can't stop trying to use it to optimize bit interleaving.
Any ideas?
source share