The loop strats by setting the counter c to 1. Send M as message to the
SHA-1 function described in section 3, and store the digest as S. Obviously, S
is a 20-byte octet stream, denoted as
S = S
19
S
18
· · · S
1
S
0
in network order, where S
i
(i ∈ {0, 1, · · · , 18, 19}) are the bytes.
Assume k is another octet stream, with zero-length before the loop starts.
The most least two bytes of S will be taken to append to the left side of k:
k = S
1
∥ S
0
∥ k
Repeat this process for 15 rounds, after each round increment c by 1 and
update to M.
If the digest after the i-time loop is denoted as S
i
, the final k after all 15
round will looks like:
k = S
15
1
S
15
0
S
14
1
S
14
0
· · · S
2
1
S
2
0
S
1
1
S
1
0
and this is the private key we generated.
To verify the key generator, check if an empty message input generates
k = k
0
, and k
0
described as follows:
k
0
= 59FE6ABCCA90BDB95F0105271FA85FB9F11F467450C1AE9044B7FD61D65E
4.3.2 The Public Key
As the base point G on the elliptic curve is known (section 4.2), the public key
is calculated by multiplying the private key k to the base point, according to
elliptic curve arithmetics
P = k · G
To verify if the key generator works well, generate P = P
0
from k
0
(which is described before), and check
P
0
= (x
P
, y
P
)
x
P
= 3861220ED9B36C9753DF09A159DFB148135D495DB3AF8373425EE9A28884BA1A
y
P
= 12B64E62DB43A56114554B0CBD573379338CEA9124C8443C4F50E6C8B013EC20
A public key compress method is used by the SM2 digital signature algo-
rithm. But WinRAR followed only some simplified steps:
1. Let P = (x
P
, y
P
) on the elliptic curve. if x
P
= 0, ˜y
P
= 0; or else ˜y
P
is the
most least (right-most) bit of e = y
P
· x
−1
P
of the composite field F
(2
15
)
17
;
2. Concatenate x
P
and ˜y
P
and obtain the bit stream.
The compressed public key is denoted as
˜
P = x
P
∥ ˜y
P
4