* 将 ![Data-inlined] 按照每行54个字符输出。
-
diff --git a/assets/README.HOW_DOES_IT_WORK.md.bak b/assets/README.HOW_DOES_IT_WORK.md.bak
new file mode 100644
index 0000000..336df37
--- /dev/null
+++ b/assets/README.HOW_DOES_IT_WORK.md.bak
@@ -0,0 +1,321 @@
+[GF2-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20%5Ctextrm%7BGF%7D%282%29
+[GF2p15-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20%5Ctextrm%7BGF%7D%282%5E%7B15%7D%29
+[GF2p15p17-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20%5Ctextrm%7BGF%7D%28%282%5E%7B15%7D%29%5E%7B17%7D%29
+[A-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20A
+[B-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20B
+[D-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20D
+[G-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20G
+[M-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20M
+[P-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20P
+[h-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20h
+[k-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20k
+[l-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20l
+[n-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20n
+[r-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20r
+[s-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20s
+[T-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20T
+[UU-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20U
+[LL-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20L
+[Rnd-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20Rnd
+[Temp-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20Temp
+[UID-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20UID
+[Data-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20Data
+[Data0-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20Data%5E0
+[Data1-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20Data%5E1
+[Data2-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20Data%5E2
+[Data3-inlined]: http://latex.codecogs.com/svg.latex?%5Cinline%20Data%5E3
+
+# How is "rarreg.key" generated?
+
+WinRAR uses an ECC-based signature algorithm to generate `rarreg.key`. The algorithm it used is a variant of Chinese SM2 digital signature algorithm. Different to many standard ECDSAs, the curve that WinRAR selected is a curve over composite field ![GF2p15p17-inlined].
+
+## 1. Composite field ![GF2p15p17-inlined]
+
+Elements in ground field ![GF2p15-inlined] are represented with standard basis, i.e. polynomial basis. The irreducible polynomial is
+
+
+
+
+where each coefficients is in ![GF2-inlined]. If we use
+
+
+
+
+as the standard basis of the ground field, an element ![A-inlined] in ![GF2p15-inlined] can be denoted as
+
+
+
+
+---
+
+The irreducible polynomial of composite field ![GF2p15p17-inlined] is
+
+
+
+
+where each coefficients is in ![GF2p15-inlined]. If we use
+
+
+
+
+as the standard basis of the composite field, an element ![B-inlined] in ![GF2p15p17-inlined] can be denoted as
+
+
+
+
+---
+
+For clarity, we use ![D-inlined], which is a 255-bits-long integer to denote an element ![B-inlined] in ![GF2p15p17-inlined]. The map between them is
+
+
+
+
+## 2. Elliptic curve over ![GF2p15p17-inlined]
+
+The equation of the elliptic curve that WinRAR uses is
+
+
+
+
+The base point ![G-inlined] is
+
+
+
+
+whose order ![n-inlined] is
+
+
+
+
+## 3. Message hash algorithm
+
+We use
+
+
+
+
+to denote a message whose length is ![l-inlined]. So the SHA1 value of ![M-inlined] should be
+
+
+
+
+where  are 5 state values when SHA1 outputs. Generally speaking, the final SHA1 value should be the join of these 5 state values while each of state values is serialized in big-endian.
+
+However, WinRAR doesn't serialize the 5 state values. Instead, it use a big integer ![h-inlined] as the hash of the input message.
+
+
+
+
+## 4. ECC digital signature algorithm
+
+We use ![k-inlined] to denote private key, ![P-inlined] to denote public key. So there must be
+
+
+
+
+If we use ![h-inlined] to denote the hash of input data, WinRAR use the following algorithm to perform signing:
+
+1. Generate a random big integer ![Rnd-inlined] which satisfies .
+
+2. Calculate ![r-inlined]
+
+
+
+
+
+ where  means we take X coordinate of  and convert it from ![GF2p15p17-inlined] to a big integer.
+
+ If  or , go back to step 1.
+
+3. Calculate ![s-inlined]
+
+
+
+
+
+ If , go back to step 1.
+
+4. Output .
+
+## 5. WinRAR private key generation algorithm
+
+We use
+
+
+
+
+
+to denote input data whose length is ![l-inlined]. WinRAR use it to generate private key ![k-inlined].
+
+1. We use  to denote 6 32-bits-long integer. So there is
+
+
+
+
+
+2. Let .
+
+3. If , we calculate SHA1 value of ![T-inlined]. Then assign SHA1 state value  to :
+
+
+
+
+
+ Otherwise, when , we let
+
+
+
+
+
+4. Regard  as counter, add itself by 1.
+
+ Calculate SHA1:
+
+
+
+
+
+ We takes the lowest 16 bits of  and donote it as .
+
+5. Repeat step 4 again with 14 times.
+
+6. After that, we will get . Then output private key
+
+
+
+
+
+## 6. The private key and public key of WinRAR
+
+Private key ![k-inlined] is
+
+
+
+
+
+This private key is generated by the algorithm describled in section 5 where the length of data ![T-inlined] is zero.
+
+Public key ![P-inlined] is
+
+
+
+
+
+## 7. Generation of "rarreg.key"
+
+The generation of license file `rarreg.key` requires 2 arguments:
+
+1. Username, an ANSI-encoded string, without null-terminator. Denoted as
+
+
+
+
+
+2. License type, an ANSI-encoded string, without null-terminator. Denoted as
+
+
+
+
+
+The following is the algorithm to generate `rarreg.key`.
+
+1. Use the algorithm describled in section 5, with argument ![UU-inlined], to generate private key  and public key . Then output hexlified public key string with SM2 compressed public key format. The hexlified public key is denoted as ![Temp-inlined].
+
+ The length of ![Temp-inlined] should be 64. If less, pad with `'0'` until the length is 64.
+
+2. Let ![Data3-inlined] be
+
+
+
+
+
+3. Use the algorithm describled in section 5, with argument ![Data3-inlined], to generate private key  and public key . Then output hexlified public key string with SM2 compressed public key format. The hexlified public key is denoted as ![Data0-inlined].
+
+ The length of ![Data0-inlined] should be 64. If less, pad with `'0'` until the length is 64.
+
+4. Let ![UID-inlined] be
+
+
+
+
+
+5. Use the algorithm describled in section 4, with argument ![LL-inlined] and private key ![k-inlined] describled section 6, to get signature .
+
+ The bit length of  and  shall not be more than 240. Otherwise, repeat this step.
+
+6. Convert  and  to hex-integer string  and , without `"0x"` prefix.
+
+ If the length of  or  is less than 60, pad character `'0'` until the length is 60.
+
+7. Let ![Data1-inlined] be
+
+
+
+
+
+8. Let ![Temp-inlined] be
+
+
+
+
+
+ Use the algorithm describled in section 4, with argument ![Temp-inlined] and private key ![k-inlined] describled section 6, to get signature .
+
+ The bit length of  and  shall not be more than 240. Otherwise, repeat this step.
+
+9. Convert  and  to hex-integer string  and , without `"0x"` prefix.
+
+ If the length of  or  is less than 60, pad character `'0'` until the length is 60.
+
+10. Let ![Data2-inlined] be
+
+
+
+
+
+11. Calculate CRC32 value of
+
+
+
+
+
+ The final checksum the complement of CRC32 value.
+
+ Then convert the checksum to decimal string . If the length is less than 10, pad character `'0'` until the length is 10.
+
+12. Let ![Data-inlined] be
+
+
+
+
+
+13. Output with format
+
+ * A fixed header `"RAR registration data"`, taking one line.
+
+ * Username, taking one line.
+
+ * License type, taking one line
+
+ * UID, taking one line, with format:
+
+
- * 将 ![Data-inlined] 按照每行54个字符输出。
+ * 将  按照每行54个字符输出。
diff --git a/assets/formula/AA-inlined-dark.svg b/assets/formula/AA-inlined-dark.svg
new file mode 100644
index 0000000..7c5eaa8
--- /dev/null
+++ b/assets/formula/AA-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/AA-inlined-light.svg b/assets/formula/AA-inlined-light.svg
new file mode 100644
index 0000000..106aa50
--- /dev/null
+++ b/assets/formula/AA-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/BB-inlined-dark.svg b/assets/formula/BB-inlined-dark.svg
new file mode 100644
index 0000000..687f303
--- /dev/null
+++ b/assets/formula/BB-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/BB-inlined-light.svg b/assets/formula/BB-inlined-light.svg
new file mode 100644
index 0000000..d07d0b6
--- /dev/null
+++ b/assets/formula/BB-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/DD-inlined-dark.svg b/assets/formula/DD-inlined-dark.svg
new file mode 100644
index 0000000..2c5e54e
--- /dev/null
+++ b/assets/formula/DD-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/DD-inlined-light.svg b/assets/formula/DD-inlined-light.svg
new file mode 100644
index 0000000..5560f7b
--- /dev/null
+++ b/assets/formula/DD-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Data-inlined-dark.svg b/assets/formula/Data-inlined-dark.svg
new file mode 100644
index 0000000..31f6985
--- /dev/null
+++ b/assets/formula/Data-inlined-dark.svg
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Data-inlined-light.svg b/assets/formula/Data-inlined-light.svg
new file mode 100644
index 0000000..3b1dcd9
--- /dev/null
+++ b/assets/formula/Data-inlined-light.svg
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Data0-inlined-dark.svg b/assets/formula/Data0-inlined-dark.svg
new file mode 100644
index 0000000..46fc84f
--- /dev/null
+++ b/assets/formula/Data0-inlined-dark.svg
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Data0-inlined-light.svg b/assets/formula/Data0-inlined-light.svg
new file mode 100644
index 0000000..14391fc
--- /dev/null
+++ b/assets/formula/Data0-inlined-light.svg
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Data1-inlined-dark.svg b/assets/formula/Data1-inlined-dark.svg
new file mode 100644
index 0000000..1d6f398
--- /dev/null
+++ b/assets/formula/Data1-inlined-dark.svg
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Data1-inlined-light.svg b/assets/formula/Data1-inlined-light.svg
new file mode 100644
index 0000000..328c003
--- /dev/null
+++ b/assets/formula/Data1-inlined-light.svg
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Data2-inlined-dark.svg b/assets/formula/Data2-inlined-dark.svg
new file mode 100644
index 0000000..731d236
--- /dev/null
+++ b/assets/formula/Data2-inlined-dark.svg
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Data2-inlined-light.svg b/assets/formula/Data2-inlined-light.svg
new file mode 100644
index 0000000..ecda7aa
--- /dev/null
+++ b/assets/formula/Data2-inlined-light.svg
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Data3-inlined-dark.svg b/assets/formula/Data3-inlined-dark.svg
new file mode 100644
index 0000000..8851e82
--- /dev/null
+++ b/assets/formula/Data3-inlined-dark.svg
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Data3-inlined-light.svg b/assets/formula/Data3-inlined-light.svg
new file mode 100644
index 0000000..b402f3b
--- /dev/null
+++ b/assets/formula/Data3-inlined-light.svg
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/GG-inlined-dark.svg b/assets/formula/GG-inlined-dark.svg
new file mode 100644
index 0000000..3c08276
--- /dev/null
+++ b/assets/formula/GG-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/GG-inlined-light.svg b/assets/formula/GG-inlined-light.svg
new file mode 100644
index 0000000..6572feb
--- /dev/null
+++ b/assets/formula/GG-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/LL-inlined-dark.svg b/assets/formula/LL-inlined-dark.svg
new file mode 100644
index 0000000..b6281bc
--- /dev/null
+++ b/assets/formula/LL-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/LL-inlined-light.svg b/assets/formula/LL-inlined-light.svg
new file mode 100644
index 0000000..cb52212
--- /dev/null
+++ b/assets/formula/LL-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/MM-inlined-dark.svg b/assets/formula/MM-inlined-dark.svg
new file mode 100644
index 0000000..b70e225
--- /dev/null
+++ b/assets/formula/MM-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/MM-inlined-light.svg b/assets/formula/MM-inlined-light.svg
new file mode 100644
index 0000000..82dbb5f
--- /dev/null
+++ b/assets/formula/MM-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/PP-inlined-dark.svg b/assets/formula/PP-inlined-dark.svg
new file mode 100644
index 0000000..e0d2ca1
--- /dev/null
+++ b/assets/formula/PP-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/PP-inlined-light.svg b/assets/formula/PP-inlined-light.svg
new file mode 100644
index 0000000..82cdd7e
--- /dev/null
+++ b/assets/formula/PP-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Rnd-inlined-dark.svg b/assets/formula/Rnd-inlined-dark.svg
new file mode 100644
index 0000000..894d964
--- /dev/null
+++ b/assets/formula/Rnd-inlined-dark.svg
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Rnd-inlined-light.svg b/assets/formula/Rnd-inlined-light.svg
new file mode 100644
index 0000000..78ad79a
--- /dev/null
+++ b/assets/formula/Rnd-inlined-light.svg
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/TT-inlined-dark.svg b/assets/formula/TT-inlined-dark.svg
new file mode 100644
index 0000000..9934a61
--- /dev/null
+++ b/assets/formula/TT-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/TT-inlined-light.svg b/assets/formula/TT-inlined-light.svg
new file mode 100644
index 0000000..79bea65
--- /dev/null
+++ b/assets/formula/TT-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Temp-inlined-dark.svg b/assets/formula/Temp-inlined-dark.svg
new file mode 100644
index 0000000..a430ae5
--- /dev/null
+++ b/assets/formula/Temp-inlined-dark.svg
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/Temp-inlined-light.svg b/assets/formula/Temp-inlined-light.svg
new file mode 100644
index 0000000..c8ba688
--- /dev/null
+++ b/assets/formula/Temp-inlined-light.svg
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/UID-inlined-dark.svg b/assets/formula/UID-inlined-dark.svg
new file mode 100644
index 0000000..12ca3f3
--- /dev/null
+++ b/assets/formula/UID-inlined-dark.svg
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/UID-inlined-light.svg b/assets/formula/UID-inlined-light.svg
new file mode 100644
index 0000000..29b3523
--- /dev/null
+++ b/assets/formula/UID-inlined-light.svg
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/UU-inlined-dark.svg b/assets/formula/UU-inlined-dark.svg
new file mode 100644
index 0000000..c271179
--- /dev/null
+++ b/assets/formula/UU-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/UU-inlined-light.svg b/assets/formula/UU-inlined-light.svg
new file mode 100644
index 0000000..7d79c29
--- /dev/null
+++ b/assets/formula/UU-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/h-inlined-dark.svg b/assets/formula/h-inlined-dark.svg
new file mode 100644
index 0000000..8f7d18c
--- /dev/null
+++ b/assets/formula/h-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/h-inlined-light.svg b/assets/formula/h-inlined-light.svg
new file mode 100644
index 0000000..a49c7a5
--- /dev/null
+++ b/assets/formula/h-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/k-inlined-dark.svg b/assets/formula/k-inlined-dark.svg
new file mode 100644
index 0000000..547031f
--- /dev/null
+++ b/assets/formula/k-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/k-inlined-light.svg b/assets/formula/k-inlined-light.svg
new file mode 100644
index 0000000..3f8c34f
--- /dev/null
+++ b/assets/formula/k-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/l-inlined-dark.svg b/assets/formula/l-inlined-dark.svg
new file mode 100644
index 0000000..80bca23
--- /dev/null
+++ b/assets/formula/l-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/l-inlined-light.svg b/assets/formula/l-inlined-light.svg
new file mode 100644
index 0000000..be44274
--- /dev/null
+++ b/assets/formula/l-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/n-inlined-dark.svg b/assets/formula/n-inlined-dark.svg
new file mode 100644
index 0000000..814e6f5
--- /dev/null
+++ b/assets/formula/n-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/n-inlined-light.svg b/assets/formula/n-inlined-light.svg
new file mode 100644
index 0000000..028a5a8
--- /dev/null
+++ b/assets/formula/n-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/r-inlined-dark.svg b/assets/formula/r-inlined-dark.svg
new file mode 100644
index 0000000..ae1a34c
--- /dev/null
+++ b/assets/formula/r-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/r-inlined-light.svg b/assets/formula/r-inlined-light.svg
new file mode 100644
index 0000000..73004f1
--- /dev/null
+++ b/assets/formula/r-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/s-inlined-dark.svg b/assets/formula/s-inlined-dark.svg
new file mode 100644
index 0000000..f1fb994
--- /dev/null
+++ b/assets/formula/s-inlined-dark.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/formula/s-inlined-light.svg b/assets/formula/s-inlined-light.svg
new file mode 100644
index 0000000..aa0ed54
--- /dev/null
+++ b/assets/formula/s-inlined-light.svg
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 455b3747a33eb59fef7301ca981f9a4bdb5bbcd0 Mon Sep 17 00:00:00 2001
From: bitcookies
Date: Thu, 10 Feb 2022 13:27:31 +0800
Subject: [PATCH 10/11] =?UTF-8?q?=F0=9F=8C=99=20Adapt=20the=20Github=20Dar?=
=?UTF-8?q?k=20Theme?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
🌙 Adapt the Github Dark Theme
---
README.HOW_DOES_IT_WORK.zh-CN.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.HOW_DOES_IT_WORK.zh-CN.md b/README.HOW_DOES_IT_WORK.zh-CN.md
index e75eefd..ecbf04b 100644
--- a/README.HOW_DOES_IT_WORK.zh-CN.md
+++ b/README.HOW_DOES_IT_WORK.zh-CN.md
@@ -63,7 +63,7 @@ WinRAR 使用了基于 ECC 的签名算法来生成 `rarreg.key` 文件,其使
-## 2. 复合域 ![GF2p15p17-inlined] 上的椭圆曲线
+## 2. 复合域   上的椭圆曲线
曲线方程为:
@@ -138,7 +138,7 @@ WinRAR 在做完 SHA1 计算后,采用大数  表示取  的 X 坐标,同时将 X 坐标从 !  转换为大数。
+ 其中  表示取  的 X 坐标,同时将 X 坐标从   转换为大数。
若  或者  则回到步骤1。
@@ -273,7 +273,7 @@ WinRAR 的私钥 ![k]
-5. 对授权类型  使用算法4得到签名 ,其中私钥见第6节。
+5. 对授权类型  使用算法4得到签名 ,其中私钥见第6节。
要求  和  的长度都不得超过240比特,否则重复该步骤。
From 80c7f8e6ead38a1b0da0ebb51ea37ed8feac1805 Mon Sep 17 00:00:00 2001
From: bitcookies
Date: Thu, 10 Feb 2022 14:00:19 +0800
Subject: [PATCH 11/11] =?UTF-8?q?=F0=9F=8C=99=20Adapt=20the=20Github=20Dar?=
=?UTF-8?q?k=20Theme?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
🌙 Adapt the Github Dark Theme
---
README.HOW_DOES_IT_WORK.md | 238 +++++++++++++++++++------------
README.HOW_DOES_IT_WORK.zh-CN.md | 36 +----
2 files changed, 150 insertions(+), 124 deletions(-)
diff --git a/README.HOW_DOES_IT_WORK.md b/README.HOW_DOES_IT_WORK.md
index 585d17b..02cfe7f 100644
--- a/README.HOW_DOES_IT_WORK.md
+++ b/README.HOW_DOES_IT_WORK.md
@@ -1,193 +1,238 @@
# How is "rarreg.key" generated?
-WinRAR uses an ECC-based signature algorithm to generate `rarreg.key`. The algorithm it used is a variant of Chinese SM2 digital signature algorithm. Different to many standard ECDSAs, the curve that WinRAR selected is a curve over composite field ![GF2p15p17-inlined].
+WinRAR uses an ECC-based signature algorithm to generate `rarreg.key`. The algorithm it used is a variant of Chinese SM2 digital signature algorithm. Different to many standard ECDSAs, the curve that WinRAR selected is a curve over composite field  .
-## 1. Composite field ![GF2p15p17-inlined]
+## 1. Composite field  
-Elements in ground field ![GF2p15-inlined] are represented with standard basis, i.e. polynomial basis. The irreducible polynomial is
+Elements in ground field  are represented with standard basis, i.e. polynomial basis. The irreducible polynomial is
-
+
-where each coefficients is in ![GF2-inlined]. If we use
+
+where each coefficients is in . If we use
-
+
-as the standard basis of the ground field, an element ![A-inlined] in ![GF2p15-inlined] can be denoted as
+
+as the standard basis of the ground field, an element  in  can be denoted as
-
+
+
---
-The irreducible polynomial of composite field ![GF2p15p17-inlined] is
+The irreducible polynomial of composite field   is
-
+
-where each coefficients is in ![GF2p15-inlined]. If we use
+
+where each coefficients is in . If we use
-
+
-as the standard basis of the composite field, an element ![B-inlined] in ![GF2p15p17-inlined] can be denoted as
+
+as the standard basis of the composite field, an element  in   can be denoted as
-
+
+
---
-For clarity, we use ![D-inlined], which is a 255-bits-long integer to denote an element ![B-inlined] in ![GF2p15p17-inlined]. The map between them is
+For clarity, we use  , which is a 255-bits-long integer to denote an element  in  . The map between them is
-
+
-## 2. Elliptic curve over ![GF2p15p17-inlined]
+
+## 2. Elliptic curve over  
The equation of the elliptic curve that WinRAR uses is
-
+
-The base point ![G-inlined] is
+
+The base point  is
-
+
-whose order ![n-inlined] is
+
+whose order  is
-
+
+
## 3. Message hash algorithm
We use
-
+
-to denote a message whose length is ![l-inlined]. So the SHA1 value of ![M-inlined] should be
+
+to denote a message whose length is . So the SHA1 value of  should be
-
+
-where  are 5 state values when SHA1 outputs. Generally speaking, the final SHA1 value should be the join of these 5 state values while each of state values is serialized in big-endian.
-However, WinRAR doesn't serialize the 5 state values. Instead, it use a big integer ![h-inlined] as the hash of the input message.
+where  are 5 state values when SHA1 outputs. Generally speaking, the final SHA1 value should be the join of these 5 state values while each of state values is serialized in big-endian.
+
+However, WinRAR doesn't serialize the 5 state values. Instead, it use a big integer  as the hash of the input message.
-
+
+
## 4. ECC digital signature algorithm
-We use ![k-inlined] to denote private key, ![P-inlined] to denote public key. So there must be
+We use  to denote private key,  to denote public key. So there must be
-
+
-If we use ![h-inlined] to denote the hash of input data, WinRAR use the following algorithm to perform signing:
-1. Generate a random big integer ![Rnd-inlined] which satisfies .
+If we use  to denote the hash of input data, WinRAR use the following algorithm to perform signing:
-2. Calculate ![r-inlined]
+1. Generate a random big integer  which satisfies .
+
+2. Calculate 
-
+
+
- where  means we take X coordinate of  and convert it from ![GF2p15p17-inlined] to a big integer.
- If  or , go back to step 1.
+ where  means we take X coordinate of  and convert it from   to a big integer.
-3. Calculate ![s-inlined]
+ If  or , go back to step 1.
+
+3. Calculate 
-
+
+
- If , go back to step 1.
-4. Output .
+ If , go back to step 1.
+
+4. Output .
## 5. WinRAR private key generation algorithm
We use
-
+
+
-to denote input data whose length is ![l-inlined]. WinRAR use it to generate private key ![k-inlined].
-1. We use  to denote 6 32-bits-long integer. So there is
+to denote input data whose length is . WinRAR use it to generate private key .
+
+1. We use  to denote 6 32-bits-long integer. So there is
-
+
+
-2. Let .
+2. Let .
-3. If , we calculate SHA1 value of ![T-inlined]. Then assign SHA1 state value  to :
+3. If , we calculate SHA1 value of . Then assign SHA1 state value  to :
-
+
+
- Otherwise, when , we let
+
+ Otherwise, when , we let
-
+
+
-4. Regard  as counter, add itself by 1.
+4. Regard  as counter, add itself by 1.
Calculate SHA1:
-
+
+
- We takes the lowest 16 bits of  and donote it as .
+
+ We takes the lowest 16 bits of  and donote it as .
5. Repeat step 4 again with 14 times.
-6. After that, we will get . Then output private key
+6. After that, we will get . Then output private key
-
+
+
## 6. The private key and public key of WinRAR
-Private key ![k-inlined] is
+Private key  is
-
+
+
-This private key is generated by the algorithm describled in section 5 where the length of data ![T-inlined] is zero.
-Public key ![P-inlined] is
+This private key is generated by the algorithm describled in section 5 where the length of data  is zero.
+
+Public key  is
-
+
+
+
## 7. Generation of "rarreg.key"
The generation of license file `rarreg.key` requires 2 arguments:
@@ -195,85 +240,96 @@ The generation of license file `rarreg.key` requires 2 arguments:
1. Username, an ANSI-encoded string, without null-terminator. Denoted as
-
+
+
2. License type, an ANSI-encoded string, without null-terminator. Denoted as
-
+
+
The following is the algorithm to generate `rarreg.key`.
-1. Use the algorithm describled in section 5, with argument ![UU-inlined], to generate private key  and public key . Then output hexlified public key string with SM2 compressed public key format. The hexlified public key is denoted as ![Temp-inlined].
+1. Use the algorithm describled in section 5, with argument , to generate private key  and public key . Then output hexlified public key string with SM2 compressed public key format. The hexlified public key is denoted as .
- The length of ![Temp-inlined] should be 64. If less, pad with `'0'` until the length is 64.
+ The length of  should be 64. If less, pad with `'0'` until the length is 64.
-2. Let ![Data3-inlined] be
+2. Let  be
-
+
+
-3. Use the algorithm describled in section 5, with argument ![Data3-inlined], to generate private key  and public key . Then output hexlified public key string with SM2 compressed public key format. The hexlified public key is denoted as ![Data0-inlined].
+3. Use the algorithm describled in section 5, with argument , to generate private key  and public key . Then output hexlified public key string with SM2 compressed public key format. The hexlified public key is denoted as .
- The length of ![Data0-inlined] should be 64. If less, pad with `'0'` until the length is 64.
+ The length of  should be 64. If less, pad with `'0'` until the length is 64.
-4. Let ![UID-inlined] be
+4. Let  be
-
+
+
-5. Use the algorithm describled in section 4, with argument ![LL-inlined] and private key ![k-inlined] describled section 6, to get signature .
+5. Use the algorithm describled in section 4, with argument  and private key  describled section 6, to get signature .
- The bit length of  and  shall not be more than 240. Otherwise, repeat this step.
+ The bit length of  and  shall not be more than 240. Otherwise, repeat this step.
-6. Convert  and  to hex-integer string  and , without `"0x"` prefix.
+6. Convert  and  to hex-integer string  and , without `"0x"` prefix.
- If the length of  or  is less than 60, pad character `'0'` until the length is 60.
+ If the length of  or  is less than 60, pad character `'0'` until the length is 60.
-7. Let ![Data1-inlined] be
+7. Let  be
-
+
+
-8. Let ![Temp-inlined] be
+8. Let  be
-
+
+
- Use the algorithm describled in section 4, with argument ![Temp-inlined] and private key ![k-inlined] describled section 6, to get signature .
- The bit length of  and  shall not be more than 240. Otherwise, repeat this step.
+ Use the algorithm describled in section 4, with argument  and private key  describled section 6, to get signature .
-9. Convert  and  to hex-integer string  and , without `"0x"` prefix.
+ The bit length of  and  shall not be more than 240. Otherwise, repeat this step.
- If the length of  or  is less than 60, pad character `'0'` until the length is 60.
+9. Convert  and  to hex-integer string  and , without `"0x"` prefix.
-10. Let ![Data2-inlined] be
+ If the length of  or  is less than 60, pad character `'0'` until the length is 60.
+
+10. Let  be
-
+
+
11. Calculate CRC32 value of
-
+
+
+
The final checksum the complement of CRC32 value.
- Then convert the checksum to decimal string . If the length is less than 10, pad character `'0'` until the length is 10.
+ Then convert the checksum to decimal string . If the length is less than 10, pad character `'0'` until the length is 10.
-12. Let ![Data-inlined] be
+12. Let  be
-
+
+
13. Output with format
@@ -287,8 +343,8 @@ The following is the algorithm to generate `rarreg.key`.
* UID, taking one line, with format:
-
+
+
-
- * Output ![Data-inlined], with 54 characters a line.
-
+
+ * Output , with 54 characters a line.
diff --git a/README.HOW_DOES_IT_WORK.zh-CN.md b/README.HOW_DOES_IT_WORK.zh-CN.md
index ecbf04b..1587e06 100644
--- a/README.HOW_DOES_IT_WORK.zh-CN.md
+++ b/README.HOW_DOES_IT_WORK.zh-CN.md
@@ -11,22 +11,18 @@ WinRAR 使用了基于 ECC 的签名算法来生成 `rarreg.key` 文件,其使
-各项系数全部位于 。设基域的标准基为:
+各项系数全部位于 。设基域的标准基为: