def get_delegated_OTP_keys(permutation, x_key, z_key, num_qubits=14, syndrome_cnots = [[14, 0], [14, 2], [14, 4], [14, 6], [15, 1], [15, 2], [15, 5], [15, 6], [16, 3], [16, 4], [16, 5], [16, 6], [17, 7], [17, 9], [17, 11], [17, 13], [18, 8], [18, 9], [18, 12], [18, 13], [19, 10], [19, 11], [19, 12], [19, 13]]):
  """ 
  Get delegated, post-processed, classical one-time pad keys for a program

  Parameters:
  permutation ([int]): permutation key
  x_key ([int]): X part of the non-delegated one-time pad key
  z_key ([int]): Z part of the non-delegated one-time pad key
  num_qubits (int): number of data qubits
  syndrome_cnots ([[int,int]]): all cnot gates used to derive error syndromes

  Returns:
  delegated_x_key ([int]): classically processed and delegated X part of one-time pad key
  delegated_z_key ([int]): classically processed and delegated Z part of one-time pad key
  """
  permuted_cnots = []
  for gate in syndrome_cnots:
    permuted_cnots.append([gate[0],permutation.index(gate[1])])

  new_x_key = x_key[:]
  new_z_key = z_key[:]

  for cnot in permuted_cnots:
    a = new_x_key[cnot[0]]
    b = new_z_key[cnot[0]]
    c = new_x_key[cnot[1]]
    d = new_z_key[cnot[1]]
    new_x_key[cnot[0]] = a
    new_z_key[cnot[0]] = b+d
    new_x_key[cnot[1]] = a+c
    new_z_key[cnot[1]] = d

  #hadamard operator delegation
  for i in range(num_qubits,num_qubits + int(num_qubits/7*3)):
    new_x_key[i], new_z_key[i] =  new_z_key[i], new_x_key[i]

  delegated_x_key = [i%2 for i in new_x_key]
  delegated_z_key = [i%2 for i in new_z_key]
  return delegated_x_key, delegated_z_key