## 3 Design
### Election  
Assume that there are some connected nodes already, and every node has its own pair of public and private keys. To prevent the 51% attack, the first block of the blockchain network is produced by the system maintainer, such as the control center, instead of the first connected node. Before the proceeding of any transaction, the election must be finished since the responsibilities of the tellers include both the packing of a new block and the spreading of transactions. In general, the election is implemented by a verifiable random number generation based on the polynomial interpolation. If there are \(m+1\) running nodes in the blockchain network, and each node contributes one data point \(P_{i}:(x_{i},y_{i})\) of the polynomial interpolation of \(m\) degree such that no two data points are the same, one equation of the polynomial can be deduced from the data points provided by the running nodes. All \(m+1\) coefficients can be used to build one random number by performing the xor operations. For example, there are four running nodes in the blockchain network, and the provided data points are \(P_{0}(-1.5,-1.2),P_{1}(-0.2,0),P_{2}(1,0.5),P_{3}(5,1)\), so the deduced equation of the polynomial would be  
\[f(x)=2.2535\times 10^{-2}\times x^{3}-1.8679\times 10^{-1}\times x^{2}+5.4717 \times 10^{-1}\times x+1.1709\times 10^{-1} \tag{3}\]  
and the coefficients, such as \(2.2535\times 10^{-2}\) and \(1.1709\times 10^{-1}\), are the factors used to build the random number. The steps for the general election can be described as follows:  
1. All the nodes randomly pick one data point \(P_{i}:(x_{i},y_{i})\) and broadcast the data point with a timestamp. If two or more nodes pick a conflicting data point such that they share the same \(x\) value or they share the same \(x\) and \(y\) values, the node whose timestamp is later will be asked to pick another data point until there is no conflict. 2. Build the polynomial of the form \(f(x)=a_{0}+a_{1}x+...+a_{n}x^{n}\) based on all received data points and generate the random number result \(r\). 3. Choose first \(k\) nodes whose data point has the value of \(|x-y|\) is closest to the generated random number \(r\). 4. These \(k\) nodes form the group of dealers and dealers take turns to pack the new block. The dealer that has already packed the new block loses the identity and the permission of the dealer until the dealer group is empty; at that time, a new round of election will be initiated. In step 2, the random number is computed by bitwise xor operation on all coefficients of the interpolated polynomial. Since most of the coefficients are not integers and some of the rare very big or very small, we concatenate all the coefficients together into a long string \(\mathcal{C}\) according to the degree order, and then split the concatenated string \(\mathcal{C}\) into an array \(A(n)\) of \(n\) number based on the globally consistent value range of data points from all nodes in order to make the final random number close to data points from all nodes. For example, if the range of all nodes' data points are within \((0,100)\), then \(\mathcal{C}\) will be cut as one integer every two digits so that all elements of array \(A(n)\) stand in the same plane with all data points, and the result of bitwise xor stands in it. Each data point has two values \(x_{i}\) and \(y_{i}\), but the calculation of bitwise xor can only yield one single value instead of one pair. To solve this problem, the separated array \(A(n)\) needs some changes, for example, reducing by 1 for all numbers in array \(A(n)\). Thus, we obtain two random numbers to form a random point as the reference to choose \(k\) closest data points, and their senders form the dealer group to pack the new block. The algorithm to generate the random point is presented in Algorithm 1.