Content uploaded by Nadeem Javaid

Author content

All content in this area was uploaded by Nadeem Javaid on Sep 18, 2021

Content may be subject to copyright.

Towards Sustainable Smart Cities: A Secure and

Scalable Trading System for Residential Homes using

Blockchain and Artiﬁcial Intelligence

Omaji Samuel1, Nadeem Javaid1,∗, Turki Ali Alghamdi2, Neeraj Kumar3

1Department of Computer Science, COMSATS University Islamabad, Islamabad 44000,

Pakistan

2Department of Computer Science, College of Computer and Information Systems, Umm

Al-Qura University, Makkah 21955, Saudi Arabia

3Computer Science and Engineering Department, Thapar Institute of Engineering and

Technology, Patiala 147001, India

Abstract

This paper proposes a secure blockchain based energy trading system for resi-

dential homes. In the system, a new proof-of-computational closeness (PoCC)

consensus protocol is proposed for the selection of miners and the creation of

blocks. Moreover, an analytical energy pricing policy is designed to solve the

problem of existing energy pricing policies in a distributed trading environment.

A dynamic multi-pseudonym mechanism is developed for the prosumers to pre-

serve their transactional privacy during energy trading. Since it requires extra

storage and computing resources for the blockchain miners to simultaneously

execute both mining process and application intensive tasks, therefore, an im-

proved sparse neural network (ISNN) is proposed for computation oﬄoading to

the cloud servers. In ISNN, a Jaya optimization algorithm is used to accelerate

the error convergence rate while reducing the number of connections between

diﬀerent layers of neurons. Besides, ISNN optimizes the overall computational

cost of the system. Furthermore, the security of the prosumers is ensured using

∗Corresponding author: www.njavaid.com

Email addresses: omajiman1@gmail.com (Omaji Samuel1), nadeemjavaidqau@gmail.com

(Nadeem Javaid1,), taghamdi@uqu.edu.sa (Turki Ali Alghamdi2), neeraj.kumar@thapar.edu

(Neeraj Kumar3

)

Preprint submitted to Elsevier September 18, 2021

blockchain technology while security analysis shows that the system is robust

against the Sybil attack. The proposed blockchain based peer-to-peer secure

energy trading system is extremely important for sustainable cities and society.

Simulations are conducted to evaluate the eﬀectiveness of the proposed system.

The proposed pricing policy is compared with time-of-use pricing, critical peak

pricing and real-time pricing policies. From the results, it is proved that the

prosumers achieve a higher degree of satisfaction and utility when using the

proposed pricing policy. Moreover, the probability of a successful Sybil at-

tack is zero as the number of attackers’ identities and computational capacities

increases. Under diﬀerent sizes of data to be uploaded, the proposed ISNN

scheme has the least average computational cost and data transmission time

as compared to deep reinforcement learning combined with genetic algorithm

(DRGO) and sparse evolutionary training and multi-layer perceptron (SET-

MLP) schemes in the literature. Moreover, the proposed system is tested for

scalability by increasing the number of prosumers. Extensive simulations are

performed and the results depict the satisfactory performance of the proposed

system.

Keywords: Computation oﬄoading, energy trading, proof-of-computational

closeness, improved sparse neural network, smart grid

1. Introduction and Literature Review1

In this section, the introduction of the paper and literature review are pre-2

sented. The problem statement extracted after a brief literature review is also3

discussed. Moreover, the contributions and organization of the paper are given4

at the end of the section.5

1.1. Introduction6

Nowadays, the integration of renewable energy sources (RESs) and informa-7

tion and communication technologies is revolutionizing the energy industry all8

over the world. Besides, distributed generation (DG) is getting popular because9

2

electricity is generated from RESs at the consumers’ end (also known as pro-10

sumers). To this end, the existing power grids are not overstressed. However,11

because of the intermittent nature of RESs, some individuals are incapacitated12

to satisfy their energy demands while others have surplus energy [1]. DG enables13

small-scale energy producers to share and store energy in a decentralized fashion14

[2] using an eﬃcient energy trading mechanism. However, the issues of security,15

privacy, trust and energy pricing determination have hindered the success of16

the existing energy trading mechanisms [3]. Today, blockchain is employed as17

a secure and trusted framework for distributed energy trading [4, 5]. It is de-18

ﬁned as a distributed ledger technology that allows data to be recorded over the19

network. It validates the public ledger by providing a non-partisan way of reach-20

ing an agreement on the global state of the network using consensus processes,21

such as proof-of-work, proof-of-stake, and so on. However, privacy leakage and22

high computational cost are the major issues of the blockchain because of the23

transparency of transactions and execution of computationally expensive min-24

ing algorithms. These issues have restricted the implementation of blockchain25

for resource-constrained users, which is against the concept of sustainable cities26

and society. From the above discussion, it is necessary to provide eﬀective and27

eﬃcient solutions for the privacy, security, resource management and price de-28

termination problems of users in the smart grids. The solutions are extremely29

important for sustainable cities and society.30

1.2. Literature Review31

Today, the smart grid made it easy for individuals to trade and store en-32

ergy, which means that there is a high potential for the energy market [6]. An33

ideal energy market is to create a friendly environment where supply and de-34

mand of energy are possible by reducing high production costs of individuals35

or organizations [2]. Because of the distinct energy usages of individuals, some36

individuals may not have suﬃcient energy to satisfy their energy needs while37

others may have surplus energy. Thus, it is paramount to provide an eﬃcient38

energy trading market for them. Many thanks to the development of peer-to-39

3

peer (P2P) energy transfer technology where energy is exchanged between peers40

residing in the same area [2, 7]. The most feasible approach in a smart grid is41

a centralized technology, which is simple to set up and implement. However,42

the approach faces a variety of concerns, including lack of trust, single point43

of failure, and high operational and maintenance costs. Moreover, in a P2P44

energy trading scenario, trust, privacy and security are plausible challenges for45

the future smart grids. To enhance the security in energy trading and address46

the above-mentioned challenges, blockchain technology has been recently intro-47

duced.48

1.3. Peer-to-Peer Energy Trading49

Recently, the authors in [8] present a survey that discusses the security prob-50

lems and the impact of deploying blockchain in smart cities. The authors in [9]51

suggest a Byzantine blockchain based consensus system for strengthening data52

protection during energy trading for the involved entities. However, the con-53

straints of entities to execute computationally intensive tasks, like blockchain54

mining, are not considered. The authors in [10] propose a blockchain based55

software-deﬁned network (SDN) for securing energy trading between entities in56

an intelligent transportation system. However, the privacy of entities is not57

considered. Notwithstanding the technological advancement in energy trading58

systems, some issues prevent blockchain and P2P energy trading from being59

fully implemented. Firstly, it is quite diﬃcult to develop a distributed energy60

trading market where a fair balance between data privacy and economic ef-61

ﬁciency can be achieved. Lastly, as the number of storage devices increases,62

there is a need for developing a new P2P market that accounts for their inter-63

temporal dependencies. To this end, the authors in [11] develop a decentralized64

blockchain based P2P energy exchange framework to solve the challenges. In the65

system, a two-layered platform is proposed. The ﬁrst layer performs short-term66

pool structured auction using the ant colony optimization method, whereas the67

second layer consists of blockchain that provides a high level of security, real-68

time settlement and automation. However, resource management of users is69

4

not considered. Energy trading between entities is a typical vertical market in70

a smart grid, but when processing energy trading decisions locally, there is a71

security problem as well as a rise in transmission delay and network overhead.72

The authors in [12] recommend a blockchain based edge-as-a-service framework73

for securing energy trading in an SDN enabled vehicle-to-grid ecosystem to solve74

the issues. However, the resource management problem of an entity is not re-75

solved as the proposed consensus mechanism is proof-of-work, which is CPU76

intensive. The authors in [4] resolve the high processing and packet overhead of77

users using a routing method for energy trading in a smart grid. In the routing78

method, a packet is routed on the basis of destination public key. The authors79

in [13] present a pseud digital identity mechanism to prevent privacy leakage80

of entities in a sustainable society. Also, a blockchain based incentive demand81

response mechanism is proposed to ensure the credibility of diﬀerent entities.82

The authors in [14] propose a blockchain based hesitant fuzzy linguistic sys-83

tem and k-mediods clustering algorithm for improving the decision making in84

energy trading. The proposed system serves as a reference model to diﬀerent85

participants in energy trading, including governments and companies. Also, it86

helps them to critically understand the impact of deploying blockchain tech-87

nology in energy trading. A novel blockchain based load sharing mechanism is88

proposed in [15] for smart microgrids. In the paper, the authors consider the89

industrial Internet of things ideal for distributed control of renewable micro-90

grids. The proposed system has a layered architecture. The upper layer has91

control over system dispatch, whereas the lower layer is responsible to control92

the proceedings of load.93

1.4. Cloud Computing based Computation Oﬄoading94

Cloud computing provides a promising solution that assists users in per-95

forming computationally intensive tasks using the computing resources [16].96

However, cloud computing faces issues of resource management and scheduling,97

which are multi-objective optimization problems [16]. In the literature, meta-98

heuristic optimization techniques have been adopted to solve the problems in99

5

cloud systems [17, 18]. Besides, machine learning methods [19, 20, 16] have100

been used as possible solutions to resolve the problems. However, the solutions101

provided by the researchers in [16, 18, 19, 20, 21] do not consider a single point102

of failure, security and privacy concerns, and how to eﬃciently share computing103

resources trustfully in the smart grids. Moreover, the works in [22, 23, 24, 25]104

propose blockchain based cloud systems for solving resource management prob-105

lem. However, privacy concerns of blockchain nodes are not considered in the106

systems. Also, the systems require further improvement to achieve robust re-107

source management.108

In this study, we consider a scenario of residential homes that wish to trade109

energy securely using blockchain technology. The residential homes can become110

miner nodes based on their computing and storage devices. In addition, security111

and privacy concerns are paramount for ensuring a safe energy trading transac-112

tion for residential homes. That is immensely important for sustainable cities113

and society. Furthermore, an eﬃcient energy trading pricing policy is important114

for enhancing energy trading in a P2P fashion. Therefore, this study proposes a115

secure energy trading system using blockchain and artiﬁcial intelligence for rural116

residential homes. Table 1 presents the comparative analysis of the proposed117

scheme with other existing schemes in terms of objectives, mechanisms, energy118

trading, privacy, resource management and security analysis.119

Table 1: Comparative analysis of the proposed scheme with existing

schemes

Objectives Mechanisms Energy

trading

Privacy Resource

manage-

ment

Security

analysis

Blockchain enabled

neighboring energy

trading system [2]

Privacy preserving

mechanism using

multi-pseudonym

3 3 7 7

6

Blockchain based dis-

tributed energy trad-

ing system [4]

Pricing negotiation

method

3 3 7 7

Blockchain based

P2P trading for

crowdsourced energy

system [5]

Day ahead schedul-

ing

3 7 7 7

A Byzantine based

blockchain consensus

framework [9]

Analytic pricing pol-

icy

3 3 7 3

Blockchain based se-

