Blockchain and Double Auction-Based Trustful EVs Energy Trading Scheme for Optimum Pricing

: Electric vehicles (EVs) have gained prominence in smart transportation due to their unpar-alleled beneﬁts of reduced carbon footprints, improved performance, and intelligent energy trading mechanisms. These potential beneﬁts have increased EV adoption at massive scales, but energy management in EVs is a critical study problem. The problem is further intensiﬁed due to the scarcity of charging stations (CSs) in near EV proximity. Moreover, as energy transactions occur over open channels, it presents critical security, privacy, and trust issues among decentralized channels. To address the open limitations of trusted energy management and optimize the pricing control among EV entities (i.e., prosumers and consumers), the paper proposes a scheme that integrates blockchain and a truthful double auction strategy for trustful EV trading. To address the transaction scalability, we integrate an Interplanetary File System (IPFS) with a double auction mechanism handled through the Remix Smart Contract environment. The double auction leverages an optimal payoff condition between peer EVs. To address the communication latency, we present the scheme at the backdrop of Fifth Generation (5G) networks that minimizes the optimal payoff response time. The scheme is simulated against parameters such as convergence, proﬁt for consumers, computation time, and blockchain analysis regarding node commit latency, collusion attacks, and EV energy consumption. The results indicate the scheme’s viability against traditional (non-blockchain) approaches with high reliability, scalability, and improved cost-efﬁciency.


