## 4 Two Countermeasures against Zero-Dynamics Attack
### Generalized-Sampler-Based Approach  
By GS, we mean a device that generates a discrete-time signal \(\tilde{y}_{k}\) from a continuous-time signal \(y(t)\) in a way that \(N\) measurements (i.e., generator angular velocity) \(y(\frac{1}{N}T_{s}+(k-1)T_{s}),y(\frac{2}{N}T_{s}+(k-1)T_{s}),\ldots,y(kT_{s})\) are taken from the sampling interval \(((k-1)T_{s},kT_{s})\) and a weighted average of them is computed as  
\[\tilde{y}_{k}=\sum_{i=1}^{N}w_{i}y\bigg{(}\frac{i}{N}T_{s}+(k-1)T_{s}\bigg{)}, \tag{20}\]  
where \(w_{1},\ldots,w_{N}\) are weights for GS.  
Similar to the case of GH, we can rewrite the system (6) under constant wind speed and ZDA as  
\[\begin{split}\tilde{x}_{k}&=\hat{A}_{\text{d}}\hat{x }_{k-1}+\hat{B}_{\text{d}}(\hat{u}_{k-1}+u_{k-1})\\ \tilde{y}_{k}&=\tilde{C}_{\text{d}}\hat{x}_{k-1}+ \tilde{D}_{\text{d}}(\hat{u}_{k-1}+u_{k-1}),\end{split} \tag{21}\]  
where  
\[\begin{split}\hat{A}_{\text{d}}&=e^{\hat{A}_{s}T_{ s}},\qquad\qquad\qquad\hat{B}_{\text{d}}=\int_{0}^{T_{s}}e^{\hat{A}_{s}(T_{s}- \tau)}\hat{B}_{s}d\tau\\ \tilde{C}_{\text{d}}&=\sum_{i=1}^{N}w_{i}C_{\text{ d}}e^{\hat{A}_{s}\frac{i}{N}T_{s}},\quad\tilde{D}_{\text{d}}=\sum_{i=1}^{N}w_{i}C_{ \text{d}}\int_{0}^{\frac{i}{N}T_{s}}e^{\hat{A}_{s}(\frac{i}{N}T_{s}-\tau)}\hat{ B}_{s}d\tau.\end{split}\]  
From (21), we can compute the transfer function from \(\hat{u}_{k}\) to \(\hat{y}_{k}\) as  
\[G_{\text{d}}(z)=z^{-1}(\tilde{C}_{\text{d}}(zI-\hat{A}_{\text{d}})^{-1}\hat{ B}_{\text{d}}+\tilde{D}_{\text{d}}). \tag{22}\]  
Note that \(\tilde{C}_{\text{d}}\) and \(\tilde{D}_{\text{d}}\) contain the sampler weights \(w_{1},\cdots,w_{N}\) of GS, which are design parameters. If the weights are chosen appropriately, it is expected that the numerator of the transfer function (22) can be chosen as desired. In fact, this is true under mild assumptions [24].  
Let \(z_{d,1},z_{d,2}\), and \(z_{d,3}\) be the desired zeros whose magnitudes are less than \(1\). We want to find the weights of GS such that the transfer function \(G_{\text{d}}(z)\) becomes identical to  
\[G_{\text{d}}^{*}(z)=k_{d}z^{-1}\frac{(z-z_{d,1})(z-z_{d,2})(z-z_{d,3})}{\det(zI -\hat{A}_{\text{d}})}, \tag{23}\]  
where \(k_{d}\) is a high-frequency gain. To proceed, let \(c_{0}\), \(c_{1}\), \(c_{2}\) be such that \((z-z_{d,1})(z-z_{d,2})(z-z_{d,3})=z^{3}+c_{2}z^{2}+c_{1}z+c_{0}\). We first find \(\tilde{C}_{\text{d}}\) and \(\tilde{D}_{\text{d}}\), then determine the weights \(w_{i}\). As in the case of GH, we realize (23) in the control canonical form given by  
\[\begin{split}\tilde{x}_{k}&=A_{\text{con}}  
we have, from the controllability of \((\hat{A}_{\rm d},\hat{B}_{\rm d})\),  
\[\hat{C}_{\rm d} =C_{\rm con}\big{[}B_{\rm con}\quad A_{\rm con}B_{\rm con}\quad A_{ \rm con}^{2}B_{\rm con}\big{]}\big{[}\hat{B}_{\rm d}\quad\hat{A}_{\rm d}\hat{B}_ {\rm d}\quad\hat{A}_{\rm d}^{2}\hat{B}_{\rm d}\big{]}^{-1}\] \[\hat{D}_{\rm d} =k_{d}.\]  
With \(\hat{C}_{\rm d}\) and \(\hat{D}_{\rm d}\) obtained above, it follows from the relation between the weights and \((\hat{C}_{\rm d},\hat{D}_{\rm d})\) that  
\[\big{[}\hat{C}_{\rm d}\quad\hat{D}_{\rm d}\big{]}=w\begin{bmatrix}C_{\rm d}e^{ \hat{A}_{\rm s}\frac{1}{N}T_{\rm s}}&C_{\rm d}\int_{0}^{\frac{1}{N}T_{\rm s}}e^ {\hat{A}_{\rm s}(\frac{1}{N}T_{\rm s}-\tau)}\hat{B}_{s}d\tau\\ C_{\rm d}e^{\hat{A}_{\rm s}\frac{1}{N}T_{\rm s}}&C_{\rm d}\int_{0}^{\frac{2}{N} T_{\rm s}}e^{\hat{A}_{\rm s}(\frac{2}{N}T_{\rm s}-\tau)}\hat{B}_{s}d\tau\\ \vdots&\vdots\\ C_{\rm d}e^{\hat{A}_{\rm s}T_{\rm s}}&C_{\rm d}\int_{0}^{\frac{1}{N}}e^{\hat{A} _{\rm s}(T_{\rm s}-\tau)}\hat{B}_{s}d\tau\end{bmatrix}=:wM,\]  
and the weights are computed as  
\[w=\big{[}\hat{C}_{\rm d}\quad\hat{D}_{\rm d}\big{]}M^{\dagger}, \tag{24}\]  
where \(M^{\dagger}\) is the pseudo-inverse of \(M\). For more details, see [24].