def matrix_identity(dim):
   """
   Calculate the identity matrix with dimension dim in the finite field.

   Parameters:
   dim(int): Dimension of identity matrix

   Returns:
   matrix(list): Identity matrix with dimension dim
   """
   matrix = []

   for i in range(dim):
      aux = []
      for j in range(dim):
         if i == j:
            aux += [[0,0,0,0,0,0,1]]
         else:
            aux += [[0,0,0,0,0,0,0]]
      matrix += [aux]
   return matrix