Introduction
The enormous growth of intelligent transportation systems (ITS) is adversely affecting the green environment of smart cities due to the persistent depletion of non-renewable resources such as fossil fuels, coal, and natural gas. Over the last few years, industries and government institutions have tried to control the emission of harmful greenhouse gases in the urban areas [1,2]. As a result, automotive industries have transitioned from petrol or fossil fuel vehicles to electric vehicles (EVs) so that drivers can also be satisfied with ITS for affordable traveling [3]. EVs utilize renewable resources such as solar energy, nuclear power plant, wind power plant, etc., proving to be a plausible solution for a green and safe environment [4]. Many authors have considered electric mobility in their research work to highlight the benefits of its usage by understanding the basic architecture, charging technologies, and consumer behavior towards the EV market [5]. For example, Secinaro et al. [6] performed the bibliometric analysis to identify the relevant business models for the EVs considering the discussion on various charging technologies, components, and resource optimization to enable a sustainable environment for EV deployment. However, despite the low cost, modest energy consumption, and low greenhouse gas emissions, the management of EV's energy demand seems to be a gruesome task to tackle due to the limited deployment of charging infrastructure. Therefore, it entails an energy trading system in which EVs can act as a prosumer or consumer to deal with the high charging prices, fluctuating energy requirements, and distant locations of charging stations (CSs) [7][8][9].
To address the aforementioned issues, many researchers across the globe have incorporated the energy trading mechanism to fulfill the energy requirement of EVs. For example, the authors in [10] discussed the energy trading between EVs and mobile CSs by formulating an incentive mechanism to provide a fair and trusted environment for EVs involved in energy trading [11]. However, the inclusion of mobile CS can be a disadvantage for massive EVs arriving for charging. Bhattacharya et al. [12] proposed a blockchain-based energy trading scheme, named EVBlocks, in Vehicle-to-Anything (V2X) scenarios. A noncooperative game model is proposed for optimization of cost payoff, and a proof-of-greed (PoG) consensus mechanism is proposed to handle fluctuations in charging and discharging EVs. However, the authors did not discuss the scenario of charging scarcity in the trading environment. Thus, to mitigate the scarcity of charging infrastructure, Xiaoguang et al. [13] developed an energy trading system to enable the optimal scheduling between EVs and temperature-controlled loads while providing a green environment. Later, Chung et al. [14] proposed an optimal EV energy trading and demand response scheme utilizing the cloud server to optimize the profit for users. However, most of the energy trading schemes discussed depend on the centralized authority to store data at a cloud server arising the security and trust issues in the system. Therefore, many researchers have adopted a trustful and decentralized blockchainbased framework to secure the data transactions involved in energy trading due to its dynamic applications in various domains such as healthcare, agri-food, energy, accounting management, and supply chain management [15][16][17]. For example, supply chain and its complex operations can be tackled with the secure and decentralized blockchain technology by executing the self-executable smart contracts [18]. Additionally, blockchain is utilized to reduce the cost associated with the supply chain management for a sustainable business models for energy management [19]. Moreover, blockchain technology seems to yield better results for the energy sectors in terms of secure, transparent, and tamper-proof transactions by discussing the consensus mechanisms and components of the blockchain to improve the performance and efficiency of energy market [20,21]. Hasselgren et al. [22] discussed about how usage of blockchain can improve the security and services in the health care sector. Moreover, blockchain technology can be applied for agri-food supply chain management to ensure the secure and optimal incentive mechanism for the participants involved in the market [23].
To highlight the advantages of blockchain technology in energy trading, Kakkar et al. [24] discussed a blockchain and multiple linear regression-based energy trading scheme to deal with security and privacy issues of data storage of EVs. However, they did not consider the various security attacks such as Denial-of-Service (DoS), data manipulation, and cyber against the data storage of users. Baza et al. [25] investigated a privacy-preserved energy trading scheme by leveraging the blockchain technology with the introduced anonymous payment system to tackle the privacy issues arising in the system. Later, the authors of [26] discussed a lightweight authenticated dynamic EV contactless charging integrated with the blockchain-based energy trading system. They have focused on providing a secure and transparent environment to the EVs for contactless charging. Then, Tanwar et al. [27] designed a blockchain-based EV charging reservation scheme for optimum pricing. They have adopted a double auction mechanism to provide maximal payoff between users in the system. The solutions provided by the researchers mainly deal with the security and privacy issues in the blockchain-based energy trading scheme [28]. Still, they did not discuss the optimal payoff, profit, computation time, and data storage cost for the EVs participating in the energy trading. The authors in [27] focused on optimizing the profit for EVs utilizing the double auction mechanism but ignoring the truthfulness and individual rationality of the bidders. Therefore, to overcome the aforementioned challenges, we have proposed a blockchain and IPFS-based energy trading scheme based on a truthful double auction mechanism to obtain the optimal payoff between EVs, i.e., prosumers and consumers [29]. The applied double auction mechanism optimizes the gain between EVs, encouraging them to bid in energy trading. The truthful and individual rationality characteristics of the formulated double auction mechanism enable the bidders to bid their true strategy. The data storage cost issues are being tackled with the help of the employed IPFS peer-to-peer (P2P) protocol which acquires low cost when integrated with the blockchain in energy trading. Similarly, EVs energy trading data can be stored and retrieved efficiently with low computation time in the blockchain-enabled IPFS framework [30]. Moreover, the data transactions are performed reliably over a 5G wireless network to guarantee a highly scalable energy trading between EVs.
Based on the above discussion, the motivation of this research work can be defined as follows: • Most conventional energy trading schemes have focused on the security aspect of the EVs while neglecting the optimal payoff between them; • As per the literature, researchers have addressed the security and privacy issues of EVs energy trading schemes. As a result, authors in [12,[24][25][26] investigated the blockchainbased energy trading scheme to strengthen the security and transparency of the EVs communication. However, they have ignored the price optimality aspect of EVs along with other factors such as profit for consumers, computation time, and data storage computation. Moreover, authors of [27] have adopted a double auction mechanism for optimality, but they did not consider the truthfulness and individual rationality of the EVs; • Therefore, a blockchain and IPFS-enabled energy trading scheme is a plausible solution to overcome the price optimality and trust issues of the EVs based on the trustful double auction mechanism. Furthermore, the IPFS and 5G wireless technology ensures the highly reliable, scalable, and efficient data communication between EVs in energy trading.
Following are the research contributions of this research work: • We propose a blockchain-based secure and truthful energy trading scheme for optimal payoff between EVs, i.e., prosumers and consumers; • We employ a P2P IPFS protocol with the blockchain to provide a low cost data storage for EV energy trading; • We formulate a truthful double auction mechanism to enable the optimized payoff for EVs in energy trading due to its truthfulness and individual rationality; • Finally, the simulation of the proposed energy trading scheme has been presented in terms of various aspects such as convergence, profit for consumers, computation time, and data storage cost computation.
The rest of the paper is organized as follows: Section 3 discusses the related work. Section 4 presents the system model and problem formulation. Section 5 describes the proposed scheme, which presents the truthful double auction mechanism. Section 6 shows the performance evaluation of the proposed scheme and, finally, the research work is concluded in Section 7.

Materials and Methods
In this section, we have discussed about the insights of blockchain-based secure and decentralized energy trading scheme for EVs. Foremost, we have explored the relevant blockchain-based EVs energy trading schemes to identify the research gaps that is being handled by the proposed trustful blockchain-based EV energy trading scheme. To identify the research gaps, authors have references from several research works from high quality research databases such as ACM digital library, Science Direct, IEEEXplore, Springer Nature, Elsevier, Wiley Online, Google Scholar, Scopus, and technical blogs. The proposed scheme can be traversed with the help of keywords, i.e., Blockchain, electric vehicles, IPFS, truthful double auction, etc. Furthermore, Figure 1 shows the prisma diagram of the proposed scheme in which research gaps have been identified by exploring the relevant research works to highlight the advantages of the proposed scheme.

Final inclusion
References included in the manuscript

Related Works
As per literature, many researchers have been reported to utilize centralized authority for optimal EV energy trading schemes. However, a centralized system can easily exploit the security of data transactions involved in energy trading. Therefore, a blockchain incorporated with the EV energy trading mechanism proves to be an effective solution to secure and preserve the data transactions involved in EV energy trading schemes. As a result, Neagu et al. [31] adopted a new vision for prosumers' optimal energy trading with the execution of smart P2P contracts. They have deployed the proposed scheme in a real microgrid network to improve the scheme's feasibility.
Later, Ashfaq et al. [32] considered a consortium blockchain network to strengthen the security and privacy in EV energy trading. The authors considered the k-Nearest Neighbor algorithm that reduces the consumption of resources and computation power for efficient EV energy trading. Furthermore, to improve the storage cost and high latency issues of [32], the authors of [33] designed a P2P smart contract-based energy trading scheme, i.e., ET-Deal, to manage the energy load of EVs. However, the ET-Deal scheme proposed by the researchers has not considered the computation time required to add data transactions to the blockchain, which can reduce the system's scalability. To enhance the scalability of the system, Chen et al. [34] adopted a blockchain framework to ensure a highly scalable energy trading scheme integrated with the distributed optimization algorithm to eliminate the dishonest participants from the network. Later, Chung et al. [14] proposed the demand response and energy trading combinatorial framework to reduce the charging cost for EVs participating in the system for their profit. The research work conducted in [14] surpasses the energy trading scheme of [34] in terms of profit and charging cost. Then, the authors of [35] extended their research work to investigate a blockchain-based energy trading framework using Proof of Solution that handles the optimization problem, which is not being considered in [14].
To the best of our knowledge, as per the literature, most authors/researchers have integrated blockchain networks in their research work to secure energy trading for EVs. However, they did not discuss the various parameters, i.e., optimal payoff, profit for consumers, computation time, and data storage computation, which can deteriorate the efficiency and performance of the EV energy trading. Thus, we have proposed a blockchain and double auction-based trustful EV energy trading scheme for optimum pricing. The proposed system ensures the optimal payoff and trusting environment to perform the energy trading for EVs. Table 1 shows the comparative analysis of various state-of-the-art energy trading schemes with the proposed scheme to highlight the benefits of optimal and trustful energy trading for EVs.

System Model and Problem Formulation
This section describes the system model and problem formulation of the blockchainbased secure energy trading scheme with the optimum price. Figure 2 depicts the blockchain-based secure energy trading scheme between EVs grouped into prosumers (E α ) and consumers (E β ) with the additionally introduced entities such as an IPFS and 5G-enabled network. The incorporated blockchain network secures the data transaction of prosumers and consumers participating in the energy trading by storing their data in a decentralized and immutable manner. The advantages of secure blockchain network also increase the sustainability of EVs in the smart city. Therefore, adoption of blockchain technology in the proposed energy trading scheme seems to be en efficient solution for prosumers and consumers [37]. The number of EVs, i.e., prosumers can choose to generate energy (ξ α ) from renewable energy sources at their home only. They can utilize the solar panel to convert energy into electricity transferred to the EVs through the charger. Thus, we have considered that some prosumers already contain the energy generated from renewable sources such as solar panels and small wind systems that can be deployed at home. Prosumers can communicate with the consumers to sell their additional energy with the authenticated EVs by registering them with the e-KYC. Registering authority θ Ra has been introduced to manage the authentication of the EVs. Moreover, consumers can also opt to purchase energy from the smart grid based on the fluctuating price and distance from the prosumers. A truthful double auction mechanism is employed to decide the strategy for optimal energy trading between prosumers and consumers in the blockchain network. Consumers validated after registering with e-KYC can participate in the truthful double auction bid with the prosumers, which are being authenticated with the execution of the smart contract to add information about the energy trading in the blockchain securely. The wireless 5G communication network along with its features such as high data rate, improved bandwidth, and low latency strengthen the reliability of the proposed energy trading scheme. Furthermore, Figure 3 depicts the three-layered architecture of the blockchain-based energy trading scheme grouped into prosumer layer, blockchain and auction layer, and consumer layer. The layers can be explained as follows.

Prosumer Layer
The three-layered architecture initiates with the prosumer layer, which comprises several EVs, i.e., prosumers, and the advantage of energy generation from renewable energy sources such as solar power and small wind systems that supply surplus energy to the EVs via an electric charger. However, we have considered that only a certain number of prosumers can generate energy for themselves. Additionally, they can trade the generated energy with the consumers in the consumer layer by spending the amount from their wallet. However, before discussing the communication between prosumer and consumer in the consumer layer, the security aspect of energy trading needs to be highlighted. For that, registering authority is introduced to validate the identity of EVs by registering them through e-KYC. Furthermore, registering authority allows them to participate in the energy trading scheme with the generated public-private key pair. Thus, EVs can request to store their energy trading data in the IPFS with the improved data storage cost. The security aspect of data storage in IPFS is discussed in the blockchain and auction layer to secure the communication between EVs for energy trading.

Blockchain and Auction Layer
The blockchain and auction layer serves as a middle layer to secure the communication between the prosumer and consumer layer. The data storage request of EVs in the prosumer layer has to fulfilled in the blockchain and auction layer. The EV energy trading data and the certificate assigned by the registering authority θ Ra can be forwarded to the IPFS for data storage. Furthermore, a smart contract executes to certify EVs data storage in the IPFS. The accredited charging certificate by smart contract enables transparent EV data storage in IPFS. Otherwise, a certificate found illegitimate by the smart contract can be discarded while maintaining the security of data transactions in the blockchain network. The auction layer is described with the truthful double auction mechanism devised between EVs, i.e., prosumer and consumer, to yield the optimal payoff during the energy trading via a 5G wireless communication network. The employed wireless technology facilitates efficient and reliable data transactions for energy trading. Algorithm 1 presents the secure data storage of EVs in energy trading based on the blockchain network, which will be explained in detail as follows: • Blockchain-based secure data storage algorithm In Algorithm 1, the two entities, i.e., prosumer α r and consumer β o , are considered along with their data Dt α r and Dt β o needed to be stored in the IPFS beforehand certified by the registering authority θ Ra . After obtaining the legitimate certificate from θ Ra , EVs can store their energy trading data in the IPFS that further generates the corresponding hash keys for them. Furthermore, public key cryptography associated with the public-private key pair for the EVs can be used to ensure authenticity and transparency in the energy trading based on the blockchain network [38]. The complete procedure of blockchain-based secure data storage for p and q number of EVs, i.e., prosumer and consumer, can be computed in terms of the time complexity of O(p) and O(q if α r ∈ authorized( αr ) then 8:

Consumer Layer
The consumer layer involves the number of EVs, i.e., consumers participating in the energy trading with the number of prosumers defined in the prosumer layer. Prosumers in the prosumer layer can trade energy with the consumers in the consumer layer after ensuring data storage security through the middle layer, i.e., the blockchain and auction layer. Both of the bidders can bid in the truthful double auction mechanism to trade electricity by disbursing the amount from their wallet. The main aim of EVs is to surpass each other in terms of profit. However, we have incorporated the truthful double auction mechanism and the smart grid operated by renewable energy sources such as solar energy, nuclear power plant, and biomass energy to balance the overall payoff of energy trading. Therefore, prosumers can sell energy to the consumers through the blockchain and auction layer authenticating the energy trading procedure.

Problem Formulation
The blockchain-based secure energy trading scheme involves several entities in which p number of prosumers {α 1 , α 2 , . . . , α p } ∈ α r associated with the energy levels, i.e., {ζ α 1 , ζ α 2 , . . . , ζ α p } ∈ ζ α r at a location that is being indicated by latitude and longitude can trade with c number of consumers {β 1 , β 2 , . . . , β c } ∈ β o located at the distance which can be computed with the latitude and longitude , κ ζ α 2 , . . . , κ ζ αp } ∈ κ ζ αr in green that k number of prosumers (k < p) can sell to the consumers willing to purchase the energy with the optimum price. The prosumers and consumers along with their data, , Vc β o can trade energy with the help of their wallet address ∆ α r and δ β o . The above-mentioned associations can be represented as follows: where p and c denote the number of prosumers and consumers communicating for the energy trading with the energy level ζ α r associated with the k number of prosumers through the available Volt coins Vc β o associated with the consumer. To enable secure and efficient energy trading between prosumers and consumers in the blockchain network, they need to register themselves with the registering authority (θ Ra ) via the e-KYC. Registering authority assigns them the unique certificate ( α r , µ β o ) to provide authentic energy trading in the blockchain network. θ Ra verifies if the prosumer contains sufficient energy, i.e., threshold value (Th ζ αr ) to sell and whether consumer contains the sufficient Volt coins (i.e., threshold number of coins (Th Vc βo ) and sufficient available energy (Th ρ βo ) for the secure energy trading in the network. After obtaining the authenticity certificate, the registering authority permits prosumers and consumers to participate in the energy trading by allocating them the public-private key pair (Pu α r k , Pr α r k ) and (Pu The above-mentioned associations of prosumer and consumer with the registering authority can be represented as follows: where r signifies the number of registering authorities associated with the prosumers and consumers. After obtaining the authorization rights from the registering authority, prosumers and consumers can decide to store the energy trading data (E d t ) in the IPFS. Before that, we need to compute the distance between prosumer and consumer at the remote locations to simplify the energy trading process for both of them. The Euclidean distance can be calculated considering the latitude and longitude of the EVs (ψ α r , Ψ α r ) and (ξ β o , Ξ β o ), which can be mentioned as follows [1]: Energy trading between prosumers and consumers can be improved by considering the factors such as temperature (T R ) and atmospheric pressure (A P ) based on the climate condition that can affect the generated renewable energy level in the prosumers. We have considered the renewable sources such as solar panels {Sp α 1 , Sp α 2 , . . . , Sp α p } ∈ Sp α r and small wind systems {φ α 1 , φ α 2 , . . . , φ α p } ∈ φ α r through which prosumers energy is getting generated to avail it for consumers. Considering the scenario of solar panels as a renewable energy source, the amount of energy level of prosumers depends on the temperature factors, i.e., {T l , T h , T m }. If temperature T R tends to be high, then the energy generated will be increased by the temperature factor T h . On the other hand, if the temperature seems to be low, then the energy generated will be decreased by the temperature factor T l . There can be one more possible scenario in which temperature tends to be moderate due to which energy of the prosumers gets affected by the temperature factor. Due to the moderate temperature range, then the energy of the prosumers will get affected by the traffic factor T m that lies between T l and T h . Prosumers should contain sufficient energy even during the temperature effecting parameter. Otherwise, prosumers cannot initiate energy trading with the consumers. These associations can be represented as follows: when temperature is low ζ α r + T h , when temperature is high ζ α r + T m , when temperature is moderate (10) ζ α r + T l (Sp α r ) > Th ζ αr (11) One more factor, i.e., atmospheric pressure A P ∈ {A l , A h , A m } has to be considered for computing the effect on the energy level of the prosumers generated from the small wind systems. If A P is high, then the energy level of the prosumer tends to be increased by the atmospheric pressure factor A h . On the other hand, a decrease in the wind pressure exertion leads to a reduction in the energy level of the prosumers by the factor, i.e., A h . Wind exertion can also vary between low and high leading to moderate wind pressure, denoted by A m . Due to this, energy level generation increases by the factor A m , which is less than the energy generated in high wind pressure. Moreover, prosumers affected by the atmospheric pressure factor (in case of low pressure) should contain energy greater than the threshold energy to execute the trading with consumers in the blockchain network. Therefore, the impact of atmospheric pressure on the energy level of prosumers can be represented as follows: Therefore, prosumers should contain sufficient energy to initiate trading with consumers. However, low energy generation in case of low temperature and atmospheric pressure factors, i.e., T R and A P , leads to the requirement of a smart grid (Θ) that is being located at a distance computed with the help of latitude and longitude (ι Θ , Λ Θ ). It means the consumer can opt to utilize the smart grid for energy trading with a lower price (µ Θ ) than the prosumer associated with a low energy level. The association between consumer and smart grid for energy trading can be represented as follows: Additionally, we need to consider one more scenario for energy trading based on the distance of consumers willing to purchase energy and the price of energy associated with the smart grid and prosumer to decide the profitable energy trading for consumers. First and foremost, we have to determine the distance between the consumer along with the latitude and longitude (ξ β o , Ξ β o ) and smart grid along with the latitude and longitude (ι Θ , Λ Θ ) similar to the Euclidean distance calculated between prosumer and consumer. The Euclidean distance between smart grid Θ and consumer β o with the latitude and longitude (ι Θ , Λ Θ ) and (ξ β o , Ξ β o ) can be determined as follows: Now, we can contemplate the scenarios for energy trading based on the prosumer energy level affecting parameters such as atmospheric pressure A P and temperature T R . If we consider the case of low temperature T l and low atmospheric pressure A l , then it reduces the energy generation level of the prosumers. In that case, consumers can adopt the smart grid Θ in which factors such as energy price associated with the prosumer and smart grid, i.e., κ ζ αr and µ Θ and distance of the smart grid and prosumer to the consumer that is denoted by Eu d (Θ,β o ) and Eu d (α r ,β o ) impact the willingness of the consumer for energy trading in terms of profit. Thus, if consumers have to pay the minimum price and travel the shortest distance by opting the smart grid for energy trading, then the scenario seems beneficial for them. In another scenario, the consumer can be allocated with a smart grid for energy trading if they have to pay the maximum price but travel the shortest distance. However, if the price and distance from the smart grid are maximum, the scenario is not favorable for consumers. Similarly, if consumers are willing to utilize energy from the smart grid with the minimum price but travel the longest route, which can deteriorate the energy level of the consumers. Then, it is not the ideal scenario for consumers to trade energy with the smart grid. The scenario of energy trading between consumers and the smart grid with the condition of low energy generation of prosumers can be mentioned as follows: We need to highlight another scenario in which prosumers contain a moderate energy level due to moderate atmospheric pressure and temperature. In this scenario, consumers can opt for a smart grid for energy trading based on the price and distance from consumers. Therefore, consumers utilizing the smart grid with minimum price and traveling the shortest distance can be beneficial for them. Alternatively, if the energy price associated with the smart grid tends to be the maximum, they have to travel the minimum distance. Then, the above-mentioned scenario can be quite favorable to the consumers for energy trading. Therefore, the scenario of energy trading between consumers and the smart grid when the prosumer contains a moderate energy level can be mentioned as follows: Thus, we have discussed the possible scenarios of energy trading between prosumers and consumers by introducing the smart grid based on the low and moderate energy levels of prosumers. However, data associated with the entities must be secure in the blockchain. To attain the security, we have highlighted the registering authority that allocated the certificate to the EVs that can be used as a security token to initiate the energy trading by storing the data in an intermediary IPFS protocol. Then, a smart contract as a self-executable code involves authorizing the verifiability of the EVs by confirming the certificate assigned by the registering authority. After obtaining the authentic certificate, IPFS permits prosumers and consumers to store information about energy trading. Thus, they can trade energy securely over the blockchain network. After the successful and secure data storage in IPFS, it assigns the hash keys σ α r ∈ {σ α 1 , σ α 2 , . . . , σ α p } and τ β o ∈ {τ β 1 , τ β 2 , . . . , τ β c } to the prosumer and consumer so that blockchain can access the hash keys to verify and add the transactions in the network. The procedure of assigning the hash keys to prosumer and consumer can be denoted by {α r , β o } = {σ α p , τ β c }. To achieve high security in the network, public-key cryptography can be used to ensure authenticity between prosumers and consumers during the energy trading with the public and private key pair of prosumer, i.e., (Pu α r k , Pr α r k ), which can be mentioned as follows [1]: where H d signifies the hash digest of the transactions between α r and β o . ϕ Pu k denotes the decryption of prosumer with its public key Pu α r k , and D S highlights the digital signature of prosumer with its private key Pr k . Therefore, prosumers can trade energy with the consumers over the blockchain by securely performing the transactions in the network.

The Proposed Scheme: Truthful Double Auction
This section discusses the incorporated truthful double auction mechanism for p number of prosumers {α 1 , α 2 , . . . , α p } ∈ α r to trade energy with c number of consumers {β 1 , β 2 , . . . , β c } ∈ β o . The smart grid Θ in the energy trading is decided based on the price and distance between the prosumers and consumers. It means consumers along with their v number of Volt coins Vc β o in the wallet and the available energy ρ β o can bid to trade energy with the prosumers associated with the energy level ζ α r and the energy prices κ ζ αr . However, if consumers bidding for utilizing the energy are less than or equal to the number of prosumers, then the consumer can request energy from prosumers directly. However, when the number of consumers is greater than the number of prosumers, then a truthful double auction mechanism has to be introduced in the energy trading scheme with the involvement of a smart grid considering the price and distance parameters of EVs (prosumers).
The truthful double auction mechanism is formulated considering the 5G wireless communication network with P2P IPFS protocol. However, the dominant strategy and truthfulness feature of the double auction mechanism ensures the optimal payoff during the energy trading between multiple prosumers and consumers along with the smart grid [39]. Therefore, the truthfulness of the double auction mechanism along with its characteristics can be considered to enhance the security and efficiency of energy trading between prosumers and consumers.
Furthermore, we need to discuss several scenarios of the double auction mechanism between consumers and prosumers to improve the overall payoff of the system. Initially, when prosumers contain sufficient energy that can be traded with the consumers optimally.
However, considering the energy prices and distance from the prosumer, consumers can acquire the smart grid to gain the profit surpassing the prosumers. Therefore, scenarios are designed based on the willingness of consumers to pay the minimum price and travel the shortest distance to achieve the optimal payoff. Another scenario is when consumers have to pay the maximum price but travel the shortest distance, which helps in optimizing the available energy of the consumers. Thus, the payoff π l,m β o for consumers by adopting the smart grid along with the price and distance can be mentioned as follows: (24) where c and c denote the number of consumers involved in the energy trading to gain the payoff in their favor. Another scenario can be when prosumers want consumers to utilize their energy based on the price and distance beneficial for them considering the low, high, and moderate energy level. Despite adopting the smart grid, prosumers may be willing that consumers should utilize energy with the maximum energy price and pay the longest distance for trading. Thus, consumers opting for the prosumers deteriorate a higher amount of energy leading to the probability of paying high energy prices. In another scenario, if consumers pay the minimum price, but they have to travel the longest distance, further deteriorating the available energy. The payoff π l,h,m α r of prosumers considering the scenarios can be mentioned as follows: where p and p number of prosumers can trade energy with c and c number of consumers for gaining the maximum payoff. Therefore, we have highlighted the various scenarios of a truthful double auction mechanism between prosumers and consumers in which both the EVs are bidding their true strategy to gain the maximal payoff from the energy trading. The combined payoff of prosumers and consumers can be expressed based on the different scenarios, which can be mentioned as follows: Based on the evaluated optimal payoff of the prosumers and consumers, it can be perceived that both of them are bidding their true strategy to gain the optimum profit during the energy trading based on the adaptation of the smart grid. However, there can be a conflict between prosumers and consumers, which can discourage them from participating in the energy trading scheme. Therefore, we have reached a stable state, i.e., Nash Equilibrium, in which payoff between prosumers and consumers can be expressed by determining the mid point of the respective payoff: Finally, we have determined the optimal payoff for energy trading between prosumers and consumers considering the payoff of both EVs.

Truthful and Individual Rationality Characteristics of the Double Auction Mechanism
We can discuss the truthful and individual rationality characteristics of the proposed double auction mechanism in which payoff for EVs has been determined at a stable state, i.e., Nash Equilibrium, which attains a trustful and beneficial energy trading for prosumers and consumers. Definition 1. The truthful double auction mechanism between bidders, i.e., prosumers and consumers, works on the principle that each bidder trades energy to maximize their profit by bidding their true utility value, i.e., the payoff that maintains the trustworthiness of the EVs in the energy trading. Moreover, if the double auction mechanism between prosumers and consumers is truthful, then they should also fulfill the criteria of individual rationality. We can mention the truthfulness in the double auction mechanism considering the true utility value of prosumers and consumers, which can be mentioned as follows [40,41]: where Π represents the information about the bid of prosumer and consumer.
Proof. The truthfulness of the double auction mechanism can be proved based on the bid value of prosumers and consumers that is denoted by the energy prices κ ζ αr and Volt coins Vc β o . For that, we have considered the true and false bid value for prosumers and consumers that can be defined as {t α r , f α r }and{t β o , f β o } to determine the truthfulness of the double auction mechanism, which can be explained with the following cases: • If f α r < t α r , then prosumers trade energy with the bid value less than its true value. However, prosumers bidding with the energy price less than their true value can deviate them from the energy trading due to the incurred loss; • If f α r > t α r , then prosumers trade energy with the bid value greater than its true value, which seems to be a beneficial choice for them. However, consumers may not be willing to participate in the energy trading due to the high energy prices for EVs. • Similarly, if f β o < t β o and f β o > t β o , then, based on the first case, consumers trade energy with the bid value less than its true value and, in the second case, consumers trade energy with the bid value greater than its true value. However, the first case is not beneficial for prosumers due to the willingness of consumer to trade energy with less number of Volt coins. Alternatively, the second case is not favorable for consumers due to the higher bidding value (more number of Volt coins) in the energy trading scheme.
Therefore, we have considered the true valuation for prosumers and consumers, i.e., threshold energy prices and threshold number of Volt coins to enable a profitable energy trading. Furthermore, we have formulated the double auction mechanism to balance the true utility of EVs in terms of optimal payoff at a Nash Equilibrium.

Definition 2.
In the truthful double auction mechanism, individual rationality is defined between the bidders, i.e., prosumers should trade energy with the corresponding energy prices (greater than the threshold energy prices Th κ ζα r and consumers associated with the available energy along with the number of Volt coins Vc β o (greater than the threshold number of coins Th Vc βo ). According to the individual rationality, EVs can not outgain each other in terms of profit by surpassing the other EV's strategy. It means that EVs can not have the negative payoff leading to a profitable auction for users. The individual rationality between bidders can be satisfied in the form of positive payoff, which can be defined as follows [41,42]: Therefore, the truthful double auction mechanism applied in the blockchain-based energy trading scheme satisfies the features of truthfulness and individual rationality to improve the experience of EVs in the energy trading scheme.

Truthful Double Auction Mechanism Algorithm for EVs Optimal Payoff
Algorithm 2 presents the applied truthful double auction mechanism between EVs based on the low, moderate, and high energy levels of prosumers. The algorithm shows that the consumers can adopt the smart grid due to the fluctuating price and distance from the prosumer. Before that, EVs should satisfy the preconditions, i.e., sufficient energy for trading, and consumers should contain the threshold number of Volt coins to participate in the proposed scheme. If conditions are satisfied, then consumers may want to trade energy with the smart grid due to its beneficial price and distance with the payoff π C β o . On the other hand, prosumers may want to trade energy with the consumers for their profit with the payoff π l,h,m C α r . Finally, we have evaluated the optimal payoff for p and q number of EVs, i.e., π α r ,β o at a Nash equilibrium stable state with the time complexity of O(p) and O(q).

Performance Evaluation
This section highlights the simulation results of the formulated truthful double auction mechanism between prosumers and consumers to ensure the optimal payoff between EVs by introducing the smart grid in blockchain-based energy trading. In the proposed scheme, we consider an EV energy management ecosystem supported by a public blockchain network. We consider an energy trading mechanism between peer EVs (prosumers and consumers), in which excess energy of EVs can be traded in real time to near-location EVs. As the considered network is dynamic (EVs are mobile) in the vehicular network, a new EV initially registers itself to the public blockchain and publishes its public key and certificate to other EVs. Nearby location area aggregators guide the EV authentication process, and the details are stored in the IPFS node. Finally, the registration details are hashed, and the content key of 32 bytes is generated, which is stored as meta-information in the public blockchain network.
During the energy trading mechanism, we consider that the trading is facilitated post the double auction mechanism, which fixates the optimal price condition between prosumers and consumers. The contracts are executed over the Remix Integrated Development Environment (IDE) platforms, and the implementation is carried out over the Rinkeby Test network. The contracts are executed over the Ethereum virtual machine (EVM), where to process the contract, a gas fee is deducted from the EV owner's wallet, and the traded energy unit is marked on the contract. The contracts are designed in the Solidity programming language and are executed over low-level contract API calls. Finally, once the contract is deployed, it is published over the IPFS node, and the content URL is shared among all EVs. The experimental results, along with the parameters, are described in the following subsections. Figure 4 depicts the convergence analysis of the proposed scheme with the conventional blockchain-based EV charging scheme. The graph highlights the improved optimal payoff of the proposed scheme to the conventional scheme with the increase in the number of transactions. The reason for obtaining the best response of the payoff is due to the applied truthful double auction mechanism in the proposed energy trading scheme. It ensures the trustworthiness of the bidding as per the strategies of bidders, i.e., EVs. However, the conventional double auction mechanism proposed in [27] does not guarantee the truthfulness of the user's strategy, which can also discourage EVs from bidding. Moreover, they have also ignored the individual rationality for applied double auction mechanism, which can demotivate users from participating in energy trading. In the proposed truthful double auction mechanism, bidders, i.e., prosumer and consumer, bid their true strategy to gain the maximum payoff considering the effecting parameters, i.e., temperature and atmospheric pressure. However, we have defined the strategy for EVs by introducing the smart grid to decide the optimal profit in which consumers can utilize the energy based on the price and distance between prosumers and the smart grid. Finally, the optimal payoff is determined considering the scenarios of strategy for both of the EVs with the balanced profit.  Figure 5 shows the profit for consumers with the increase in the number of prosumers in blockchain-based energy trading. We have considered a scenario in which the increasing number of prosumers α r want to trade energy with consumers β o located at a remote location. However, the probability of consumers β o to trade energy with the smart grid Θ is high due to its associated minimum price and distance. Therefore, the above-mentioned scenario has been considered in the truthful double auction mechanism, which yields improved profit for consumers by adapting the smart grid with the increased number of prosumers in the energy trading.

Computation Time
The computation time is important to measure the reliability of the transactions between prosumers and consumers in the blockchain-enabled energy trading scheme. Thus, the computation time to store or retrieve the information of EVs about the energy trading in the blockchain needs to be considered. Moreover, the execution of a smart contract written as a self-executable code decides the authorization of the EVs for data storage in the blockchain, which can be performed in 0.08 s [43]. On the other hand, if a combinatorial blockchain and IPFS energy trading scheme is utilized for EVs, then data storage time through the usage of IPFS can be determined as 0.11 s [44]. The use of intermediary IPFS yields somewhat moderately higher computation time than with the blockchain. However, IPFS as a decentralized and P2P protocol stores data with low cost in a distributed manner than the blockchain, which improves the cost-efficiency of the system. Thus, we have considered the IPFS protocol to enable the cost-efficient data storage of energy trading in the blockchain. Now, we need to contemplate the data retrieving procedure from the blockchain. The data retrieving time directly from the blockchain can be evaluated in 6 × 10 2 s [45] by applying the encryption using the SHA-256 algorithm. However, in the proposed scheme, EV energy trading data can be retrieved in 7.5 × 10 −2 s [43], with the employed IPFS data storage protocol that works on the principle of data storage by generating the hash of a block of data. It can be distinguished from the data storing and retrieving procedure that computation time associated with data storage in the blockchain combined with the IPFS seems relatively lower than in the blockchain.

Blockchain Analysis
In this subsection, we discuss the performance of blockchain in the energy trading ecosystem. We discuss three important metrics: the node commit latency, the auction fairness (impact of collusion attack), and the consumed energy by active EVs. The details are presented as follows. • Node Commit Latency-In this subsection, we discuss an important metric, the node commit latency of the proposed scheme. The node commit latency is the elapsed time when a transaction is proposed, and it is finalized in the block with the consensus validation. Figure 6 presents the results. Thus, the node commit latency is directly proportional to the consensus mechanism employed in the system, and the value of miner difficulty M D . We compare the results with Kumari et al., which uses a Proof-of-Stake (PoS) consensus. Let us consider that q EV transactions are finalized, with a difficulty M D . Thus, in the PoS consensus, the finalized blocks B f inal satisfy the condition as follows: where block i denotes the time elapsed for finalizing a block by any i th miner, and coin i presents the stake of the i th miner. Thus, the product block i × coin i is the coin-age, and is the overall stake of the i th miner. Once a miner is selected, we set coin i as 0 to ensure fairness in the system. As we have a large number of transactions to be finalized, block i is generally large. In our proposed approach, we consider a sharded PoS approach, where the entire blockchain network is divided into w shards. Thus, the finalizing time of each shard is B f inal /w. Once the payoffs are finalized by an auction, we consider the load γ of transactions proposed to a shard. In this case, if γ is sufficiently high, we reduce the election time of the i th miner by reducing the value of coin i , which reduces the latency. In overall, the node commit latency in a shard is proportional to 1 w times of block i ×coin i M D , which improves the commit latency. In the figure, we consider the load as percentage of processed blocks, which is F(B)/T(B), where F(B) is the finalized blocks, and T(B) is the total blocks. Thus, at γ = 0.25, means 1/4 of total blocks are finalized, the commit latency in the non-shared (Kumari et al.) approach is 1150 seconds (s). With w = 10 shards, the commit time reduces to ≈125 s. Similarly, at γ = 0.5 (one-half of total blocks are finalized), the commit time is 2500 s in a non-sharded approach, which becomes 250 s in our approach. • Collusion Attack Scenario-Next, we present the importance of blockchain in mitigating the collusion attacks. Figure 7 presents the results. In the scheme, we discuss a truthful double auction between p prosumers and c consumers. We consider a scenario where the k among the p prosumers can collude to decrease the energy level ζ α r , which would lead to price inflation for consumers. This situation would not be solved by an auction pricing mechanism as it would only determine a faulty optimal payoff condition. Instead, once the energy units are fixed by p, the details of energy price per unit are also fixed, and then the auction starts. As the details are stored in the blockchain, the colluding parties' higher bids would not be considered by other nodes during validation. Intuitively, auction fairness in the real sense is defined as the trading condition where no payoff condition brings a price loss to the buyer and seller nodes. In the proposed double auction mechanism, considering n nodes in the network, we assume that, if the offered price o p to a particular seller node s is less than a designated base (nodal price) n p , then an additional compensation amount c is also paid to s. Thus, the seller node's auction fairness (selling price) condition is depicted as follows: where f s p denotes the final price to seller node. In the case of collusions, the bidding price is lowered by buyer nodes to lower the profit of the seller. In such a case, the auction designer increases the nodal (base) price to cover the loss. On the other hand, if the seller node is collusive, then also fairness is guaranteed as the base price is stored in the blockchain. Thus, all buyer nodes are aware of the n p , and the bidding starts with a price just higher than n p . For the buyer nodes, the fairness condition is presented as follows: where f b p denotes the final price of buyer node, and c p denotes the cost price of the traded energy. The auction fairness condition is dynamic and depends on the underlying auction conditions [46]. The details of auction fairness are presented on similar lines. We compare our approach to Aujla et al. [47], which proposes a Stackelberg game formation for energy trading among EVs and CS. In the figure, a collusion indicator of 0.3 indicates that, out of the total participating entities (p prosumers and c consumers), we assume that 30% of the population is not fair, or have made parties with others. In the consensus formation, we consider a sharded PoS, which elects a miner based on a reputation score R. In any event E, out of total users, we consider the R value for each node between 0 and 1, i.e., 0 < R < 1, and is defined as B Final T blocks , where B Final is the final verified blocks, and T blocks is the total number of blocks. As B Final increases during the auction phase, the fair energy allocation decreases in a non-BC approach, whereas, in the proposed scheme, we see a gradual drop in auction fairness. At 0.5 collusion scenario (50% dishonest entities), the fairness indicator is 0.68 in our scheme, which means that still 68% of the traded transactions are fair, compared to 0.41 in the non-BC approach. The reason is trivial: once the prices are stored, they cannot be altered, and the sharded PoS elects a miner based on a high value of R, and, thus, there are less chances for the miner to be biased. This leads to fair block proposals in most auction events. • Energy consumption by EVs-Lastly, we simulate the energy consumption by EVs against consensus approaches like Proof-of-Work (PoW), and PoS. Figure 8 depicts the results.
As shared PoS has a low transactional finality time, thus less time is required to form the collective voting decision to add the next block. However, in both PoW and PoS, the network requires multiple message confirmations to finalize the block. In PoW, we consider t miners in the ecosystem; then, the average expected time PoW[T EAvg ] to finalize a block is presented as follows [48]: where P i is the computational power of i th node, and TD is the target difficulty. In PoS, the expected time for t-miner ecosystem is as follows [49]: where stake i denotes the stake of i th miner, and li f e i is the lifetime value of stake i based on last win chance. In both PoW and PoS, the time to add a block is further delayed by T del , and is presented as follows: where M C is the communication delay for propagation of node updates. Both PoW and PoS thus have a low transactional throughput. However, with a sharded approach, the overall network is divided into k shards, and thus each shard only has 1/k number of transactions to validate. Most communications are managed through a shard manager, and thus T del reduces drastically. Thus, the expected time [T EAvg ] also reduces, and less energy is required to communicate in the network. On these discussions, we model the energy consumption of energy trading between active EVs, and compare our scheme with PoS and PoW blockchains. As an example, for 150 active EVs, PoW has a high energy dissipation of 2400.1 kiloJoule (kJ), PoS has 1767.19 kJ energy dissipation, and the energy dissipation in our scheme is 1100.46 KJ, respectively.

Data Storage Cost Computation
This section describes the data storage cost of blockchain and IPFS-enable energy trading scheme for prosumers and consumers. The Ethereum blockchain as an open-source and decentralized framework provides EVs a platform to store their data transactions securely utilizing the IPFS data storage protocol. IPFS protocol enables data accessing and storage cost-efficient for EVs involved in the energy trading scheme. We can compute the cost required for data storage in blockchain considering the parameter, i.e., gas price of a single word (S w ) and determine the gas for data storage of 1 KB of data with S w . The gas required for a single word and 1 KB of data can be mentioned as follows: 1S w = 20 × 10 3 Gas(Ga = 20k) (38) Gs KB = (2 10 /256) × (20 × 10 3 ) Gas Furthermore, gas price (Gs b pr = 23.186 gwei) and Ethereum price (E b pr = 232.96 USD) can be used to enumerate the data storage cost (D K c ) of K number of words in the blockchain. Thus, we can represent the calculation of D K c for data storage of K words contemplating the parameters 1E = 10 9 in the form of expression, which can be mentioned as follows: Finally, data storage cost of K words in USD can be determined by observing the parameters D K c , Gs b pr , E b pr that can be represented as follows: Therefore, incorporating the IPFS with blockchain improves the data storage cost D K USD c for EVs due to the cryptographic hash generation of the data that can be used to execute real-time transactions in the blockchain network [50].

Conclusions and Future Scope
In this paper, we presented an integrative scheme that combined blockchain and truthful double auction strategy to assure trusted energy transactions, supported through an optimal payoff between the prosumers and consumer EVs. Once EVs are registered in the network, we store the authentication details on the IPFS network which addresses the scalability issue of public blockchain. The energy trading is facilitated through smart contracts, once the payoff scenarios are finalized, and payoff convergence is reached. This assures that both parties (prosumers and consumers) have achieved optimal trading benefits, which is validated via convergence to the Nash equilibrium state. Furthermore, to ensure low latency and high reliability in network communication, a 5G-assisted network is considered. The scheme is validated for auction and blockchain parameters, and the comparative analysis suggests the potential improvements in terms of n terms of optimal profit, high reliability, individual rationality, and trustworthiness.
However, there are certain limitations with the proposed scheme. Firstly, as we integrate the contracts on public blockchain networks, these contracts are still vulnerable to attacks like dependency injection, gas overflow, and buffer attacks. Thus, security validation is a future direction of the work. Secondly, the trading environment is dynamic, where energy fluctuations between the energy sources (smart grids), CS, and EVs are common. Hence, a consensus strategy is required to dampen the transient fluctuations.
For the same, reinforcement learning based strategies can be considered by researchers, where an agent learns about the environment conditions, and forms an optimal reward policy that minimizes the energy fluctuations. This would address the intermittent energy spikes, and make the network more stable that would optimize the auction mechanism.