Instructions from Intel GFNI (Galois Field New instructions) designed to perform affine transformations on packed 8-bit elements.
Introduction
The instruction name can broken into fairly understandable bits
GF2-P8-AFFINE-Q-B, where
- GF2 stands for , the Galois field with two elements
- P8 is for power of 8 (). It specifies the field sizea as it works with 8-bit bytes, so operation operating within the finite field
- Affine indicates affine transformations, which means it multiplies and 8-bit element by an 8 8 bit matrix and then adds (XORs) and 8-bit vector constant.
- Qword variant, the transformation matrix is supplied as a qword 64-bit; each 64-bit chunk contains the 8 8 matrix representations
- B, the elements being transforrmed are bytes.
A high level interpretation is: perform an affine transformations over on packed 8-bit elements.
Here each byte is treated as an 8-bit vector over . Mathematically operation can be represented as:
,the matmul is operated over Galois field, whichm means instruction is essentially performing 8 XOR equations in parallel for every byte.
A byte as a vector over 8-bit Galois field
Consider an 8-bit byte
where each bit satisfies
We can represent the byte as an 8-dimensional vector over :
An matrix whose entries are elements of can then operate on this vector:
The resulting vector is
Because the arithmetic is performed over , addition is XOR and multiplication is AND.
For example, if
then
Thus, an binary matrix can be viewed as eight XOR equations, one for each output bit.
For an affine transformation, an additional constant vector is added:
just a draft, will continue later