code: def inv_cipher(rkey, ct, Nk=4):
      
      assert Nk in {4, 6, 8}
      Nr = Nk + 6
  
      rkey = rkey.reshape(4*(Nr+1), 32)
      ct = ct.reshape(128)
  
      # first round
      state = add_round_key(ct, rkey[4*Nr:4*(Nr+1)])
  
      for i in range(Nr-1, 0, -1):
          state = inv_shift_rows(state)
          state = inv_sub_bytes(state)
          state = add_round_key(state, rkey[4*i:4*(i+1)])
          state = inv_mix_columns(state)
  
      # final round
      state = inv_shift_rows(state)
      state = inv_sub_bytes(state)
      state = add_round_key(state, rkey[0:4])
  
      return state
docs: AES decryption cipher.