Design of a Secure Energy Trading Model Based on a Blockchain

: This study proposes a Secure Energy Trading Model design based on a Blockchain is an attempt to overcome the weak security and instability of the current energy trading system. The focal point of the design lies in the user-security features of the model, such as user authentication and iden-tification, and the blockchain that every transaction goes through. The user-security feature provides a safer system for peer-to-peer energy trade, and the blockchain technology ensures the reliability of the trading system. Furthermore, the Secure Energy Trading Model supports a decentralized data control mechanism as a future measure for handling vast amounts of data created by IoT.


Introduction
Along with consumption, consumers have begun to take part in the overall process of the development and distribution in various industries. Simultaneously, the frontiers between suppliers and consumers are becoming more blurred [1]. Prosumer, a portmanteau of the words producer and consumer, was introduced as a futuristic concept by Alvin Toffler in 1980, and it is no longer a distant concept. In recent years, the traditional energy market system has shifted as increasing numbers of households have installed devices [1,2], such as solar panels, to generate their own electricity from renewable sources [3]. Meanwhile, a peer-to-peer energy trading system is gaining more recognition as an alternative version to the conventional energy market for consumers and producers [4,5]. The system requires a secure transaction agent for the varied types of producers and consumers. The blockchain-based Secure Energy Trade Model (SETM) proposed in this paper includes a producer/consumer module and a blockchain module that satisfies this need. The SETM consists of a transaction agent, which is a multi-interaction management agent (MiM agent), and a blockchain that contains cost information and a request/reply message. This model is connected to the consumer and the producer through an energy network. Over the course of this paper, we lay out the design of the blockchain-based secure energy trade model (SETM). In Section 2, we go through the issue statement, which is proceeded by the definition of the proposed SETM in Section 3. Then, the implementation of the SETM and a discussion with regards to the model is given in Sections 4 and 5, respectively. The paper is concluded in Section 6.

Prosumer
Prosumer is a portmanteau of the words producer and consumer. In this case, an energy prosumer is a consumer that also generates their own energy [1]. Depending on the supply level, a prosumer can alternate between a consumer and a producer depending on a person's energy consumption and production. Various countries have different platforms that support energy trading activities between prosumers. The UK's web-based electricity trading platform "Piclo" connects electricity producers and consumers every 30 min to trade energy [2]. The Netherlands operates "Vandebron", a web-based platform structured to accommodate interpersonal transactions. Germany operates an online platform that connects owners of solar power facilities who wish to sell their surplus energy to their neighbours [4].

Blockchain
A blockchain is a shared and distributed digital database structured by blocks chained in chronological order. Each block contains transaction data. Simply put, the structure is a ledger that includes digital transaction and data records [6]. It is a peer-to-peer distributed digital record of validated transactions. The technology is applied to establish reliability, accountability and transparency of transaction processes. It has the advantage of reducing the transaction processing cost and complexity [5]. In addition, it operates on a system based on the consensus of network users instead of a central authority that manages the system.

Problem Definition
Currently, energy is traded on an unreliable e-trade system that lacks security and stability. Despite its registration process, the system is prone to forgery and price tampering by its participants [7]. Without a user-security step, the blockchain can be accessed and opened for anyone to join a transaction. This means that the trade system is vulnerable to participants exploiting the system by trying to modify/block/interrupt transactions. In addition, the system's centralized data handling process is inadequate to keep up with the vast amount of data created by the ever increasing IoT [8]. A secure energy trading platform that can also process big data must be devised [9]. In response to the issue, an energy trading model with the integration of blockchain technology is proposed as a secure and stable platform that conforms to modern standards in the field. In [10], the authors suggest a blockchain-based secure service mechanism for IoT with a blockchain. The service code is protected by unreliable servers that are implicated in the seamless on-board computer network and with a blockchain [11]. The efficiency of the system for resource constrained devices is evaluated by the results of the simulation. However, neither a service charging mechanism nor a security mechanism for secure communication is considered. In [10], in the commercial warranty system, systems that do not fix security issues are vulnerable to data hijacking. A transparent computing network for a deportation system with a centralized and distributed architecture would be used for cost-effective communication. The servers are distributed in order to provide a necessary service and to arrive at the location. However, efficient deployment of servers that can enable IoT caching techniques is not considered. The authors introduced a blockchain based on Vehicular Network, which allows for the development of a distributed network in large vehicles [12]. However, a trust management system is required to ensure dependable communication. Generally, in V2V, each ID is used for communication purposes. However, it is vulnerable to privacy leakage problems.

Secure Energy Trading Model (SETM)
In this section, Figure 1 shows the SETM which explains the model configuration, including consumers, producers, request time, price of the transaction and the definition of an authentication and identification method of user security.