cure energy trading

scheme for electric

vehicles [10]

SDN 3 7 7 7

Blockchain based

decentralized P2P

energy trading

platform [11]

Ant colony optimiza-

tion

3 7 7 7

A consensus based

blockchain mech-

anism for secure

energy trading in

SDN enabled vehicle

to grid [12]

Edge-as-a-service for

secure energy trading

method

3 7 7 7

A blockchain based

price incentive de-

mand response [13]

Non cooperative

game and pseud

identity mechanism

3 3 7 7

A blockchain based

energy trading sys-

tem [14]

Hesitant fuzzy

linguistic and k-

mediods

3 7 7 7

Edge cloud assisted

Internet of things [21]

Iterative double

sided auction scheme

3 7 3 7

7

Blockchain empow-

ered mobile edge

computing [22]

Deep reinforcement

learning method

7 7 3 7

Blockchain em-

powered industrial

Internet of things

[23]

A multi-hop cooper-

ative and distributed

computation oﬄoad-

ing algorithm

7 7 3 7

Blockchain based

mobile edge comput-

ing [24]

Stochastic geomet-

ric method and an

alternative direction

method of multiplier

algorithm

7 7 3 7

Blockchain based

cryptocurrency for

computation oﬄoad-

ing [25]

Incentive scheme and

a reputation mecha-

nism

7 7 3 7

Proposing a

blockchain based

energy trading

system for rural

residential homes

Analytical pricing

policy, ISNN and

multi-pseudonym

3 3 3 3

120

1.5. Problem Statement121

Recently, blockchain based energy trading systems have been proposed for122

energy users in the smart grids [2, 4]. However, existing schemes depend on123

ﬁxed energy trading pricing policies, auctions, and negotiation methods that are124

ineﬀective in a network of consumers with a diverse set of needs. Besides, com-125

bining blockchain mining and application intensive tasks, like trading, increases126

the computational cost for resource-constrained energy users. Furthermore, the127

privacy problems of the users are not completely addressed. Therefore, it is128

important to provide an eﬃcient energy trading system that ensures a reduced129

8

computational cost, high privacy and security of energy users, which are ex-130

tremely important for sustainable cities and society.131

1.6. Contributions132

This paper addresses the important issues of privacy and energy trading133

for sustainable cities and society. As the technology for deploying RESs in134

residential homes advances and more people are anticipated to be involved,135

these issues are becoming more signiﬁcant to be considered in the design of such136

technology. So, a blockchain system for the residential homes to trade energy in137

a distributed way is proposed. In this study, the prosumers are residential homes138

that generate and consume energy locally. The contributions of this paper are139

given as follows.140

1. A blockchain based energy trading system is proposed for the smart and141

sustainable cities with the integration of cloud for computation oﬄoading.142

2. To optimize computation oﬄoading cost for the miner nodes, an improved143

sparse neural network (ISNN) is proposed.144

3. Using the concept of resistance distance [26], a new proof-of-computational145

closeness (PoCC) consensus protocol is designed for miner’s selection and146

block creation.147

4. A novel pricing scheme is proposed to enhance the utility and satisfaction148

of the energy prosumers. It encourages the prosumers to participate in149

energy trading.150

5. A privacy preservation mechanism based on multiple pseudonyms is de-151

veloped. It is used to shield the transactional privacy of prosumers during152

energy trading.153

6. The vulnerability of the proposed system to the Sybil attacks is evaluated.154

The results depict that the system is robust against the attacks.155

7. Extensive simulations are performed to check the scalability of the system156

against increasing number of users.157

9

1.7. Paper Organization158

The remaining paper is organized as follows. Section 2 presents the proposed159

system model and the problem formulation is given in Section 3. Section 4160

provides the privacy preservation for prosumers while Section 5 presents the161

security analysis. Moreover, in Section 6, socio-economic aspects of the proposed162

system are discussed. Section 7 gives the discussion of the simulation results163

and Section 8 concludes the paper.164

2. System Model165

As shown in Fig. 1, the proposed architecture consists of rural residen-166

tial homes, miner nodes, smart meters (SMs), cloud system and consortium167

blockchain. All of the homes have installed SMs to eﬃciently communicate with168

adjacent peers forming the local communities through direct wireless broadband169

communication technology. The homes use SMs to record information about170

their energy consumption and solar panels to harvest energy, which is stored171

in batteries. The energy need of each home is satisﬁed with the harvested en-172

ergy that is stored in the batteries. Due to the change in temperature and173

solar irradiation on solar panels [3], the energy generation from RESs of a home174

can become less than the demand. To meet the energy demand, such homes175

purchase energy locally from other homes that have surplus energy via P2P176

energy trading [27]. If the homes do not have surplus energy, then the energy177

is purchased from the main grid. The homes, also known as ordinary homes,178

are connected to access points to get services from the cloud system. In this179

study, ordinary homes have low computational resources and low capabilities to180

perform blockchain mining. The miner nodes are similar to ordinary homes but181

have high computational resources and more capabilities for blockchain min-182

ing. These nodes are responsible for performing blockchain mining tasks and183

providing services like price determination to ordinary homes. Determination184

of price is as issue in a P2P energy trading market, which is labeled as L2 in185

Fig. 1. In this study, the cloud system oﬀers enough computational and out-186

10

Full

Battery Home #1

Solar Panel

Smart

Meter

Full

Battery Home #1

Solar Panel

Smart

Meter

Home #N

Empty

Battery

Home #N

Empty

Battery

Limitations

L1: Security and Privacy

L2: Energy Pricing Policy

L3: Resource Management

Limitations to be addressed

L1

: Lack of Security and Privacy

L2

: Inefficient Energy Pricing Policy

L3

Cloud System

: Problem of Resource Management

Offloading

Computation

Outsourced

Storage

Consortium

Blockchain

L1 and L3

L1 and L2

L1 and L2

L3

#1

#2 #K

Virtual

Machine

Figure 1: The proposed architecture consists of rural residential homes that trade energy with

each other within the consortium blockchain network. During energy trading, the limitations

to be addressed are security and privacy, energy pricing policy and resource management,

which are denoted by L1-L3

sourced storage for miner nodes. In the proposed system, the ordinary homes187

and miner nodes are the nodes of the consortium blockchain. To avoid losses188

during energy transmission between nodes and enhance energy trading in terms189

of quick energy delivery, the energy is exchanged between nodes that are present190

in the same proximity. Note that we do not consider the performance of the191

proposed system in terms of data loss, line interruption, noise and delay. They192

will be taken into consideration in the future. In our system, we consider power193

line communication. Both energy and data are transferred between nodes using194

existing power line infrastructure [28]. Hence, there is no extra cost of electrical195

and communication lines for energy and data transfer, respectively, which make196

the system practical for the real world scenario. A consortium blockchain is em-197

ployed in this paper to provide authentication for the nodes before performing198

energy trading in the sustainable society. Also, a multi-pseudonym mechanism199

is proposed to protect the transactional privacy of homes. Besides, blockchain200

resolves the problems of lack of trust and a single point of failure issues which201

are common in a centralized system [3], labeled as L3 in Fig. 1 .202

11

Inspired by the work in [23], this study assumes that every ordinary home203

performs fewer data processing tasks, excluding the mining task within a pre-204

deﬁned deadline. Two important tasks are considered in this study: the energy205

trading task and the blockchain mining task. This study considers the former206

as a normal task and assumes that the task can be locally performed by both207

ordinary homes and miner nodes, whereas the latter can only be performed us-208

ing the cloud system. Two rationalities are considered in this study concerning209

the task processing activity of an ordinary home. The ﬁrst rationality is that if210

an ordinary home wants to perform both normal and mining tasks, it uploads211

the tasks to a corresponding miner node, as shown in Fig. 2. For the second ra-212

tionality, if an ordinary home only performs the normal task, then it completes213

the task locally.

Cloud Server

#1

#2

#N

... #k

#1

...

Offload the entire normal

and mining tasks

Ordinary Homes

Blockchain

Managers

Figure 2: Resolving mining centralization problem

214

In this study, if all of the ordinary homes oﬄoad tasks through the same215

path, then a lower cost is shared; however, this can result in congestion and216

ineﬃciency. So, for addressing this issue, we deﬁne Bto be the set of miner nodes217

that are willing to engage in block mining and set a deadline for performing each218

normal task. A miner node in Bwith the most computing resources is selected219

as the blockchain manager (BM) to manage the energy trading operations of220

12

all ordinary nodes in the network. In this study, BM executes computationally221

intensive tasks, such as blockchain mining and normal tasks of all ordinary222

homes at a given time slot. In subsequent time slots, there is a possibility223

that BM is unable to execute the tasks because of a large number of mining224

requests from many ordinary homes, labeled as L3 in Fig. 1. For addressing the225

aforementioned issue, data outsourcing and computation oﬄoading mechanisms226

to the cloud system are provided to minimize the overall system cost of BM.227

Also, ISNN is applied before shifting the tasks to the cloud system. In ISNN, the228

Jaya optimization algorithm is integrated into the sparse neural network (SNN)229

for reducing the number of connections between diﬀerent layers of neurons and230

convergence acceleration.231

2.1. The Proposed Blockchain System232

In this study, an elliptic curve encryption algorithm [29] is employed for233

parameter initialization of the system. Each ordinary home registered with the234

system is given a pair of keys (public pknand private skn) and identity IDn

235

for accessing the system. The pair of keys is used for generating the certiﬁcate236

cerfn, which is bound to the wallet waI Dnof the ordinary home. BM stores the237

mapping list {IDn, skn, pkn, cerfn, waI Dn}to the account pool. During energy238

trading, each ordinary home submits waIDnto its corresponding BM for making239

payment and getting incentives. In the proposed system, each miner node in B240

manages and maintains the records of transactions of the corresponding ordinary241

home in the blockchain. The following is the description of each component of242

the proposed blockchain.243

1. Transaction: This is an instance of a record that is digitally signed and244

encrypted by an ordinary home, and broadcasted over the network by BM.245

The hash of the previous transaction is a part of the current transaction246

that forms a block. Several blocks are chronologically chained to create the247

blockchain. In this study, transaction information includes IDn, energy248

token of the actual transaction and timestamp of the transaction. The249

13

transaction is secured and digitally signed by the miner node to ensure250

the authenticity.251

2. Data block: The block is made up of a hash of the current transactions,252

timestamp, hash of the previous block and transaction counter.253

3. Block creation: For each energy trading operation, BM collects the trans-254

action record of a predeﬁned period. A new block is created by BM when255

the old pseudonym expires while the authenticity of a block is veriﬁed via256

digital signature and encryption.257

3. Problem Formulation258

This section provides the problem formulation in four sub-formulations. Ta-259

ble 2 describes the variables and parameters used throughout the paper.260

Table 2: Descriptions of variables and parameters used in this paper

Notations Description Notations Description

AAdjacent matrix Ed

j,min Minimum deﬁcit energy

λArrival rate of requests Es

i,min Minimum surplus energy

ρBlockchain incentive Π0

z,l,hModiﬁed solution

