def signal_1D(mu, i, key, n):
	"""
	Generate signal power consumption S values for all messages mu. 

	Parameters:
	mu  -- list of bool, size n x 2^n
	i   -- integer in [0,n-1]
	key -- list of bool, length n
	n   -- integer

	Return:
	S -- list of integers, length 2^n
	"""
	S = []

	# For each message mu
	for j in range(len(mu)):

		# Activity of the first storage cell of the register
		d = key[i] ^ mu[j][i] ^ ((key[(i+1) % n] ^ mu[j][(i+1) % n] ^ bool(1)) & (key[(i+2) % n] ^ mu[j][(i+2) % n]))

		# Power consumption model
		S_j = (-1)**(d)

		S.append(S_j)

	return S