The antilog table turns an exponent into an element; the log table is its inverse, turning an element back into its exponent. Together they are the two halves of fast multiplication. Today you invert the table you just built.
Build the inverse of the antilog table and read back its key entries.
If the antilog table is “give me 2 to the power i”, the log table answers the reverse question: “what power of 2 is this element?” You build it by walking exp and writing the inverse mapping - for each index i, the value exp[i] has logarithm i. Because 2 is primitive, every non-zero element appears exactly once, so the inverse is well defined for all 255 of them.
The one hole is 0: it is never a power of 2, so it has no logarithm and its entry is meaningless. Keep that firmly in mind, because the fast multiply you write next adds two logarithms - and it must special-case a zero operand rather than read log[0]. With both tables in hand, log[3]=25 and exp[25]=3 are two views of the same fact, and multiplication is about to become a single addition of exponents.
// Invert exp: if exp[i] == v then log[v] == i. Element 0 has// no logarithm (it is never a power of 2), so leave it unset.var logt [256]bytefunc init() {for i := 0; i < 255; i++ {logt[exp[i]] = byte(i)}}