Method and system for protecting privacy in microgrids based on homomorphic encryption algorithm
A method for protecting privacy in microgrids based on a homomorphic encryption algorithm and relates to the technical field of microgrid control includes: designing a distributed cooperative control method for a microgrid based on distributed control theory, to achieve frequency restoration of a microgrid; defining a technical essence of privacy protection and a scope of privacy protection; designing a method for protecting privacy in microgrids based on a homomorphic encryption algorithm according to defined technical essence of privacy protection and scope of privacy protection, and protecting initial and real-time values of each distributed power source in the microgrid from disclosure to neighbor nodes, to achieve a distributed cooperative control objective in the microgrid; and verifying the method for protecting privacy in microgrids based on the homomorphic encryption algorithm through simulation experiments. The method enhances trustworthy monitoring capabilities and privacy security during distributed cooperative operation of microgrids.
1 . A method for protecting privacy in microgrids based on a homomorphic encryption algorithm, comprising:
S 1 : designing a distributed cooperative control method for a microgrid based on a distributed control theory, to achieve frequency restoration of the microgrid;
wherein in S 1 , the designing the distributed cooperative control method for the microgrid comprises:
an expression for droop control in the microgrid is given by:
ω
i
=
ω
n
i
-
m
p
i
P
i
(
1
)
wherein, ω i is an output frequency value of a distributed power source i, ω ni is a frequency setting of the distributed power source i, P i is an output active power value of the distributed power source i, and m pi is a droop control coefficient of the distributed power source i;
a specific expression for a frequency restoration target of the microgrid is given by:
lim
t
→
∞
ω
i
=
ω
r
e
f
(
2
)
wherein, ω ref is a frequency reference value;
based on the distributed control theory, the frequency setting of each distributed power source depends exclusively on topologically interconnected neighbor of the distributed power source, designing a frequency setting point ω ni to restore frequencies of distributed power sources to a reference value, and an expression for the frequency setting point ω ni is given by:
ω
i
=
ω
n
i
-
m
p
i
P
i
+
u
ω
i
+
u
P
i
(
3
)
wherein, u ωi and u Pi are a frequency control input and an active power control input for the distributed power source i, respectively;
u ωi is given by:
u
ω
i
=
-
k
ω
i
∑
j
∈
N
i
a
i
j
(
ω
i
-
ω
j
)
-
k
ω
i
g
i
(
ω
i
-
ω
r
e
f
)
(
4
)
wherein, ω j is an output frequency value of a distributed power source j, k ωi is a frequency control gain of the distributed power source j, g i is a frequency-dependent root gain of the distributed power source j, a ij is a connection gain between the distributed power source i and the distributed power source j, and N i is a neighbor set of the distributed power source i;
u Pi is given by:
u
P
i
=
-
k
P
i
∑
j
∈
N
i
a
i
j
(
m
p
i
P
i
-
m
p
j
P
j
)
(
5
)
wherein, P j is an output active power value of the distributed power source j, m pj is a droop control coefficient of the distributed power source j, and k Pi is an active power control gain of the distributed power source i;
S 2 : defining a technical essence of privacy protection and a scope of privacy protection;
S 3 : designing a method for protecting privacy in the microgrids based on the homomorphic encryption algorithm according to the technical essence of privacy protection and the scope of privacy protection, and protecting initial and real-time values of each distributed power source in the microgrid from disclosure to neighbor nodes, to achieve a distributed cooperative control objective in the microgrid;
wherein a Paillier homomorphic encryption algorithm exhibits homomorphic addition and homostatic scalar multiplication properties, as expressed by:
E
i
(
P
i
)
·
E
i
(
P
j
)
=
E
i
(
P
i
+
P
j
)
,
(
8
)
E
i
(
P
i
)
τ
=
E
i
(
τ
·
P
i
)
,
wherein, E i (P i ) τ equals E i (P i ) raised to a power of τ
wherein the method for protecting privacy in the microgrids based on the homomorphic encryption algorithm comprises:
S 301 : the connection gain a ij is known to both the distributed power source i and the distributed power source j, according to Formula (6), randomly splitting a ij into a i→j ∈Z + and a j→i ∈Z + ;
S 302 : generating a public key
(
pk
i
[
1
]
,
pk
i
[
2
]
)
,
constructing a private key
(
sk
i
[
1
]
,
sk
i
[
2
]
)
,
and computing a ciphertext E i (ω i (t)) according to the Paillier homomorphic encryption algorithm, according to Formula (8), to obtain:
E
i
(
ω
i
(
t
)
)
-
1
=
E
i
(
-
ω
i
(
t
)
)
(
9
)
for the distributed power source i, transmitting a data packet
{
E
i
(
-
ω
i
(
t
)
)
,
pk
i
[
1
]
,
pk
i
[
2
]
}
to the distributed energy resource j, meanwhile, encrypting, by the distributed energy resource j, a frequency value with the public key, to obtain E i (ω i (t)); and
S 303 : applying the public key
(
pk
i
[
1
]
,
pk
i
[
2
]
)
and a unilateral connection gain a j→i ∈Z + , to obtain:
E
i
(
-
ω
i
(
t
)
)
·
E
i
(
ω
j
(
t
)
)
=
E
i
(
ω
j
(
t
)
-
ω
i
(
t
)
)
,
(
10
)
E
i
(
ω
j
(
t
)
-
ω
i
(
t
)
)
a
j
→
i
=
E
i
(
a
j
→
i
·
(
ω
j
(
t
)
-
ω
i
(
t
)
)
)
,
transmitting Formula (10) to the distributed power source i, decrypting E i (a j→i ·(ω j (t)−ω i (t))) into a j→i ·(ω j (t)−ω i (t)) by the distributed power source i, then multiplying by the unilateral connection gain a i→j ∈Z + , to obtain a i→j ·a j→i ·(ω j (t)−ω i (t)) i.e. a ij ·(ω j (t)−ω i (t)), and performing distributed coordination in the microgrid by the distributed power source i with Paillier homomorphic encryption without accessing information of the distributed power source j; and
S 4 : verifying the method for protecting privacy in the microgrids based on the homomorphic encryption algorithm through simulation experiments.
2 . The method for protecting privacy in the microgrids based on the homomorphic encryption algorithm according to claim 1 , wherein S 2 comprises: defining the technical essence of privacy protection and the scope of privacy protection, and protecting data of each distributed power source from disclosure to the neighbor nodes during computational participation, wherein the scope of privacy protection covers true values of both initial values and real-time values of each distributed power source participating in computations.
3 . The method for protecting privacy in the microgrids based on the homomorphic encryption algorithm according to claim 1 , wherein S 3 comprises: protecting the initial and real-time values of each distributed power source in the microgrid from disclosure to the neighbor nodes, and defining the connection gain a ij as:
a
ij
=
a
i
→
j
·
a
j
→
i
∀
i
,
j
∈
V
,
(
6
)
a
i
→
j
∈
[
a
_
,
a
_
]
a
j
→
i
∈
[
a
_
,
a
_
]
,
0
≤
a
_
≤
a
_
≤
1
max
{
❘
"\[LeftBracketingBar]"
N
i
-
❘
"\[RightBracketingBar]"
,
❘
"\[LeftBracketingBar]"
N
i
+
❘
"\[RightBracketingBar]"
}
,
wherein, a i→j ∈Z + and a j→i ∈Z + are unilateral gains randomly generated for the distributed power source i and the distributed power source j, respectively, Z + is a set of positive integers,
❘
"\[LeftBracketingBar]"
N
i
+
❘
"\[RightBracketingBar]"
and
❘
"\[LeftBracketingBar]"
N
i
-
❘
"\[RightBracketingBar]"
are an in-degree matrix and an out-degree matrix of the distributed power source i, respectively, a and ā are a minimum value and a maximum value of the connection gain, respectively, V={1, 2, . . . n}, and n is a total number of distributed power source.
4 . The method for protecting privacy in the microgrids based on the homomorphic encryption algorithm according to claim 3 , wherein
P
i
κ
represents data to be encrypted, and the Paillier homomorphic encryption algorithm comprises:
initialization: in a Paillier homomorphic encryption cryptosystem, both a ciphertext C i and a plaintext P i are positive integers, prior to applying the encryption method, according to the equation
P
i
=
1
0
κ
·
P
i
κ
,
converting
P
i
κ
to an integer P i , wherein k denotes a number of decimal places retained;
generating public key and private key: randomly selecting two large prime numbers p and q of identical bit-length, satisfying:
gcd
(
pq
,
(
p
-
1
)
(
q
-
1
)
)
=
1
wherein, gcd(⋅) is a greatest common divisor function;
defining the public key as
(
pk
i
[
1
]
,
pk
i
[
2
]
)
,
and the private key as
(
sk
i
[
1
]
,
sk
i
[
2
]
)
,
wherein,
pk
i
[
1
]
=
pq
,
sk
i
[
1
]
=
lcm
(
p
-
1
,
q
-
1
)
,
lcm(⋅) is a least common multiple function,
pk
i
[
2
]
∈
Z
n
+
is arbitrarily selected, provided that
n
=
pk
i
[
1
]
·
pk
i
[
1
]
and
Z
n
+
=
{
z
❘
z
∈
Z
⋂
[
0
,
n
)
,
gcd
(
z
,
n
)
=
1
}
are satisfied;
sk
i
[
2
]
=
L
(
(
pk
i
[
2
]
)
λ
mod
n
)
-
1
mod
pk
i
[
1
]
;
wherein
L
(
x
)
=
x
-
1
pk
i
[
1
]
,
mod denotes a modulo operation; λ=lcm(p−1, q−1);
encrypting: the ciphertext satisfies
C
i
=
E
i
(
P
i
)
=
(
pk
i
[
2
]
)
P
i
·
r
pk
i
[
1
]
mod
n
,
wherein, r∈Z + , 0<r<n, E i (⋅) is an encryption function;
decrypting: the plaintext satisfies
P
i
=
D
i
(
C
i
)
=
L
(
(
C
i
)
s
k
i
[
1
]
mod
n
)
·
sk
i
[
2
]
mod
pk
i
[
1
]
,
wherein D i (⋅) is a decryption function; and
deinitialize: derive a plaintext
P
i
κ
according to the plaintext P i , and a specific expression is:
P
i
κ
=
{
P
i
/
10
κ
if
0
≤
P
i
≤
1
2
(
pk
i
[
1
]
-
1
)
(
P
i
-
pk
i
[
1
]
)
/
10
σ
if
1
2
(
pk
i
[
1
]
+
1
)
≤
P
i
≤
pk
i
[
1
]
.
(
7
)
5 . The method for protecting privacy in the microgrids based on the homomorphic encryption algorithm according to claim 1 , wherein in S 4 , in the simulation experiments, the microgrid is modeled using a MATLAB toolbox, while the Paillier homomorphic encryption algorithm is executed via a Python implementation.