BLBinary mask of layer LMNetwork model

PrG,b Buying price of grid ζRelative hash of the pro-

sumer

CIjCharges imposed on a buyer

for not remitting the agreed

amount of energy token to a

seller

LF (.) Network loss function

Ccr

kCost of purchasing servers’

resources

nL−1Number of neurons in layer

L−1

Cdt

kCost of data transmission

for oﬄoading tasks

nLNumber of neurons in L

cComputational capacity of

node

mNumber of successful Sybil

identities

14

GConnected graph zNumber of decision variables

αConstant value lNumber of solutions

CdCost of deﬁcit energy P rcr

kPurchasing price of VM

ℵiCredit value of the seller ξPruning rate

Ψ Dataset for the experiment r1and r2Random numbers

PrG,s Selling price of grid LkRequired CPU cycles

dtkTotal transmission rate to

the kth server

SFjSatisfaction of the buyer

drkData transmission rate XSet of nodes

βDecay rate nSize of each layer

Φ Decay time |B|Size of miner nodes in G

DDecision of blockchain man-

ager

ΠL

sSparse matrix

µDeparture rate SSparsity level

XLDense matrix X∗

hSolution with the best value

Dia Diagonal matrix of nodes’

degree

X∗∗

hSolution with the worst

value

τDiscount factor T M T +Total amount of mining

tasks that a miner node k

has to perform in the net-

work after the kth trial be-

fore the start of the Sybil at-

tack

σDrop rate T M T −Total amount of mining

tasks the miner nodes k∈

|B|or any of their Sybil

nodes obtained from the net-

work

Es

iEnergy seller with surplus

energy

iSubscript of energy seller

Ed

jEnergy buyer with deﬁcit

energy

jSubscript of energy buyer

15

γEnergy consumed per CPU

cycles

sSuperscript of energy sur-

plus

EX PdExpected date when the

pseudonym will expire

dSuperscript of energy deﬁcit

FFlag cr Superscript of cloud re-

sources

E(.) Function whose output lies

within R+

P r The proposed price

⊕Hadamard product δk1,k1The Moore-Penrose inverse

of LM

Hblk Hash of blockchain hTime slot

HV M Hash of virtual machine TjTime when energy token is

remitted

ωkHash power of nodes xkin G tjTime slot of energy buyer

Π Hyperparameter to control

the sparsity level S

tiTime slot of energy seller

IDnIdentity of a home NTotal number of ordinary

homes that upload task

through BM

−→

MImproved sparse neural net-

work

RTotal reward of the seller

model

kIndex of blockchain man-

agers

ULnTotal size of data to be up-

loaded

IR Interest rate DLnTotal size of data to be

downloaded

LM Laplacian matrix ITotal numbers of energy sell-

ers

LLayer JTotal numbers of energy

buyers

LqLength of the queue Uj(.) Utility function of energy

buyer

YLine joining any two nodes

in G

WtWaiting time

16

Clocal

kLocal computational task tr Warning message

Ed

j,max Maximum deﬁcit energy kΠk0l0norm of Π

Es

i,max Maximum surplus energy kΠsk0l0norm of Πs

261

3.1. Formulating the Cost of Energy Trading262

The increase in the usage of smart appliances in the sustainable society raises263

energy demand, which overburdens the power grids. Therefore, this study allevi-264

ates the burden on the power grids by proposing a new method of decentralized265

and P2P energy trading for the prosumers, as shown in Fig 3.266

(2) Verify and broadcast the request of the buyer

(4) Generate energy price

Buyer Seller

(7) Generate pseudonym for each transaction

(8) Energy token is sent

(9) Energy is delivered

Consortium

blockchain

Blockchain Manager

Figure 3: Process of energy trading

In the ﬁgure, the prosumers act either as energy buyers or sellers according

to the current energy state. They act as energy sellers when they have surplus

energy Es

i, whereas when they are energy deﬁcit Ed

j, they act as energy buyers.

The subscripts iand jdenote the indices of seller and buyer, respectively; while

the superscripts sand ddenote surplus and deﬁcit energy, respectively. In step

(1), the buyer sends an energy request to the blockchain while in step (2), BM

veriﬁes the request and once the veriﬁcation test is passed, it broadcasts the

request over the network. In step (3), sellers that have surplus energy send

17

responses to the blockchain. Based on the quantity of supply and demand of

seller and buyer, the energy price is calculated in step (4) and the lists of sellers

and energy price are sent to the buyer. The buyer in step (5) selects its preferred

seller based on proximity of location while in step (6), the selected seller accepts

the request of the buyer. For each transaction between a seller and a buyer, a

pseudonym is generated in step (7). The buyer uses an energy token for making

payment to the wallet account of the seller in step (8) and in step (9), seller

delivers the agreed amount of energy to the buyer. If the seller can satisfy the

energy demands of the buyer, then it implies that the buyer can achieve full

energy satisfaction. The satisfaction of the buyer is deﬁned as

SFj=αln Es

i

Cd

+Ed

j,min,(1)

where α∈[0,1] is a constant value that normalizes the buyers’ satisfaction

and Cd=Ed

jP r is the cost of deﬁcit energy. P r =α−τ

ρ

Ed

j

Es

iis the proposed

energy price, τis a discount factor, ρis a blockchain incentive and Ed

j,min is

the minimum deﬁcit energy. Moreover, the satisfaction of a buyer depends

on its Ed

j,min,Cdand Es

i. This means that the Cdis proportional to Ed

j,min.

Besides, the satisfaction of a buyer implies that Ed

jis equal to Es

i, if the following

conditions are satisﬁed [30].

Ed

j,min ≤Ed

j≤Ed

j,max,

Es

i,min ≤Es

i≤Es

i,max,

I

X

i=1

Es

i=

J

X

j=1

Ed

j,

P rG,b ≤P r ≤P rG,s .

(2)

The conditions show that the maximum energy deﬁcit and surplus are Ed

j,max

and Es

i,max, respectively. Whereas, Es

i,min is the minimum surplus energy. P rG,b

and P rG,s are the grid buying and selling prices, respectively. Iand Jare the

total numbers of sellers and buyers, respectively. The conditions imply that

energy trading is possible only if they are fulﬁlled. If the energy cannot be sold

locally, then the energy is bought from the grid as P r =P rGEd

j

Es

iwhere PrG,b ≤

18

P rG≤P rG,s . The buyers are risk-averse entities in the energy trading domain.

It means that they are exposed to the uncertainty that needs to be minimized,

i.e., instability of demand and supply. Therefore, the utility functions of both

sellers and buyers are required to determine whether energy trading services are

rendered or not. In this study, we consider two assumptions of a buyer: uses the

same energy token twice to pay for energy to be consumed and refuses to pay

for energy already consumed. Based on the assumptions, the utility of a buyer

is calculated. Besides, the utility function Uj(tj) of a buyer at a given time tj

represents its individual satisfaction or appropriate usage of energy, which can

be expressed in terms of SFj,bdj,CIjand Ed

j.

Uj(tj) = SFjEd

j(tj)−CIjEd

i(tj)bdj,(3)

bdj=

0,if a buyer remits an energy token to the seller,

1,otherwise,

(4)

where the charge imposed CIjon a buyer for not remitting the agreed amount

of energy token to a seller is calculated as follows.

CIj= (Tj−tj)I R, (5)

where Tjis the time when energy token is remitted to the seller and IR is

the interest rate. From Eq. 3, if a buyer’s decision bdj= 0, the cost of not

remitting the said amount of energy token to the seller is zero; otherwise, the

cost is calculated. In this study, an energy token is used instead of conventional

currency. Moreover, two assumptions of a seller are considered in this paper.

The ﬁrst assumption is that the seller fails to deliver the said amount of energy

on time to the buyer while the second assumption is that the same energy is

sold to more than one buyer. Based on the assumptions, the utility function Ui

of a seller at a given time tiis calculated as follows.

Ui(ti) = RIREs

i(ti)−P rE s

i(ti)+ (1 −R)CIiEs

i(ti)sdi,(6)

19

sdi=

0,if a seller delivers energy on time to the buyer,

1,otherwise,

(7)

where the total number of rewards Ris given as PI

i=1 ℵiΦ, ℵi∈[0,1] is the

credit value of the seller and the time decay is calculated as Φ = exp−β(ζ−j).

β > 0 is the decay rate and ζ=HV M

Hblk [22] is the relative hash of the BM. HV M

and Hblk are the number of hashes of virtual machine (VM) and blockchain,

respectively. Note that Rdiminishes with time until the seller delivers the

said amount of energy to the buyer. The charge imposed CIion a seller for

not delivering the agreed amount of energy to a buyer on time is calculated as

follows.

CIi= (Ti−ti)I R, (8)

where Tiis the time when the agreed energy is not delivered to the buyer within267

the speciﬁed time. From Eq. 6, if the seller’s decision is sdj= 0, the cost of not268

delivering the said amount of energy to the buyer is zero; otherwise, the cost is269

calculated.270

3.2. Formulating the Cost of Oﬄoading Task271

In the proposed system, the computational tasks involve blockchain mining

and trading management. In this study, the overall system cost is minimized

by the proposed ISNN. BM performs computational tasks locally if it has the

required computing resources to execute the above mentioned tasks; otherwise,

it oﬄoads them to a cloud server. The decision Dof BM is given as follows [23].

If D= 0, then BM performs computations locally, which means that BM has

the required resources; otherwise, BM purchases resources from the server and

oﬄoads tasks to it. In this study, the cost of computational task is measured in

terms of energy tokens to unify units [22]. The total cost of the computational

task is deﬁned as follows.

C=

Clocal

k,if D= 0,

Ccr

k,if D= 1.

(9)

20

In Eq. (9), the cost of local computational task is deﬁned as [23]

Clocal

k=γP r Lk,(10)

where kis the index of BM. γis the energy consumed per CPU cycles for using

BM’s resources to compute the normal task and Lkis the number of required

CPU cycles of the normal task. In a situation where BM cannot handle the

computational tasks, it requires the assistance of cloud servers to achieve better

performance. In such a situation, a certain price is paid to purchase the servers’

resources and it is deﬁned as [22]

Ccr

k=P rcr

kLk,(11)

where P rcr

kis the purchasing price of VM in token per Gcycle and the superscript

cr denotes cloud resources. After Ccr

kis calculated, the transmission rate that

ordinary nodes can get when they upload tasks to BM is calculated as drk=dtk

N

[23] where dtkis the total transmission rate and Nis the total number of

ordinary homes that upload tasks through BM. The total cost of oﬄoading

tasks is deﬁned as [22]

Cdt

k=Ccr

k+Pn∈N(ULn+DLn)

drk

,(12)

where ULnand DLnare the data sizes for uploading and downloading, respec-272

tively.273

3.3. Formulating the Cost of Mining Task274

In this study, a connected graph G= (B, Y ) with Bvertex and Yedge is

deﬁned. Where B={bm1, bm2, . . . , bmk}is the set of miner nodes and Yis

the line joining any two nodes in G. In PoCC, a miner node having the highest

computing resources is selected as BM, i.e., from a list of sorted miner nodes with

high computational resources such that bm1< bm2<· · · < bmk. Moreover, if

two miner nodes have the same highest computing resources, the calculation of

computational closeness between the miner nodes and any adjacent miner node

is considered. The miner node that has the smallest computational closeness is

21

selected as the new BM. Let ωkbe the hash power of nodes bmkin G, which is

calculated as number of correct nonce

elapsed time . We calculate the Laplacian matrix as LM =

Dia−Awhere Dia is the diagonal matrix of nodes’ degree and Ais the adjacent

matrix such that A= [b{bm1,bm2}]. It implies that if there is a communication

between bm1and bm2, then b{bm1,bm2}= 1; otherwise, b{bm1,bm2}= 0. The

Moore-Penrose inverse [31] of LM is calculated as δbm1,bm1=LM +1

|B|ωk

where |B|is the size of miner nodes in G. Thus, the computational closeness is

deﬁned as

Ccl

k=δbm1,bm1+δbm2,bm2−2δbm1,bm2.(13)

In this study, we observe that the proposed solution is still centralized in the275

sense that it depends on BM, which is known as a mining task centralization276

problem (see Fig. 2). To address the problem, we increase the number of miner277

nodes in the network, which is achieved by oﬀering incentives to any ordinary278

node who is ready to increase its computing resources. Also, a deadline is279

deﬁned for each mining task. Setting a deadline by BM aims at lowering the280

transmission load on mining nodes while keeping it within a reasonable range281

[23].282

The overall system cost is given as Csys

k=Clocal

k+Ccr

k+Cdt

k+Ccl

k.283

3.4. Formulation of the Proposed ISNN284

Fig. 4 shows the framework of the proposed ISNN, which comprises of the285

two most important components: SNN and Jaya optimization algorithm.286

3.4.1. Initializing ISNN287

Motivated by the work in [33], the network model is represented as M=

f(Csys

k,Π) and is parameterized by Π, which is broken down into the dense

matrix ΠL∈RnL−1nL.nL−1and nLrepresent the number of neurons in layers

L−1 and L, respectively. The network is minimized by a loss function, which

is deﬁned as

X

k1,k2∈k

LF f(Csys

k1,Π), Csy s

k2.(14)

22

Set the Algorithm Parameters

Compute the Objective Function

Evaluate Objective Function and Trim

Solution to Get the Best and Worst

Solutions

Accept and Replace

the Previous Solution

Is

the Termination Criterion Met?

Keep the Previous

Solution

Is

the Latter Objective Better than

the Former Objective ?

Yes No

Yes

No

Get the Optimized System Cost

Dense Network

Sparse Network

Obtain Dataset as the Overall System

Cost

Jaya

Optimization

Algorithm

Sparse

Neural

Network

Set the Algorithm Parameters

Compute the Objective Function

Evaluate Objective Function and Trim

Solution to Get the Best and Worst

Solutions

Accept and Replace

the Previous Solution

Is

the Termination Criterion Met?

Keep the Previous

Solution

Is

the Latter Objective Better than

the Former Objective ?

Yes No

Yes

No

Get the Optimized System Cost

Dense Network

Sparse Network

Obtain Dataset as the Overall System

Cost

Jaya

Optimization

Algorithm

Sparse

Neural

Network

Figure 4: The proposed ISNN consists of SNN and Jaya algorithm for minimizing the overall

system cost

ISNN model aims to re-parameterize the dense artiﬁcial neural networks (ANNs)

using only a small number of parameters Πs[33]. Πsis broken down into the

sparse matrix ΠL

s∈RnL−1nL, which is a connection between the two consecutive

layers L−1 and L. ISNN model is represented as −→

M=fs(Csys

k,Πs). The

sparsity of network is deﬁned as S= 1 −kΠsk0

kΠk0where kΠk0and kΠsk0are the

l0norm of Π and Πs, respectively [33]. The network is initialized as ΠL

s=

ΠL⊕BLwhere ⊕is the Hadamard product and BLis the binary mask. The

objective function, which is minimized using the Jaya optimization algorithm

[34] is deﬁned as

Π = min E(nL+nL−1)

nL+nL−1,(15)

where Eis a function whose output lies within R+. The probabilistic Π is a

hyperparameter to control the sparsity level S, i.e., when nL≥nL−1a lower

sparsity is obtained; otherwise, a higher sparsity is achieved. The non-essential

connections in each Lare pruned after training and the remaining connections

are described as Πs⊕(BL−−→

BL). Where the binary matrix size of −→

BL=BL, i.e.,

−→

BL⊆BL.||−→

BL||0=ξ||BL||0are the non-zero elements of BLthat correspond

to the largest negative weights and the smallest positive weights of ΠL

s.ξis

the pruning rate. Subsequently, the same number of connections with −→

BLare

23

randomly added to each layer and are deﬁned as ΠL

s+ΠL

r. Where ΠL

r∈RnL−1nL

has the same non-zero values of −→

BL. The non-zero ΠL

rvalues are derived using

a Gaussian noise. Finally, BLis updated using Eq. (16) [33].

BL=

1,if ΠL

s= 0

0,otherwise.

(16)

Note that the creation of new connections follows the trimming process of Jaya288

optimization algorithm [34]. We chose Jaya algorithm for sparsity operation289

over existing evolutionary optimization algorithms [33, 35] because it does not290

depend on the algorithm speciﬁc control parameters, such as mutation factor291

and crossover rate. However, population size should be determined carefully.292

3.4.2. Jaya based Optimization Algorithm293

At every time slot h, the objective function is to minimize Π. It is assumed

that there are znumber of decision variables and the number of solutions is

denoted by l. Within the solution set, the solution with the best value is deﬁned

as X∗

h, whereas the solution with the worst value is denoted by X∗∗

h. If we obtain

the value Xz,l,hin the lth solution for the zth decision during the hth time slot,

then we present the modiﬁed solution as [34]

X

0

z,l,h=Xz,l,h+r1X∗

z,h− |Xz,l,h|−r2X∗∗

z,h− |Xz,l,h|,(17)

where X∗

z,his the value of the zth decision for the best solution and X∗∗

z,his the294

value of the zth decision for the worst solution. X0

z,l,his the modiﬁed solution of295

Xz,l,hwhere r1and r2∈[0,1] are random numbers, which maintain the diversity296

from one solution of the population. The term r1(X∗

z,h− |Xz,l,h|) means that297

X0

z,l,happroaches the best solution while the term r2(X∗∗

z,h− |Xz,l,h|) implies298

that X0

z,l,hdeviates from the worst solution. If the best solution is obtained,299

then X0

z,l,his selected. At each time slot, all of the selected function values are300

retained and are used as the inputs for the next time slots.301

24

Start

Energy status

of buyer\

sellers

Buyers’ energy

demands are

broadcasted by

BM

Sellers

respond to the

requests

Pairs are made

for energy

trading

Energy

price is

computed

Check for abnormal

connection

Penalize the

responsible

prosumer

Prosumers’ engages in

mining tasks

Compute

prosumers’

satisfaction

and utility

Calculate

mining cost

of BMs

Check decision of

BMs

Perform

computations

locally

Compute

offloading cost

and threshold

If offloading <

threshold

Existing VM is

used

New VM is

used

End

No

yes

Yes

False

False

No

True

True

Figure 5: Flowchart proposed blockchain based energy trading system

3.4.3. Algorithm Implementation302

Based on the proposed mechanisms in Algorithm 1 and ﬂowchart 5, sellers303

and buyers submit information about their surplus and deﬁcit energy status to304

the blockchain, respectively. Using this information, BM broadcasts the energy305

demands of the buyers over the network. The sellers that meet the energy re-306

quirements respond to the blockchain. Once there is an established connection307

between the buyers and the sellers, BM computes the energy price. Afterward,308

the satisfaction and utility of the prosumers are calculated. If the prosumers309

wish to perform only normal tasks, then the tasks are completed locally. On310

25

the other hand, if the prosumers wish to perform both normal tasks and mining311

tasks, they upload the tasks to the corresponding BM. The BM checks the com-312

putational resources to decide whether to perform computational tasks locally313

or not. If BM has suﬃcient computational resources, then computations are314

performed locally; otherwise, BM purchases the server’s resources. Before the315

computation oﬄoading process, BM minimizes Csys

kusing the proposed ISNN.316

When an abnormal connection occurs from either buyers or sellers, a warning317

message, denoted as tr, is triggered and the energy trading transaction is initi-318

ated. The prosumers who initiate the abnormal connections are charged with319

some amount of energy tokens as a ﬁne. In the proposed algorithm, two ra-320

tionalities of prosumers are analyzed. First, prosumers can either be buyers321

or sellers and second, they are resource constrained. Therefore, our proposed322

mechanisms enable prosumers to trade energy trustfully in a P2P fashion.323

4. Privacy Preservation for Energy Prosumers324

The proposed system provides privacy to prosumers from the perspectives325

of the cloud and blockchain based systems. Motivated from [2], the privacy326

mechanism is designed.327

4.1. Privacy Preservation based on Blockchain328

The level of anonymity provided to each prosumer in the blockchain system329

depends on the number of pseudonyms that are generated for each transac-330

tion. It implies that the energy trading trends are completely hidden from331

each prosumer. Prosumers broadcast messages using pseudonyms rather than332

their real identities. In this study, a 14 bytes pseudonym, whose format is333

{IDn, Wt, EX Pd}, is designed. The pseudonym format ensures that the pseudonyms334

generated on the present date are diﬀerent from the pseudonyms generated on335

the previous date. I Dnis a random string of 7 bytes of length and Wtis the336

waiting time that indicates the length of time for which a new pseudonym337

is created. Also, it is the proportion of requests’ arrivals that are served.338

26

Algorithm 1: Algorithm of the proposed energy trading system

Initialize: Set SNN with Llayers, sparsity S, pruning rate ξ, the maximum number of

iterations dmax, decision of BM D,sand rare the indices of Π

Initialize: Set time h←1, ﬂag F: false and trigger tr: true

if tr == true then

An abnormal connection has occurred, pannalize the responsible prosumer

else

while Fand ∼tr do

for h←1 to Tdo

Get prosumers’ demand and supply information and calculate energy trading price

if Prosumers engage in local energy trading then

Calculate prosumers’ satisfaction and utility

tr: false

else

Calculate mining cost and minimize the overall system’s cost

for s←1 to Ldo

Set k←1 and ΠL

s←ΠL⊕BL

Set ΠL←Normalized(ΠL

s)

for r←1 to Ldo

Set ΠL←Πs⊕(BL−−→

BL) and ΠL

s←ΠL

s+ ΠL

r

end for

Get the best and worst solutions

repeat

Set r1, r2∈[0,1] and modify the solution

k←k+ 1

until k > dmax

end for

if ΠL

s←0then

F: true

end if

if D== 0 then

BM performs computations locally

Compute local computational cost

else

Purchase resources from the server

Calculate computation oﬄoading cost

end if

Calculate computation oﬄoading’s threshold

if Computation oﬄoading <threshold then