SETM Structure
In Figure 1, SETM consists of a consumer, a producer, a blockchain module, a multiinteraction management agent (MiM agent) and a blockchain for reliable multilateral transactions. The producer and the consumer in the model are a representation of a user interconnected in multiple forms. A prosumer may alternate between these two roles depending on the need. Users are granted roles only after authentication through a trusted server, such as uA and uI. Users are linked to each other in a grid, and they share the energy they need or the energy they want to trade. Using the shared information, users request to buy the amount they need, and the seller receives these purchase requests. The energy transaction between these users with different roles is stored in a blockchain. SETM consists of a consumer, a producer, a blockchain module and a multi-interaction 74 management agent(MiM agent) which is a model transaction agent and a blockchain for reliable 75 multilateral transactions. [ Fig. 1]. There is one producer and one consumer in that model that can 76 be the same person, or they can also work as a producer or as a consumer. However, as shown in 77 the figure 1, the producer and consumer are interconnected in multiple forms. Users are users that 78 have been authenticated through a trusted server, like uA and uI. The figure 1 depicts the structure of 79 blockchain energy transactions. Users are linked to each other in a grid, and they share the energy 80 they need or the energy they want to trade. Using the shared information, the user who wants to buy 81 asks for the purchase amount, and the seller receives the purchase request, and each is set up as a 82 blockchain.

Energy Market Mechanism
The SETM is connected to a blockchain energy network (BEN). The customer and/or the producer such as smart factories, energy companies, home solar systems, wearable devices, smart IoT devices, smart vehicles and personal offices are also connected to the BEN together ( Figure 2). There is also a multi-interaction manager agent (MiM agent), which consists of the Web, customer service, a blockchain I/F and operation system. The MiM agent functions as a manager of the energy trade in the SETM. Each customer and each producer consist of a controller, device I/F, user I/F, blockchain module and operation system. In Figure 2, the energy company only produces energy. The home solar system can be either a consumer or a producer. A personal office, a smart factory, wearable devices, smart IoT devices and smart vehicles are customers. Generally all participants contact an MiM agent to monitor the current information. If one of the customers wish to buy energy, the customer contacts the MiM agent by sending 'request message'. If a producer wants to sell energy, the producer sends 'share message'. The 'share message' contains [available energy and cost]. Consumers have the option of choosing from these offers.

Messages Flow in SETM
All messages are sent through the energy network ( Figure 3). The flow begins with participants, who have to go through the user.security step, user.Authentication uA and uI.
As part of the model, user's security is a formal registration procedure a user must authenticate in order to participate in a transaction. The blockchain guarantees the safety/reliability of transactions, and the dependability of the decentralized database of each user is relatively weak. Each user is given a unique key that is stored on the server, and a mutual key is bestowed to users in a transaction (Figure 4). The mutual key verifies the reliability of the other party. Those that wish to sell on the SETM must enter their amount of energy and cost by sending a SHARE message to the model. Figure 3, depicts energy generators such as the solar system and the home solar system sending a SHARE message. Depending on supply levels, at times, the home solar system can sell surplus energy and vice versa. To buy the energy, buyers send a (request message) to acquire [available cost, amount available] from the SETM. With the (reply message) from the SETM, the buyer receives information, and the trade proceeds in the SETM. Figure 5 shows the process by which each transaction is linked to the blockchain. Each block contains information on the transaction. Information on the transaction includes information on energy shared by each vendor, information on buyers' purchases and information on each cost. The transaction information (TI: 1, ..., n) is defined as shown in Figure 5.

Case Study
For this case study, we use data from a local energy market with seven stakeholders ranging from consumers (both domestic and industrial), industrialists and producers. Each party has a usage and generation profile. In Table 1, we can see each member's min bid and max bid for energy.  Figure 6 represents the sequence diagram for the SETM. In the figure, there are five personal consumers, one industrial consumer and one generation. The first transaction is initialized with the generation's SEND Energy(x kW) to personal customer 1. The SEND Energy(x kW) message contains g, ep, message(1 kW). As soon as the message is sent, the (Genesisblock Hash()) is created and treated as the first hashblock. Upon Personal Customer 1's receipt, the process is ready for the next procedure, Initial.Tran(). Then, message.Energy(xx kW) is sent as a forgeryblockhash. Initial.Tran() now contains g1 and c1 data. Meanwhile, Customer 2 wants to partake in the transaction by processing the User Security Process. Generation 1 sends the same message Energy (xx kW) to Customer 2. Now, Personal Customer 2 can join the transaction by computing blockhash Figure 7. Industrial Customer 1 takes the same steps and the transaction is set at Tran(g1, c1, c2, ic1. In this model, we define energy.Producer(eP), energy.Consumer(eC), energy.Request Time(eRT), energy.Price(ePr), Agreement Time(AT), user.Authentication(uA), and user.Identification(uI) Algorithm 1 and in Algorithm 2. The TI 1 is considered the first blockchain of this block, followed by TI 2 as the next blockchain. put simply, TI n is the nth block chain value. Price (Pr) is expressed in equations when there are two producers (g1, g2). Consumers are provided with the option to select from the variety of supply created by producers nearby. The resulting outcome of this variety leaves consumers to acquire energy at a competition reduced rate.  for Everytimeinablock do 3: ask(U) ← user.Identi f ication(uI) 4: request(CONFIRM(U)) ← user.Authentication(uA) 5: con f irm(U) for askU and for the blockchain member 6: if ( then∆h_user = (uI · uA)) 7:

SETM Sequence Diagram
Message(Thisiswronguser. con f irm(U) for askU and for the blockchain member 13: end procedure

Model Compare
Unlike previous models, blockchain technology is integrated into the suggested SETM to ensure more secure energy transactions and privacy protection. The privacy of the payment system in the traditional model relies on the trust confirmation of a third party. Problems may occur in the traditional privacy model by attempts made to break the flow of information in some places. [ Figure 8]. In comparison, the blockchain of the blockchainbased privacy model [ Figure 9] involves the transaction information and all participants' information to do the payment.  The security of transactions is impossible compromise. Data Unforgeability is the decentralized nature of the consortium blockchain, which combined with digitally signed transactions, ensures that no adversary is able to pass as each node to corrupt the network. The digital signature of a node cannot be forged, nor can an adversary gain control over the majority of the network resources. The energy coin relies on digital signatures to prove ownership and public history of transactions to prevent double-spending. The transaction histories are going to be shared in the P2P network and will be conform to the proofof-work methods. Digital Wallet Security, without corresponding keys and certificates, no adversary can open a prosumers (consumer and producer)' wallet and steal energy coins from the wallet. As each node has a unique wallet corresponding to its energy coin account. We use multiple wallet addresses as pseudonyms of this wallet for privacy protection.
Last, with the removal of the trusted intermediary, in our energy blockchain, each node trades energy in a P2P manner, which is unlike traditional centralized trading relying on a globally trusted intermediary. All nodes have the equal right to trade energy with the help of authorized prosumers. The energy blockchain is robust and scalable without the involvement of a globally trusted intermediary. Table 2 shows the comparison with existing research for security analysis. The security problem in [13] is that Unknown people can infer a user's electricity usage habits based on the data. The suggested model integrates the private blockchain and smart meters as a main technology and uses the market auction mechanism. In [14], they used a blockchain, smart meters and smart contract with a market auction mechanism; however, if the cost of each auction can be retrieved in the blockchain, the subsequent auction may be affected. There are lots of main technologies in [15] such as a blockchain, multiple signatures, and anonymous encrypted information flow. However, the multiple signatures would be an unnecessary process because the hash process in the blockchain can replace the signature. In [16], they include private information in all transactions, which can potentially pose a security problem. our suggested SETM uses a blockchain and IoT, and as the pricing mechanism, we defined negotiable energy prices and a multi-agent usage. In the security analysis, because the SETM has the user.security step, such as user.authenticationn and user.identification, the SETM contains stronger privacy policy than existing studies Algorithm 2. Table 2. Security analysis.

Ref.
Main Technologies Pricing Mechanism Security Analysis [13] private blockchain, smart meters market auction mechanism Unknown people can infer a user electricity usage habits based on the data. [14] blockchain, smart meters, smart contract market auction mechanism In case, the cost of each auction can be retrieved in the blockchain, the subsequent auction may be affected. [15] blockchain, multiple signatures, anonymous encrypted information flow negotiate energy prices anonymously Achieved many security and privacy requirements. while t=0 ∞(eP i · Pr i )(eP j · Pr j ) do 31: We defined the security problems of the existing model in the Section 2.3 problem definition. We define how the SETM overcomes the security problems in Table 3, which is a security strength of SETM. In Table 3, there are four security problem definitions and security of strength was also analysed for each security problem. Vulnerable to forgery and price tampering A blockchain in SETM prevents the forgery and the tampering in the transactions.
Vulnerable to participants exploiting the system by trying to modify/block/interrupt the transactions If someone who has joined the trade system, modified the transaction, then the rules of the blockchain are broken. If the rules are broken, the trade system will be blocked.
Centralization of the data handling process is inadequate to keep track of the vast amount of data.
Basically, a blockchain is a peer-to-peer distributed digital record of validated transactions, not the centralized data handling.

Conclusions
In this paper, we have thoroughly reviewed the structure, the system and, specifically, the safeguards of the SETM. The security features integrated in the model make it more reliable than the conventional market and any other models suggested from existing studies. The structure of the SETM consists of a multi-interaction management agent (MiM agent) and a blockchain which contains the cost data, request and reply messages. The model is connected to the consumer party and the producer party through an energy network. The system begins with the producer registering the available energy amount for sale along with the price to the model. Consumers can choose and buy from these sellers. However, the model needs further adjustments. Despite the security and stability of the model, the applications of this model are yet unfit for bi-directional trades. Interested stakeholders' role in the model is confined to either as a consumer or a producer, and cannot be both, specifically a prosumer, for energy trade.
Author Contributions: H.K. leads this paper by suggesting the idea and has performed the implementation and I.P. managed the whole paper work. Both the authors have read and agreed to the published version of the manuscript.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript:

SETM Secure Energy Trade Model IoT
Internet of Things 5G 5 Generation