# Proxy Signature-Based Management Model of Sharing Energy Storage in Blockchain Environment
## 5 Case Study
### Consensus Process  
The consensus mechanism is the core part in blockchains, achieving the validation and confirmation of the ledgers on blockchains and reaching the uniformity of the distributed database. At present, practical Byzantine fault tolerance (PBFT) is a common consensus mechanism in consortium blockchains that are the first choice in the energy sector including SES [15]. A typical consensus process of PBFT is shown in Figure 7[34]. It can be seen that the consensus process includes five phases: request, pre-prepare, prepare, commit and reply. A message from the client (i.e., \"C\" in the Figure 7) will be validated and accepted by other nodes (i.e., \"0\", \"1\", \"2\" and \"3\" in the Figure 7, though \"3\" is faulty at this time) through the consensus process. More detail about PBFT, such as the analysis of process, performance evaluation and implement techniques, can be found in [34]. The prepare phase of PBFT is selected in this case. In the phase, a prepare message with the digital signature of the node is multicast to all other nodes when the node accepts the pre-prepare message in order for all nodes to verify the correctness of the message with each other. Therefore, on an SES blockchain, a prepare phase based on the traditional scheme and a prepare phase based on the principal-agent model with the proxy signature mechanism are, respectively, shown in Figures 8 and 9. It is assumed that there are five nodes deployed on the blockchain, including a primary node and four follower nodes. The primary node is selected according to the node number, the node state and the validation result. Figure 8: The prepare phase based on the traditional scheme. Figure 7: The typical consensus process of practical Byzantine fault tolerance (PBFT). It can be seen from Figure 8 that the other nodes, except for the primary node, multicast a prepare message to all nodes on the blockchain. The prepare message consists of two parts: the prepare message body and its digital signature produced by the private key of the node. The prepare message body consists of a label of \"PREPARE\", the view number and sequence number of this consensus process, the digest of the original message from the client forwarded by the primary node in the pre-prepare phase and the node number. Then, the prepare message body is signed by the node, and the digital signature for the prepare message body is obtained. The digital signature mechanism based on the ElGamal algorithm is applied in the consensus process. Once the signature is verified to be correct and the view number and sequence number are right, the node that receives the prepare message will accept the message. At last, when the node accepts enough messages from other nodes (twice the number of tolerable faulty nodes of the blockchain), the node will start the commit phase and multicast a commit message to other nodes. It is worth mentioning that the nodes on the blockchain may be in different phases of the consensus process at a certain time, and therefore the figures show the message exchange at the same prepare phase. As shown in Figure 9, node 5 accepts the delegations from node 3 and node 4 at the same time. Therefore, node 5 is the proxy node, and node 3 and node 4 are the delegation node. For a blockchain supporting the proxy signature mechanism, although the primary node sends a pre-prepare message to the delegation nodes, the proxy node will multicast the prepare message on behalf of the delegation nodes when it receives the pre-prepare message even if the delegation nodes may be faulty or off-line. The sent messages from the proxy node and the corresponding delegation nodes are consistent. It can be seen from Figure 9 that node 5 multicasts three prepare messages to other nodes, including a message of node 5 itself and two messages signed by using the proxy keys. The nodes that receive the three messages, node 1 and node 2, also accept these messages if the ordinary digital signature and the proxy signatures are verified.