  Anomaly detection is a protocol that detects integrity attacks on control
systems by comparing the residue signal with a threshold. Implementing anomaly
detection on encrypted control systems has been a challenge because it is hard
to detect an anomaly from the encrypted residue signal without the secret key.
In this paper, we propose a dynamic encryption scheme for a linear system that
automatically discloses the residue signal. The initial state and the input are
encrypted based on the zero-dynamics of the system, so that the effect of
encryption on the residue signal remains identically zero. The proposed scheme
is shown to be secure in the sense that no other information than the residue
signal is disclosed. Furthermore, we demonstrate a method of utilizing the
disclosed residue signal to operate an observer-based controller over encrypted
data for an infinite time horizon without re-encryption.