An existing VM is used

else

A new VM is used

end if

end if

end for

end while

end if

27

EX Pd= (current date + Wt) indicates the expected date when the pseudonym339

will expire. Note that the sizes of Wtand EXPdare 1 byte and 6 bytes, respec-340

tively.341

In this study, we consider the case when there are several requests for new342

pseudonyms in a queue, which is formulated as the queuing problem using Erlang343

[36]. Given the arrival rate of requests λ, the drop rate σand a departure344

rate µ, the length of the queue is deﬁned as Lq=λ−σ

µ. It implies that the345

exponential survival rate of those prosumers whose requests do not drop out346

during the waiting period is deﬁned as µ

λ= exp−Wtµwhere Wt=1

µln λ

µ. The347

present architecture of blockchain does not support transactions’ reversibility as348

there is a limited time to mitigate or address the occurrence of an attack [37].349

Furthermore, transaction reversal may erode conﬁdence in the system’s fairness,350

but a system that allows signiﬁcant losses due to bug exploitation would lose351

users. This raises the question of how will the system be able to recover the352

identities of the parties if false information (i.e., the wrong amount of energy353

demand or supply) occurs that needs to be traced. For tracing who provided the354

false information, BM uses the timestamp of the transaction that was created355

and the signature of the node who provided the false information. For identifying356

the node, the signature is veriﬁed using the pool of public keys in the system.357

The public key that matches the signature, identiﬁes the owner of the false358

information. Based on the consensus of mining nodes, the node that provides359

the false information is penalized by paying a ﬁne.360

4.2. Privacy Preservation based on Cloud System361

The proposed system enables BM to have two options: perform computa-362

tional tasks locally and request the services of a cloud system for computation363

oﬄoading. Multiple VMs are created at the server side to completely shield364

prosumers’ information. The proposed system calculates the computation of-365

ﬂoading threshold to determine whether a new VM should be used or not. The366

conﬁguration of the threshold follows a probability distribution. When BM’s367

computation oﬄoading is less than the threshold, the existing VM is used. Oth-368

28

erwise, a new VM is used. To determine the growth of computation oﬄoading,369

the maximum value is estimated and the threshold is obtained using the average370

method.371

The proposed system is secured by preserving the privacy of prosumers and372

authenticating them. Owing to this, the prosumers are authenticated anony-373

mously. In the proposed system, the prosumers generate both pseudonyms and374

digital signatures for all transactions. On successful authentication, the pro-375

sumers are allowed to trade energy. The privacy of prosumers is preserved376

when a pseudonym is generated. The dynamic generation of pseudonyms for all377

transactions protects prosumers from identity based attacks.378

5. Security Analysis379

This study analyzes a scenario where a miner node creates fake pseudonyms380

for getting more incentives [38]. This kind of attack is known as the Sybil attack.381

Deﬁnition 5.1 (Sybil Attack).Considering a graph Gwhere Sybil attack is382

applied to B, i.e., B={bm1, bm2, . . . , bmk} ∀383

k∈ |B|and the modiﬁcation of Gis G−={B−, Y −}. The Sybil attack occurs384

when a miner node in the network creates diﬀerent pseudonyms and assigns385

mining tasks to them for increasing incentives. This is important for the miner386

node as long as it receives more incentives from the created nodes than the exact387

amount of incentives received from legitimate block mining.388

A successful Sybil attack increases the incentives of the involved miner nodes389

via block mining within the network. The proﬁt of the Sybil attack is deﬁned390

as follows.391

Deﬁnition 5.2 (Proﬁt from Sybil Attack).Let rhoibe the Sybil attack on G

for k > 0and the assignment of a unit of mining task be T Mk. Let T MT +

be the total amount of mining tasks that a miner node khas to perform in the

network after the kth trial before the start of the Sybil attack. Let T M T −be

the total amount of mining tasks the miner nodes k∈ |B|or any of their Sybil

29

nodes obtained from the network. The proﬁt of this sequence of a Sybil attack

is deﬁned as [39]

supT M T +

T M T −, k ∈ |B|,if T M T −6= 0,(18)

if supremum sup is ∞, the Sybil attack is highly proﬁtable for an attacker,392

whereas if sup is greater than 1 and ﬁnite, the Sybil attack is weakly proﬁtable393

for the attacker. On the other hand, if sup is less than or equal to 1, the Sybil394

attack is not proﬁtable for the attacker. The proposed system is shown to be395

immune to the Sybil attack.396

Theorem 5.1. The Sybil attack is not a problem for the proposed system.397

Proof 5.1. The proof of Theorem 5.1 is as follows. Suppose there are several398

mining tasks to be performed by miner nodes in the network after kth step of the399

Sybil attack and T M T −for an individual unit of mining task that is allocated400

to a miner node kduring the attack, the capacities of some miner nodes in401

k∈ |B|that have contributed to the network must drop by 1 unit of the mining402

task. This implies that maximum one unit of mining task of T M T −can be403

contributed by a miner node in k∈ |B|after the kth step of the attack. Hence404

T M T +< T M T −. This explains that the proposed system is resistant to the405

Sybil attack with a proﬁt of no more than 1.406

In the proposed system, each pseudonym only contains a single identity of the407

node and it expires once mining and normal tasks are completed. Furthermore,408

the number of blocks in the network does not surpass the number of nodes. To409

this end, a collision attack is resolved for concurrent block mining. This study410

also determines the success probability of a legitimate node in the network to411

select one of the Sybil identities created by the attacker. Let πbe a deﬁned412

threshold for accomplishing the Sybil attack while an attacker has to create more413

than πidentities in the network. In this study, π=c∆ where cis the number414

of computational capacities of nodes and ∆ is the deﬁned consensus threshold.415

We denote mto be the number of successful Sybil identities and Nto be the416

number of legitimate node identities in the network. Then the total pool of417

30

identities comprises N+m−1 identities. Let wbe the number of identities418

that are selected from N+m−1 identities created during the initialization419

step. In each trial of the attack, the success probability is deﬁned as a function420

of the number of Sybil identities generated by the attacker, which is dispersed421

among diﬀerent valid nodes. The attacker fails to execute the Sybil attack if422

the number of Sybil identities generated by the attacker is less than π. The423

probability P[w] of randomly selecting wSybil identities from the whole pool424

of N+m−1 identities in each trial is deﬁned in Theorem 5.2.425

Theorem 5.2 (Analytical Analysis).If an attacker can create mSybil identities

during the kth trial, then the probability of randomly selecting wSybil identities

from the pool of N+m−1is deﬁned as

P[w] = m

wN−1

N−w

N+m−1

N.(19)

Proof 5.2. The proof of Theorem 5.2 is trivial from the fact that wfollows a426

hypergeometric distribution where m

w=m!

w!(m!−w!) is a binomial coeﬃcient.427

Theorem 5.3 (Numerical Analysis).Given that wSybil identities are created

by an attacker have been chosen from mSybil identities after the initialization

step. Then the probability of having atleast wSybil identities in a network is

deﬁned as

P[w] = c

wpw+ (1 −p)c−w,(20)

if m≤π, an attacker is not successful to perform Sybil attack. Hence,428

P[w] = 0. Besides, we consider the limit N, m → ∞ and m

N=pis ﬁxed. For429

the analysis, P(w) is determined for each identity created by attacker in the430

network.431

Proof 5.3. For the proof of Theorem 5.3, given the number of nodes in m,

the capacity of each node and the overall number of chosen identities for atleast

31

π+ 1 Sybil identities will be

P[w] = m

wN−m

c−w

N

c=m!

(m−c)!c!.(N−m)!

(m−c)!(N−m−c+w)!

.c!(N−c)!

N!=c

wm(m−1)(m−2) . . . (m−w+ 1)

N(N−1)(N−2) . . . (N−w+ 1).

(N−m)(N−m−1)

(N−w)(N−w−1) . . . (N−m−(c−w) + 1)

(N−c+ 1)

=m(m−1)(m−2) . . . (m−w+ 1)

N(N−1)(N−2) . . . (N−w+ 1) ≈mw

Nw=pw,

if wis ﬁxed, then mand Ndiverge while cis ﬁnite.

=(N−m)(N−m−1) . . . (N−m−(c−w) + 1)

(N−w)(N−w+ 1) . . . (N−c+ 1) ≈

(N−m)c−w

Nc−w= (N−m

N)c−w= (1 −p)c−w,

(21)

considering the binomial distribution, we have

lim

N,m→∞,m

N=pc

wpw(1 −p)c−w,(22)

if the limit holds, Theorem 5.3 is satisﬁed. Moreover, if w > c, it will be

considered in our future work. Considering the condition w≤c, then P[w+ 1]

is deﬁned as

P[w+ 1] = m

m

X

w=π+1

w

X

m=π+1 m

∆N−1

N−wm

wN−w

c−w

N+m−1

NN

c.(23)

For security analysis, a scenario is considered where a miner node generates fake432

identities to get more tasks in order to increase the incentives. The rest of the433

scenario is the same as mentioned in algorithm 1 and section 3.4.3. Moreover,434

the system is blockchain based, so jamming, hacking, fraud and theft are not435

possible by a single user. As all the nodes use pseudonyms for transactions;436

hence, they cannot cooperate to hack or jam the network. Fraud and theft437

are not possible because the transactional records are saved in a decentralized438

manner in blockchain and each transaction is conﬁrmed by the consensus of439

nodes. Moreover, unauthorized access is prevented by registering each node on440

the network with a unique identity.441

32

6. Socio-economic Impacts442

The proposed system is a blockchain based energy trading system. Blockchain443

is a disruptive technology. It is changing the ways of ﬁnancial dealing. Using444

blockchain, two parties can exchange anything without knowing each other and445

involving a third party. In short, it is a trustless technology where smart con-446

tracts take care of ﬂawless dealings. The proposed system is considered to have447

a revolutionary impact on sustainable cities and societies. The prominent im-448

pact of the system is on the economy because the transactional cost in the449

blockchain is signiﬁcantly lower than the traditional transactions. Other socio-450

economic impacts of the proposed blockchain based system include transparency,451

fairness, simplicity and regulation of rules while performing transactions. From452

the economical point of view, it is a decentralized system and leans towards a453

democratic system. Hence, it is a threat to the monopoly of the utility com-454

panies. Moreover, the low transactional cost of both data storage and trading455

between parties results in economic and ﬁnancial growth. The data stored in456

the blockchain is immutable, which results in data integrity. Therefore, the457

data stored on the blockchain is reliable and consistent. From the social point458

of view, all users or blockchain nodes get fair incentives and are treated equally.459

Moreover, all the transactions are automatic and controlled by smart contracts,460

so there are minimum or no disputes between users. Every legitimate and au-461

thorized user has the freedom of performing transactions and trading with other462

users without any discrimination. Furthermore, the trustless nature of the sys-463

tem makes it suitable and hassle-free for the users.464

It is a known fact that nothing is ﬂawless. Every technology or innovation465

has some limitations. Same is the case with a blockchain based system. In spite466

of all the above discussed advantages and positive socio-economic aspects, the467

