# RingFFL: A Ring-Architecture-Based Fair Federated Learning Framework
## 4. Penalty Mechanism in RingFFL
#### 3.2.5 _Roof deposits_
\(P_{1}\) first provides evidence \(E_{1}=Expand(1,\bot;M_{1})\) according to Equation (4) to acknowledge \(Ack_{2,1}\) from \(P_{2}\). When \(P_{1}\) provides the acknowledgment message \(\left(acknowledge,T_{id},T^{{}^{\prime}}_{id},P_{2},\)\(P_{1},C_{1},t_{1},b,E_{1}\right)\), miners will verify whether the transaction \(\left(deposit,T_{id},T^{{}^{\prime}}_{id},P_{2},P_{1},C_{1},t_{1},b\right)\) exists and that \(C_{1}(E_{1};H_{1})=1\) is true according to Equation (5). If the verification passes, the message \(\left(acknowledge,T_{id},T^{\prime}_{id},B_{2},P_{1},C_{1},t_{1},b,E_{1}\right)\) is made public to the network, and the transaction \(\left(deposit,T_{id},T^{\prime}_{id},P_{2},P_{1},C_{1},t_{1},b\right)\) is recorded on the blockchain later. The \(coins(b)\) in \(\left(acknowledge,T_{id},T^{\prime}_{id},P_{2},P_{1},C_{1},t_{1},coins(b)\right)\) is sent to \(P_{1}\)'s wallet. Afterwards, \(P_{2}\) acknowledges \(Ack_{3,2}\) from \(P_{3}\), similarly. It continues in turn until \(P_{N-1}\) acknowledges \(Ack_{N,N-1}\) from \(P_{N}\) using evidence \(E_{N-1}\) according to Equations (4) and (5). At last, \(P_{N}\) uses \(E_{N}\) to acknowledge \(Ack_{i,N}\) (Equation (2)) from all \(P_{i}(i=1,2,\cdots,N-1)\). Abnormal situation. For \(i=1,2,\cdots,N-1\), if \(P_{i}\) does not acknowledge \(Ack_{i+1,i}\) according to Equation (3), then \(P_{i+1}\) will end the RingFFL and wait for reimbursement from \([PERSON]_{i+1,i}\). Furthermore, when \(i+1\
eq N\), \(P_{i+1}\) waits for reimbursements from \([PERSON]_{i+1,N}\) according to Equation (2). **Step 4**: _Output_  
Like roof deposits, we introduce the output phase in two cases: normal and abnormal situations. Normal situation. In the output phase, if \(P_{N}\) acknowledges \(Ack_{i,N}\) according to Equation (2)), then \(E_{N}\) (Equation (4)) is made public, which is the evidence that meets \(C_{N}\)(Equation (5)). Each \(P_{i}(i=1,\cdots,N)\) outputs \(M_{1}\|\cdots\|M_{N}\), uses the FedAvg algorithm [43] for model aggregation to obtain the current round of global model \(M_{Round}^{glob}=\frac{1}{N}\sum_{N}M_{i}\), and continues to the next round of training. In the RingFFL, for \(i=1,\cdots,N-1\), \(Ack_{i,N}\) (Equation (2)) locks \(coins(b)\) of \(P_{i}\). If \(P_{i-1}\) successfully executes \(Ack_{i,i-1}\)'s acknowledgment (Equation (3)), then \(P_{i}\) will give \(P_{i-1}\)\(coins((i-1)b)\) and the condition \(C_{i-1}\) (Equation (5)) provided by \(P_{i-1}\) will be made public. According to the model parameters \(M_{i}\) of \(P_{i}\) and \(C_{i-1}\), \(P_{i}\) can successfully execute \(Ack_{i+1,i}\)'s acknowledgment (Equation (3)) and obtain \(coins(ib)\) from \(P_{i+1}\). That is, if all clients execute the RingFFL honestly, the number of each client's digital currencies neither increase nor decrease. Abnormal situation. If \(P_{N}\) does not acknowledge any \(Ack_{i,N}\) (Equation (2)), then each client outputs \(\bot\). For \(i=1,\cdots,N\), suppose \(P_{i}(j\in[i-1])\) are honest clients. If \(P_{i}\) terminates the RingFFL after obtaining \(M_{1}\|M_{2}\|\cdots\|M_{i-1}\), then \(P_{i-1}\) can successfully acknowledge \(coins((i-1)b)\) from \(P_{i}\)'s ladder deposits, and \(P_{k}\)'s \(coins((k-1)b)\) in the ladder deposits will be reimbursed, in which \(k=i+1,i+2,\cdots,N\). Since \(P_{N}\) cannot provide \(C_{N}\) (Equation (5)), each client's roof deposits will be reimbursed. As a result, the total number of \(P_{k}\)'s digital currencies is unchanged, in which \(k=i+1,i+2,\cdots,N\). The number of each \(P_{i}\)'s digital currencies increases by \(b\), and the number of \(P_{i}\)'s digital currencies decreases by \((i-1)b\). Thus, the RingFFL guarantees the fairness of FL. The overall process of RingFFL is illustrated in Algorithm 1. To better understand the whole process, we take 5 clients as an example to demonstrate the penalty mechanism in RingFFL, which is shown in Figure 3.  
```
1:\(\{T_{1},T_{2},\cdots,T_{N}\}\), \(M^{int}\), \(MAX\). 2: Federated Learning Model \(M\).