## 3 A New Dual-Rail-Based Power-Balancing Countermeasure without Look-Up Tables
### Constant ADD Operation
```
1:\(x_{\in E_{1}},y_{\in E_{2}}\), Carry \(c_{\in E_{2}}\), and \(l=max(\lceil\log_{2}(k-1)\rceil,1)\)
2:Carry \(c_{\in E_{2}},z_{\in S_{3}}(=E_{3}(x+y\mod 2^{k}))\)
3:\(P,P^{\prime},G\gets 0\)
4:\(P_{\in E_{3}}\gets x_{\in E_{1}}\oplus y_{\in E_{2}}\)
5:\(P_{\in E_{1}}\gets P_{\in E_{3}}\oplus(\mathtt{0b}\ 1100...)\)
6:\(P^{\prime}_{\in E_{1}}\gets P_{\in E_{1}}\)
7:\(G_{\in E_{1}}\leftarrow\mathtt{ConstAND}(x_{\in E_{1}},y_{\in E_{2}})\)
8:\(G_{\in E_{2}}\gets G_{\in E_{1}}\oplus(\mathtt{0b}\ 0110...)\)
9:for\(i=0\) to \(l-2\)do
10:\(T\gets 0\); \(T\gets G_{\in E_{2}}\ll(4\ll i)\)
11:\(T_{\in E_{2}}\gets T\oplus(\mathtt{0b}\...0000\ 1100...)\)
12:\(T_{\in E_{1}}\leftarrow\mathtt{ConstAND}(P_{\in E_{1}},T_{\in E_{2}})\)
13:\(G_{\in E_{3}}\gets T_{\in E_{1}}\oplus G_{\in E_{2}}\)
14:\(G_{\in E_{2}}\gets G_{\in E_{3}}\oplus(\mathtt{0b}\ 1010...)\)
15:\(T\gets 0\); \(T\gets P_{\in E_{1}}\ll(4\ll i)\)
16:\(T_{\in E_{1}}\gets T\oplus(\mathtt{0b}\...0000\ 1010...)\)
17:\(P_{\in E_{2}}\gets P_{\in E_{1}}\oplus(\mathtt{0b}\ 0110...)\)
18:\(P_{\in E_{1}}\leftarrow\mathtt{ConstAND}(T_{\in E_{1}},P_{\in E_{2}})\)
19:endfor
20:\(T\gets 0\); \(T\gets G_{\in E_{2}}\ll(4\ll(l-1))\)
21:\(T_{\in E_{2}}\gets T\oplus(\mathtt{0b}\...0000\ 1100...)\)
22:\(T_{\in E_{1}}\leftarrow\mathtt{ConstAND}(P_{\in E_{1}},T_{\in E_{2}})\)
23:\(G_{\in E_{3}}\gets T_{\in E_{1}}\oplus G_{\in E_{2}}\)
24:\(c\leftarrow\mathtt{0}\); \(c\leftarrow\mathtt{MSCW}\) of \(G_{\in E_{3}}\) {MSCW : Most Significant Codeword}
25:\(c_{\in E_{2}}\gets c\oplus(\mathtt{0b}\...1100\ 1010)\)
26:\(T\gets 0\); \(T\gets G_{\in E_{3}}\ll 4\)
27:\(T_{\in E_{2}}\gets T\oplus(\mathtt{0b}\...1010\ 1100)\)
28:\(z_{\in E_{2}}\gets P^{\prime}_{\in E_{1}}\oplus T_{\in E_{2}}\)
29:return\((c_{\in E_{2}},z_{\in E_{3}})\)
```
**Algorithm A2**BKSAdderCoron, Coron's KS Adder Applied to Power-balancing Methods
```
1:\(x^{\prime},y^{\prime}\in\{0,1\}^{k-1}||\{0\}\), Carry \(c\in\{0,1\}\), and \(l=max(\lceil\log_{2}(k-1)\rceil,1)\)
2:Carry \(c\in\{0,1\},z^{\prime}(=x^{\prime}+y^{\prime}+2c\mod 2^{k})\in\{0,1\}^{k-1}||\{0\}\)
3:\(P\gets x^{\prime}\oplus y^{\prime}\)
4:\(P^{\prime}\gets P\)
5:\(G\leftarrow(x^{\prime}\wedge y^{\prime})\oplus c\)
6:for\(i=0\) to \(l-2\)do
7:\(G\leftarrow(G\wedge(G\ll(1\ll i)))\oplus G\)```
1:\(x^{\prime}_{c_{E_{1}}},y^{\prime}_{c_{E_{2}}}\), Carry \(c_{c\in E_{2}}\), and \(l=max(\lceil\log_{2}(k-1)\rceil,1)\)
2:\(\text{Carry }c_{c\in E_{2}},z^{\prime}_{c\in E_{3}}(=E_{3}(x^{\prime}+y^{\prime}+2c\mod 2 ^{k}))\)
3:\(P,P^{\prime},G\gets 0\)
4:\(P_{\in E_{3}}\gets x^{\prime}_{c\in E_{1}}\oplus y^{\prime}_{c\in E_{2}}\)
5:\(P_{\in E_{1}}\gets P_{\in E_{3}}\oplus(\texttt{0b }\texttt{1100...})\)
6:\(P^{\prime}_{\in E_{1}}\gets P_{\in E_{1}}\)
7:\(G_{\in E_{1}}\leftarrow\text{ConstAND}(x^{\prime}_{c\in E_{1}},y^{\prime}_{c \in E_{2}})\)
8:\(G_{\in E_{3}}\gets G_{\in E_{1}}\oplus c_{\in E_{2}}\)
9:\(G_{\in E_{2}}\leftarrow G_{\in E_{1}}\oplus(\texttt{0b }\texttt{1010...})\)
10:for\(i=0\) to \(l-2\)do
11:\(T\gets 0\); \(T\gets G_{\in E_{2}}\ll(4\ll i)\)
12:\(T_{c\in E_{2}}\gets T\oplus(\texttt{0b }...\texttt{00000 }\texttt{1100...})\)
13:\(T_{c\in E_{1}}\leftarrow\text{ConstAND}(P_{\in E_{1}},T_{c\in E_{2}})\)
14:\(G_{\in E_{3}}\gets T_{c\in E_{1}}\oplus G_{\in E_{2}}\)
15:\(G_{\in E_{2}}\gets G_{\in E_{3}}\oplus(\texttt{0b }\texttt{1010...})\)
16:\(T\gets 0\); \(T\gets P_{\in E_{1}}\ll(4\ll i)\)
17:\(T_{c\in E_{1}}\gets T\oplus(\texttt{0b }...\texttt{00000 }\texttt{1010...})\)
18:\(P_{\in E_{2}}\gets P_{\in E_{1}}\oplus(\texttt{0b }\texttt{0110...})\)
19:\(P_{\in E_{1}}\leftarrow\text{ConstAND}(T_{c\in E_{1}},P_{\in E_{2}})\)
20:endfor
21:\(T\gets 0\); \(T\gets G_{\in E_{2}}\ll(4\ll(l-1))\)
22:\(T_{\in E_{2}}\gets T\oplus(\texttt{0b }...\texttt{00000 }\texttt{1100...})\)
23:\(T_{\in E_{1}}\leftarrow\text{ConstAND}(P_{\in E_{1}},T_{c\in E_{2}})\)
24:\(G_{\in E_{3}}\gets T_{c\in E_{1}}\oplus G_{\in E_{2}}\)
25:\(c\gets 0\); \(c\leftarrow\text{MSCW}\) of \(G_{\in E_{3}}\) {MSCW : Most Significant Codeword}
26:\(c_{\in E_{2}}\gets c\oplus(\texttt{0b }...\texttt{1100 }\texttt{1010})\)
27:\(T\gets 0\); \(T\gets G_{\in E_{3}}\ll 4\)
28:\(T_{c\in E_{2}}\gets T\oplus(\texttt{0b }...\texttt{1010 }\texttt{1100})\)
29:\(z^{\prime}_{c\in E_{2}}\gets P^{\prime}_{c\in E_{1}}\oplus T_{c\in E_{2}}\)
30:return\((c_{\in E_{2}},z^{\prime}_{c\in E_{3}})\)
```

**Algorithm A4**BKSAdder\({}_{\text{Won}}\), Won's KS Adder Applied to Power-balancing Methods

```
1:\(X(=x_{n-1}||...||x_{0})\), \(Y(=y_{n-1}||...||y_{0})\) {\(x_{i},y_{i}\in\{0,1\}^{k}\)}
2:\(Z(=z_{n-1}||...||z_{0})\)
3:\(C\gets 0\)
4:for\(i=1\) to \(n\)do
5:\(x^{\prime}_{i}\leftarrow(x^{i(k-1)+k-1}||...||x^{i(k-1)+1}||0)\)
6:\(y^{\prime}_{i}\leftarrow(y^{i(k-1)+k-1}||...||y^{i(k-1)+1}||0)\)
7:endfor
8:\((C,z_{0})\leftarrow\text{KSAdder}_{\text{Coron}}(x_{0},y_{0})\)
9:for\(i=1\) to \(n\)do
10:\((C,z^{\prime}
```
1:\(X_{\in E_{1}}(=x_{n-1}||...||x_{0})\), \(Y_{\in E_{2}}(=y_{n-1}||...||y_{0})\)\(\{x_{i},y_{i}\in\{0,1\}^{k}\}\)
2:\(Z_{\in E_{3}}(=z_{n-1}||...||z_{0})\)
3:\(C\gets 0\)
4:for\(i=1\) to \(n\)do
5:\(x_{i}^{\prime}\leftarrow(x^{4i(k-1)+4(k-1)}||...||x^{4i(k-1)+4}||0\)b1010)
6:\(y_{i}^{\prime}\leftarrow(y^{4i(k-1)+4(k-1)}||...||y^{4i(k-1)+4}||0\)b1100)
7:endfor
8:\((C,z_{0})\leftarrow\textsc{BKSAdder}_{\textsc{Comon}}(x_{0},y_{0})\)
9:for\(i=1\) to \(n\)do
10:\((C,z_{i}^{\prime})\leftarrow\textsc{BKSAdder}_{\textsc{Comon}}(x_{i}^{\prime},y _{i}^{\prime},C)\)
11:\(z_{i}^{\prime}\gets z_{i}^{\prime}\gg 4\)
12:endfor
13:\((z_{n-1}||...||z_{0})\leftarrow\textsc{Adjustment}(z_{n-1}^{\prime}||...||z_{0}^ {\prime})\) {Bit reordering except \(0_{\in E_{3}}\)}
14:return\((z_{n-1}||...||z_{0})\)
```  
**Algorithm 6**Multi-bit Adder Combining Won's Kogge-Stone Adders Applied to Power-balancing Methods