proposed system too has some limitations. As mentioned above, the blockchain468

is an immutable technology, which ensures data integrity; however, if a false469

transaction is added or users want to reverse their transactions, the committed470

transactions are irreversible. Moreover, the blockchain is highly dependent on471

33

technology and complex to be deployed. So, its adaptability is also limited.472

One of the major challenges of the blockchain is dispute resolution between473

two parties. Although, rules for known disputes are deﬁned in the system,474

however, solving a unique dispute between two parties is only possible with the475

involvement of a third party.476

7. Simulations and Results477

The numerical results are used to test the performance of the proposed478

mechanisms in this section. The proposed solution is implemented in Python479

3.7, with details about the cloud system taken from [22, 23]. Moreover, the480

simulation setup is described as follows. In our scenario, prosumers within the481

same proximity are considered and they communicate with each other via SMs482

and the total number of seller and buyer prosumers is 200. However, this study483

is not limited to the above mentioned number of prosumers, it can accommodate484

an inﬁnite number of prosumers (Section 7.4). It is assumed that each seller485

has surplus energy between 75 MWh and 220 MWh and each energy deﬁcit486

prosumer requires energy within [20, 60] MWh [41]. Other parameters used for487

the simulations are provided in Table 3 [22] while some are randomly generated488

if not stated. We consider 5 VMs and the initial reward that is given to a489

miner for completing a task is 30 tokens. To design ISNN model, the network490

structure is given as [1,1000,1] with 1 input layer, 1000 dimensions and 1 output491

layer. The pruning rate ξ= 20 is used to control the sparsity of the network492

and the dimension of observations is 203×3312 [33]. For the Jaya optimization493

algorithm 1000, and the maximum and minimum limits of population values are494

1 and 0, respectively.495

7.1. Evaluation Metrics496

The following metrics are used for evaluating the proposed system.497

1. System cost: It is used as a metric to assess the proposed algorithm’s498

performance. A lower system cost means that the system is performing499

well.500

34

Table 3: Simulation parameters

P V P V

α0.7 Lk[20, 40] Gcycles

τ0.3 P rcr

k[1,5] ×10−6tokens/Gcycles

ρ0.7 dtk250 kbps

Tj3ULk[100, 1000] kB

tj2λ0.6

IR 0.5 σ0.2

β[1, 5] µ0.5

R[0, 1] ℵ[1 ×10−6,1×10−5]

HV M [20, 100] MHash/s I200

Hblk [1 ×103, 1 ×105] GHash/s J200

P: Parameters, V: Values.

2. Number of epochs: The proposed algorithm’s convergence rate and com-501

putation complexity are determined by the number of epochs. The algo-502

rithm converges better if the number of epochs is less.503

3. Trading cost: It is used to assess the eﬃcacy of a pricing policy plan. A504

lower trading price corresponds to a more favourable purchasing strategy.505

In this study, the limitations to be addressed are mapped to the proposed506

solutions, which are then validated by simulation results. The mapping of the507

proposed solutions to the limitations to be addressed is presented in Table 4.508

The table shows how the proposed solutions are validated.509

To overcome the limitation L1, blockchain is used to secure the prosumers’510

transactions and also provide trust between them. The privacy of each node’s511

transaction is achieved using the proposed multi-pseudonym mechanism.512

7.2. Evaluation of the Blockchain based Energy Trading System513

In this subsection, validations of the solutions to L2 are presented. To514

evaluate the performance of the proposed pricing policy, other existing pricing515

policies, such as time of use (ToU), critical peak pricing (CPP) and real-time516

35

Table 4: Validating solutions based on identiﬁed problems

Limitations to be ad-

dressed

Solutions proposed Validations

L1: Lack of security

and privacy

We have used consor-

tium blockchain and

cloud for achieving

security. Multi-

pseudonym is used for

privacy preservation

We have used multi-

pseudonym, anony-

mous authentication

and blockchain

L2: Ineﬃcient energy

pricing policy

An analytical energy

pricing policy based on

supply and demand ra-

tio is employed

Figs. 6, 7, 8 and

9 show the eﬃciency

of the proposed energy

pricing policy

L3: Problem of re-

source management

An ISNN with Jaya op-

timization algorithm is

used

Figs. 10, 11, 12, 13, 14

and 15 validate the eﬃ-

ciency of the proposed

ISNN

pricing (RTP) are used [3, 40]. As shown in Fig. 6, the proposed pricing policy

0 5 10 15 20 25

Time (hour)

0

20

40

60

80

100

120

140

Price ($ per MW)

Proposed

ToU

CPP

RTP

Figure 6: Analysis of energy price

517

36

has the minimum price for each hour as compared to its counterpart policies.518

The ﬁgure shows that from 11th to 16th interval, the electricity price using519

CPP is highest. The second peak in electricity price is observed in case of RTP.520

However, the peak of RTP during 6 to 10 is lower than CPP and the diﬀerence521

is huge. Moreover, the pricing peak of ToU is even lower than RTP. The results522

of the proposed pricing scheme depict that its price is lowest in almost all of the523

intervals. It implies that there is a minimum diﬀerence between energy supply524

and demand, which ultimately leads to a stable energy trading market.525

0 5 10 15 20 25

Time (hour)

0.0

0.2

0.4

0.6

0.8

1.0

Average Satisfaction

Proposed ToU CPP RTP

Figure 7: Analysis of prosumer’s satisfaction

Fig. 7 shows the buyers’ average satisfaction for 24 hours. From the ﬁgure, it526

is observed that our proposed pricing policy achieves the maximum satisfaction527

of approximately 90% as compared to 58% for ToU, 70% for CPP and 63% for528

RTP. It implies that on reduced energy price, buyers achieve a higher degree of529

satisfaction. However, it is observed from Fig. 6 for CPP that during the hours530

11 to 16, the electricity price is the highest while the satisfaction is relatively531

high in Fig. 7. It means that the cost of energy is low because of moderate532

energy demand. The same is the case with RTP during the hours 7 to 10.533

Moreover, the satisfaction of buyers implies that energy demand is equal to the534

energy supply. It also implies that the buyers’ satisfaction is inﬂuenced by the535

ability of the sellers to meet their energy demands with a minimum energy price.536

However, this satisfaction cannot be used as either prosumers’ proﬁt or utility.537

37

Therefore, the prosumers’ utility is analyzed in two cases as follows.

5 10 15 20

Time (hour)

0

200

400

600

800

1000

Buyer Average Utility

Proposed ToU CPP RTP

Figure 8: Evaluation of the utility of sellers

538

In the ﬁrst case, the buyers’ average utility values are given in Fig. 8. From539

the results, it is observed that our proposed pricing policy achieves high utility540

values as compared to other existing policies. The utility function shows the541

relationship between buyers’ satisfaction and their energy demands. Depending542

on the utility values, buyers decide whether to engage in energy trading with543

sellers or not. Once the buyers are unable to fulﬁll the energy need from the544

sellers, they purchase the required amount of energy from the main grid. More-545

over, in our case, we have no negative utility values, which implies that there546

are no cost negations. Besides, positive utility values may imply that the utility547

is proportional to satisfaction.548

In the second case, Fig. 9 shows the average utility values of the sellers.549

From the ﬁgure, it is observed that our proposed pricing policy achieves better550

and higher utility value as compared to other existing policies due to low energy551

price. Moreover, sellers’ satisfaction is determined by the number of rewards552

they received. Therefore, the utility values of sellers are proportional to their553

rewards. Hence, the proposed pricing policy is eﬀective for energy trading in a554

sustainable society.555

38

5 10 15 20

Time (hour)

0

20

40

60

80

100

Seller Average Utility

Proposed ToU CPP RTP

Figure 9: Evaluation of the utility of buyers

7.3. Evaluation of the Proposed ISNN Model556

In this subsection, validations of the solutions to L3 are presented. The557

proposed ISNN model aims to converge at a minimum number of epochs. Con-558

sidering the proposed mechanisms in Algorithm 1, the convergence of the system559

is important to determine whether the sparsity of the network is achieved or560

not. Moreover, the network is said to achieve convergence when the learning561

curve becomes smooth and ﬂat; therefore, the loss function is plotted against the562

number of epochs. In Fig. 10, the learning curve converges at 1 ×105epoch. It563

implies that the learning curve achieves optimality within an acceptable number564

of epochs.565

Fig. 11 shows the convergence analysis of the computation oﬄoading cost.566

It is observed that the initial cost is 0.957 token per kB. As the number of567

epochs increases, the computation oﬄoading cost increases to a peak of 1.0568

token per kB and then reduces afterwards due to optimization. It implies that569

the proposed system is eﬃcient to minimize the computation oﬄoading cost at570

an acceptable number of epochs.571

To evaluate the performance of the proposed system under diﬀerent sizes of572

data, i.e., 100-1000 kB, two performance parameters, such as average computa-573

tional cost and data transmission time, are considered. For the comparison with574

the existing schemes, deep reinforcement learning combined with genetic algo-575

39

0 1 2 3 4 5

Number of Epochs 105

0

0.2

0.4

0.6

0.8

1

1.2

1.4

Loss

Figure 10: Convergence analysis of ISNN

0 10 20 30 40 50

Number of Epochs

0.95

0.96

0.97

0.98

0.99

1

Offloading Cost (Token/kB)

Predicted

Target

Figure 11: Convergence analysis of oﬄoading cost

rithm (DRGO) [22], and sparse evolutionary training and multi-layer perceptron576

(SET-MLP) [33] are used.577

It is observed from Fig. 12 that our proposed scheme achieves the lowest578

average computational cost for long term decision making as compared to DRGO579

and SET-MLP schemes due to Jaya optimization algorithm. The ﬁgure shows580

that the system’s average computational cost increases with the increase in the581

size of the data to be uploaded.582

Fig. 13 shows the average data transmission time with diﬀerent sizes of data.583

It is obvious from the result that the average data transmission time increases584

with increase in the sizes of data. The results depict that our scheme performs585

40

100 300 500 700 900

Uploading Data Size (kB)

1.2

1.4

1.6

1.8

2

2.2

2.4

Average Cost (Token)

Proposed

DRGO

SET-MLP

Figure 12: Analysis of average system cost

100 300 500 700 900

Uploading Data Size (kB)

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Average Transmission Time (s)

Proposed

DRGO

SET-MLP

Figure 13: Analysis of average transmission time

better than DRGO and SET-MLP schemes based on the following reasons. Both586

DRGO and SET-MLP use genetic algorithm that requires algorithmic speciﬁc587

control parameters like mutation factor and crossover rate for tuning. These588

parameters aﬀect the processes of exploitation and exploration. Contrarily, our589

proposed scheme uses Jaya algorithm that does not depend on algorithmic spe-590

ciﬁc control parameter; however, it requires information related to population591

size only. Besides, its data transmission time is the lowest as compared to other592

schemes.593

Fig. 14 shows the comparison of average system cost, transmission cost594

and computation oﬄoading cost under diﬀerent sizes of data to be uploaded.595

41

100 300 500 700 900

Uplaoding Data Size (kB)

