xor matrix multiplication for AES mix column stage
<p>Hi I'm writing program for AES mix column stage. Here I have to multiply two matrices of <code>(4,4)</code> shape. The only difference is that while multiplying two matrices I have to take 'xor' instead of where I have to add. e.g </p>

<pre><code>a = np.array([[1,2],[3,4]])
b = np.array([[5,6],[7,8]])
np.dot(a,b) # this gives [[(1*5+2*7),(1*6+2*8)][(3*5+4*7),(3*6+4*8)]]
            # but I want [[((1*5)^(2*7)),((1*6)^(2*8))][((3*5)^(4*7)),((3*6)^(4*8))]]
</code></pre>

<p>Here's the solution with loops</p>

<pre><code>result = [[0,0,0,0],
          [0,0,0,0],
          [0,0,0,0],
          [0,0,0,0]]

# iterate through rows of X
for i in range(len(X)):
   # iterate through columns of Y
   for j in range(len(Y[0])):
      # iterate through rows of Y
      for k in range(len(Y)):
         result[i][j] = result[i][j] ^ (X[i][k] * Y[k][j])
</code></pre>

<p>How to achieve that without using loops?</p>