0

0.5

1

1.5

2

Average Cost (Token)

System Cost

Offloading Cost

Transmission Cost

Figure 14: Cost evaluation of the proposed system

It is observed from the ﬁgure that the average system cost is the highest as596

compared to computation oﬄoading cost and data transmission cost. Besides,597

average system, data transmission and computation oﬄoading costs are aﬀected598

by diﬀerent sizes of data.599

12345

Number of VMs

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Average Cost (Token)

0

2

4

6

8

10

MHash/s

105

Mining Cost

Blockchain Hash

Figure 15: Cost evaluation of blockchain

Fig. 15 shows the average cost for mining process of blockchain and hash600

under diﬀerent VMs. It is observed that each VM has distinct mining and hash601

cost in tokens. However, VM4 shows the lowest mining and hash cost due to602

the calculation of computational closeness.603

42

Table 5: Cost (Token) comparison of the proposed system for scalability evaluation

Average

data size

(kB)

N=200 N=400 N=600 N=800

100 1.29 2.46 3.76 5.02

200 1.35 2.68 4.05 5.21

300 1.4 2.9 4.2 5.32

400 1.45 2.943 4.31 5.43

500 1.48 3.1 4.35 5.49

600 1.56 3.02 4.68 6.14

700 1.6 3.25 4.8 6.38

800 1.65 3.29 4.94 6.7

900 1.72 3.39 5.08 6.87

1000 1.81 3.64 5.41 7.04

Average 1.499 3.0673 4.558 5.96

7.4. Performance Evaluation in Terms of Scalability604

A system is considered scalable if increasing values of one system parameter605

have a linear or no impact on other parameters. To ensure the scalability of606

the proposed system, the behavior of computational time and cost parameters607

is monitored against diﬀerent numbers of prosumers: 200, 400, 600 and 800.608

Table 5 shows that under diﬀerent numbers of prosumers, the increase in system609

cost (tokens) is linear. The ﬁrst column of the table contains diﬀerent sizes of610

data that are uploaded and the next four columns show the system cost against611

diﬀerent numbers of prosumers. The average cost of prosumers is also computed.612

It can be observed from the results that in the case of 200 prosumers, the average613

cost is 1.499 tokens. When the number of prosumers is increased to 400, the614

average system cost also increased up to 3.0673. Furthermore, for N= 600 and615

N= 800, the increments in system cost are 4.558 and 5.96, respectively. The616

experimental values show that there is no abrupt change in the system when617

43

Table 6: Transmission time (s) comparison of the proposed system for scalability evaluation

Average

data size

(kB)

N=200 N=400 N=600 N=800

100 0.01 0.021 0.03 0.039

200 0.03 0.05 0.091 0.11

300 0.045 0.10 0.135 0.178

400 0.05 0.11 0.17 0.21

500 0.1 0.19 0.32 0.4

600 0.12 0.21 0.37 0.50

700 0.15 0.28 0.44 0.61

800 0.2 0.38 0.61 0.78

900 0.23 0.42 0.69 0.90

1000 0.25 0.47 0.76 0.95

Average 0.1185 0.2291 0.3616 0.4677

the number of users is increased. Similarly, Table 6 shows the transmission618

cost of the proposed system against diﬀerent numbers of prosumers: 200, 400619

and 800. The ﬁrst column shows the average data size of prosumers and the620

next three columns show diﬀerent numbers of prosumers. The average data621

transmission time (s) is also computed to demonstrate the eﬀect of the increasing622

number of users. The results depict that the increase in data transmission time623

is linear. The transmission time increases with prosumers because the data to624

be transmitted is also increasing with each prosumer. Hence, the results prove625

that the proposed system is scalable.626

Energy management is important for smart and sustainable cities. With627

increases in computational requests, the energy consumption also increases.628

Moreover, eﬃcient utilization of resources has a great impact on energy con-629

sumption. Table 7 shows the resource utilization in percentage and the corre-630

sponding energy consumption of a processor. It is observed that initially, the631

44

Table 7: Average energy consumption (joules) comparison of the proposed scheme with respect

to resource utilization

Resource utilization Energy consumption

(jouls)

10% 0.07

20% 0.1

30% 0.18

40% 0.2

50% 0.22

60% 0.3

70% 0.4

80% 0.53

90% 0.8

100% 1.4

Table 8: Average energy consumption (joules) comparison of the proposed system for scala-

bility evaluation

Average

data size

(kB)

N=200 N=400 N=600 N=800

200 0.2 0.41 0.59 0.81

250 0.3 0.61 0.88 1.23

300 0.4 0.78 1.25 1.79

350 0.6 1.23 1.99 2.62

400 0.9 1.91 2.79 3.91

450 1.35 2.82 4.38 5.7

500 1.91 3.85 5.88 7.95

Average 0.8086 1.83 2.794 3.529

45

energy consumption shows linear behavior with resource utilization. However,632

when the resource utilization reaches 70%, the increase in energy consumption633

becomes non-linear. The abrupt increasing behavior is observed, which indi-634

cates that when a processor is overburdened, it consumes more energy than635

usual. So, computation oﬄoading has great importance. Similarly, Table 8636

shows the energy consumption of the proposed scheme when the numbers of637

users increase from 200 to 800 with step sizes of 200. The table shows that638

the energy consumption increases non-linearly when data size increases. The639

average is also taken for diﬀerent numbers of prosumers. On comparing the640

average energy consumption values, it is observed that the change in energy641

consumption is high. The reason is that 200 users are increased on each step,642

so the corresponding requests also increase with the same rate and so does the643

data size. Moreover, the resource utilization also increases, which results in high644

energy consumption. The results depict the trade-oﬀ of the proposed system.645

However, as mentioned above, for eﬃcient resource utilization and reduce the646

computational burden from the processor, computation oﬄoading is employed647

in the proposed system. Hence, the scalability of the system is not aﬀected by648

high energy consumption.649

7.5. Security Analysis650

This study evaluates the Sybil attack by performing extensive numerical sim-651

ulations, which are compared with analytical results. The probability of success652

for selecting Sybil identities generated by an attacker is evaluated regarding653

block hash rate. Moreover, the block hash rate is computed as the ratio of the654

hash power of the attacker to the overall hash power of the network. For the655

analysis, the diﬀerent numbers of Sybil identities (m) are considered. This study656

begins by analyzing the network of N= 14 nodes with a sample of m= 4 nodes657

and the capacity cof 3 nodes. Fig. 16 shows the probability of a successful Sybil658

attack using the aforementioned parameters. It is observed that as the block659

hash rate increases, the analytical and numerical results do not align with each660

other. This occurs as a result of π. Moreover, both numerical and analytical661

46

results satisfy Theorem (5.2) and (5.3).662

0 0.2 0.4 0.6 0.8 1

Adversary Hash Rate

0

0.1

0.2

0.3

0.4

0.5

Probability of Success

Analytical Result

Numerical Result

Figure 16: Sybil attack when N= 14 and m= 4

0 0.2 0.4 0.6 0.8 1

Adversary Hash Rate

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

Probability of Success

Analytical Result

Numerical Result

Figure 17: Sybil attack when N= 200 and m= 4

As we increase the number of nodes up to 200 (N= 200) as shown in Fig.663

17, it is obvious that the analytical and numerical results align with each other.664

This means that the proposed analytical results follow the same pattern as nu-665

merical results. Fig. 18 shows the patterns of the probability of a successful666

Sybil attack as the number of samples increases. For this scenario, the capacity667

of nodes in mis c= 100 and diﬀerent samples m, such as 4, 8 and 10 are consid-668

ered. It is observed that as the number of samples (m) increases, the probability669

of a successful Sybil attack reduces. This means that the proposed system can670

47

0 0.2 0.4 0.6 0.8 1

Adversary Hash Rate

0

0.1

0.2

0.3

0.4

0.5

Probability of Success

m=4

m=8

m=10

Figure 18: Sybil attack when N= 200, and m= 4,8 and 10

tackle Sybil identities that are created by an attacker. In normal cases, when the671

number of Sybil identities increases, it increases the probability of the selection672

of more Sybil identities from the selection pool N+m-1. However, increasing673

the number of identities involves high computational power to complete multi-674

ple tasks in the proposed system. Furthermore, a time limit is also deﬁned for675

task completion. The computational power of the miner nodes is not unlimited.676

Moreover, getting cloud resources involves additional costs. Hence, increasing677

the Sybil identities weakens the attacker’s computational power and the prob-678

ability of success decreases. Fig. 18 proves that the proposed system is robust679

against Sybil attacks.680

8. Conclusion681

This paper proposes a secure energy trading system based on blockchain682

for residential homes. Firstly, an analytical energy pricing policy is designed683

to solve the problem of existing energy pricing policies in a distributed en-684

ergy trading environment. Secondly, the security of prosumers is ensured us-685

ing the consortium blockchain. The privacy of prosumers is preserved in the686

blockchain using the proposed multi-pseudonym mechanism. In this mecha-687

nism, each transaction requires a distinct pseudonym. Thirdly, a strategy is688

proposed that allows prosumers to either compute tasks locally or oﬄoad them689

48

to the cloud system. In the strategy, an ISNN is designed to achieve compu-690

tation oﬄoading eﬃciency. It also integrates the Jaya optimization algorithm,691

which reduces the number of connections between diﬀerent layers of neurons and692

speeds up the error convergence rate. The strategy ensures the scalability of the693

system.. At last, in the cloud system, a new VM is only used when the com-694

putation oﬄoading task is greater than its deﬁned threshold. Security analysis695

shows that the proposed system prevents Sybil attacks. Simulation results val-696

idate the performance of the proposed scheme. From the results, it is observed697

that the proposed pricing policy shows the least average energy price and the698

highest average maximum utility as compared to ToU, CPP and RTP pricing699

policies. Also, a buyer achieves approximately 90% average satisfaction using700

the proposed pricing policy as compared to 58% with ToU, 70% with CPP and701

63% with RTP. Under diﬀerent sizes of data, ISNN has the least average compu-702

tational cost and data transmission time as compared to DRGO and SET-MLP703

schemes. Furthermore, the convergence of the proposed scheme is achieved at704

1×105epoch. Besides, extensive simulations are performed to check the scala-705

bility of the system under increasing number of prosumers. The results depict706

that the system is scalable because on increasing the number of prosumers, the707

change in transmission cost and system cost is linear. Contrarily, the increase708

in energy consumption becomes nonlinear after a certain point. It is considered709

as the trade-oﬀ of the system. However, the proposed work tackles this issue710

by computation oﬄoading where BM oﬄoads the computational tasks to cloud711

server. Hence, scalability of the system is not aﬀected.712

The robustness of the proposed PoCC will be thoroughly investigated in713

the future to increase network throughput. We also plan to partner with a714

utility operator to incorporate and test our proposed system’s prototype. This715

will allow us to assess its real-world usefulness and scalability more accurately.716

Moreover, the proposed system will be tested in inter-blockchain communication717

scenario where energy will be traded among prosumers of diﬀerent communities.718

49

References719

[1] A. S. Yahaya, N. Javaid, F. A. Alzahrani, A. Rehman, I. Ullah, A. Shahid,720

and M. Shaﬁq. “Blockchain based sustainable local energy trading consid-721

ering home energy management and demurrage mechanism.” Sustainability,722

vol. 12, no. 8, pp 1-28, 2020.723

[2] G. Keke, Y. Wu, L. Zhu, M. Qiu and M. Shen,“Privacy-preserving energy724

trading using consortium blockchain in smart grid,” IEEE Transactions on725

Industrial Informatics, vol. 15, no. 6, pp. 3548-3558, 2019.726

[3] S. Omaji, S. Javaid, N. Javaid, S. H. Ahmed, M. K. Afzal and F. Ishmanov,727

“An eﬃcient power scheduling in smart homes using Jaya based optimization728

with time-of-use and critical peak pricing schemes,” Energies, vol. 11, no.729

11, pp. 1-27, 2018.730

[4] D. Ali, F. Luo, S. S. Kanhere, R. Jurdak and Z. Y. Dong, “SPB: A se-731

cure private blockchain-based solution for distributed energy trading,” IEEE732

Communications Magazine, vol. 57, no. 7, pp. 120-126, 2019.733

[5] W. Shen, A. F. Taha, J. Wang, K. Kvaternik and A. Hahn, “Energy crowd-734

sourcing and peer-to-peer energy trading in blockchain-enabled smart grids,”735

IEEE Transactions on Systems, Man, and Cybernetics: Systems, vol. 49, no.736

8, pp. 1612-1623, 2019.737

[6] R. Khalid, N. Javaid, A. Almogren, M. U. Javed, S. Javaid and M. Zuair, “A738

blockchain based load balancing in decentralized hybrid P2P energy trading739

market in smart grid”, IEEE Access, vol. 8, pp. 47047-47062, 2020.740

[7] A. Sadiqi, M. U. Javed, R. Khalid, A. Almogren, M. Shaﬁq and N. Javaid,741

“Blockchain based Data and Energy Trading in Internet of Electric Vehi-742

cles”, IEEE Access, vol. 9, pp. 7000-7020, 2021.743

[8] S. Saurabh, P. K. Sharma, B. Yoon, M. Shojafar, G. H. Cho and I. Ra,744

“Convergence of blockchain and artiﬁcial intelligence in IoT network for the745

sustainable smart city,” Sustainable Cities and Society, 63, 1-16, 2020.746

50

[9] A. Sheikh , V. Kamuni, A. Urooj, S. Wagh, N. Singh and D. Patel, “Secured747

energy trading using byzantine-based blockchain consensus,” IEEE Access748

8, pp.8554-8571, 2020.749

[10] C. Rajat, A. Jindal, G. S. Aujla, S. Aggarwal, N. Kumar and K. R. Choo,750

“BEST: Blockchain-based secure energy trading in SDN-enabled intelligent751

transportation system,” Computers & Security, 85, pp.288-299, 2019.752

[11] E. Ayman, M. de Vos, Y. Ghiassi-Farrokhfal, P. Palensky and D. Epema.753

“A novel decentralized platform for peer-to-peer energy trading market with754

blockchain technology,” Applied Energy, 282, pp. 1-16, 2021.755

[12] J. Anish, G. S. Aujla and N. Kumar, “SURVIVOR: A blockchain based756

edge-as-a-service framework for secure energy trading in SDN-enabled757

vehicle-to-grid environment,” Computer Networks, 153, pp.36-48, 2019.758

[13] W. Shifan, W. Xiong, J. Tan, S. Chen and Q. Li, “Blockchain enhanced759

price incentive demand response for building user energy network in sustain-760

able society,” Sustainable Cities and Society, 68, 1-10, 2021.761

[14] Z. Jianli, Y. Wu, F. Liu, Y. Tao and J. Gao, “Prospects and obstacles762

analysis of applying blockchain technology to power trading using a deeply763

improved model based on the DEMATEL approach,” Sustainable Cities and764

Society, 1-20, 2021.765

[15] X. Weicheng, J. Li, M. Dehghani, and M. GhasemiGarpachi. “Blockchain-766

based secure energy policy and management of renewable-based smart mi-767

crogrids.” Sustainable Cities and Society, pp. 1-9, 2021.768

[16] P. Zhiping, J. Lin, D. Cui, Q. Li and J. He, “A multi-objective trade-769

oﬀ framework for cloud resource scheduling based on the Deep Q-network770

algorithm,” Cluster Computing, pp. 1-15, 2020.771

[17] H. M. Askarizade, M. Maeen and M. Haghparast, “An energy-eﬃcient772

dynamic resource management approach based on clustering and meta-773

51

heuristic algorithms in cloud computing IaaS platforms,” Wireless Personal774

Communications, vol. 104, no. 4, pp. 1367-1391, 2019.775

[18] V. Amandeep and S. Kaushal, “A hybrid multi-objective particle swarm776

optimization for scientiﬁc workﬂow scheduling,” Parallel Computing, vol. 62,777

pp. 1-19, 2017.778

[19] H. Liang, X. Feng, C. Zhang, L. Qian and Y. Wu, “Deep reinforcement779

learning-based joint task oﬄoading and bandwidth allocation for multi-user780

mobile edge computing,” Digital Communications and Networks, vol. 5, no.781

1, pp. 10-17, 2019.782

[20] H. Liang, X. Feng, A. Feng, Y. Huang and L. P. Qian, “Distributed deep783

learning-based oﬄoading for mobile edge computing networks,” Mobile Net-784

works and Applications, pp. 1-8, 2018.785

[21] L. Zhenni, Z. Yang and S. Xie, “Computing resource trading for edge-cloud-786

assisted Internet of Things,” IEEE Transactions on Industrial Informatics,787

vol. 15, no. 6, pp. 3661-3669, 2019.788

[22] Q. Xiaoyu, L. Liu, W. Chen, Z. Hong and Z. Zheng. “Online deep reinforce-789

ment learning for computation oﬄoading in blockchain-empowered mobile790

edge computing.” IEEE Transactions on Vehicular Technology, vol. 68, no.791

8, pp. 8050-8062, 2019.792

[23] C. Wuhui, Z. Zhang, Z. Hong, C. Chen, J. Wu, S. Maharjan, Z. Zheng793

and Y. Zhang. “Cooperative and distributed computation oﬄoading for794

blockchain-empowered industrial Internet of Things.” IEEE Internet of795

Things Journal, vol. 6, no. 5, pp. 8433-8446, 2019.796

[24] L. Mengting, F. R. Yu, Y. Teng, V. C. Leung and M. Song, “Computation797

oﬄoading and content caching in wireless blockchain networks with mobile798

edge computing,” IEEE Transactions on Vehicular Technology, vol. 67, no.799

11, pp. 11008-11021, 2018.800

52

[25] C. Dimitris, M. Ahmadi, S. Kosta and P. Hui, “Flopcoin: A cryptocurrency801

for computation oﬄoading,” IEEE Transactions on Mobile Computing, vol.802

17, no. 5, pp. 1062-1075, 2017.803

[26] W. Weizhong, T. Ma and J. Liu, “Resistance Distance and Kirchhoﬀ Index804

of Q-Double Join Graphs,” IEEE Access, vol. 7, pp. 102313-102320, 2019.805

[27] R. Khalid, O. Samuel, N. Javaid, A. Aldegheishem, M. Shaﬁq, N. Alra-806

jeh “A Secure Trust Method for Multi-agent System in Smart Grids using807

Blockchain”, IEEE Access, Vol. 9, pp. 59848-59859, 2021.808

[28] R. El-Azab, ”Smart homes: potentials and challenges.” Clean Energy 5,809

no. 2, pp. 302-315, 2021.810

[29] S. Gang, M. Dai, F. Zhang, H. Yu, X. Du, and M. Guizani, “Blockchain-811

Enhanced High-Conﬁdence Energy Sharing in Internet of Electric Vehicles.”812

IEEE Internet of Things Journal, 7, no. 9, pp. 7868-7882, 2020.813

[30] A. G. Singh, N. Kumar, M. Singh and A. Y. Zomaya, “Energy trading with814

dynamic pricing for electric vehicles in a smart city environment.” Journal815

of Parallel and Distributed Computing, vol. 127, pp. 169-183, 2019.816

[31] K. J. J., D. Djordjevi and D. Cvetkovi, “MoorePenrose inverse in rings817

with involution,” Linear Algebra and its Applications, vol. 426, no. 2-3, pp.818

371-381, 2007.819

[32] A. O. Isaac, A. Jantan, A. E. Omolara, K. V. Dada, N. A. Mohamed820

and H. Arshad, “State-of-the-art in artiﬁcial neural network applications: A821

survey.” Heliyon, vol. 4, no. 11, pp. 1-41, 2018.822

[33] L. Shiwei, D. C. Mocanu, A. R. R. Matavalam, Y. Pei and M. Pechenizkiy,823

“Sparse evolutionary deep learning with over one million artiﬁcial neurons824

on commodity hardware,” Neural Computing and Applications, pp. 1-16,825

2020.826

53

[34] R. Rao, “Jaya: A simple and new optimization algorithm for solving con-827

strained and unconstrained optimization problems,” International Journal828

of Industrial Engineering Computations, vol. 7, no. 1, pp. 19-34, 2016.829

[35] M. D. Constantin, E. Mocanu, P. Stone, P. H. Nguyen, M. Gibescu and A.830

Liotta, “Scalable training of artiﬁcial neural networks with adaptive sparse831

connectivity inspired by network science,” Nature communications, vol. 9,832

no. 1, pp. 1-12, 2018.833

[36] A. Giacomo, N. Leonenko and E. Pirozzi, “Fractional Erlang queues,”834

Stochastic Processes and their Applications, vol. 130, no. 6, pp. 3249-3276,835

2020.836

[37] P. Joana, M. M. Tavalaei and H. Ozalp, “Blockchain-based platforms: De-837

centralized infrastructures and its boundary conditions,” Technological Fore-838

casting and Social Change, 146, 94-102, 2019.839

[38] L. Raul, D. Griﬃn, R. G. Clegg, E. Mykoniati and M. Rio, “A sybilproof840

indirect reciprocity mechanism for peer-to-peer networks,” In IEEE INFO-841

COM 2009, Rio de Janeiro, Brazil, pp.343-351, 2009.842

[39] O. Pim, M. de Vos and J. Pouwelse, “TrustChain: A Sybil-resistant scalable843

blockchain,” Future Generation Computer Systems, 107, 770-780, 2020.844

[40] D. Yeming, Y. Gao, H. Gao and H. Zhu, “Real-time pricing scheme based845

on Stackelberg game in smart grid with multiple power retailers,” Neuro-846

computing, vol. 260, pp. 149-156, 2017.847

[41] W. Yunpeng, W. Saad, Z. Han, H. V. Poor and T. Baar, “A game-theoretic848

approach to energy trading in the smart grid,” IEEE Transactions on Smart849

Grid, vol. 5, no. 3, pp. 1439-1450, 2014.850

54