PSE Basic Mathematics Cryptography ZKP-EN
PSE Basic Mathematics Cryptography ZKP-EN
In this file you have the opportunity to experiment with numbers throug
emergence of numerical patterns that help us to understand basic math s
to the development of cryptographic schemes and protocols, and, also Z
I encourage you to experiment and after check your results with the solu
Gracias!
Ranulfo
with numbers through 4 simple mathematical experiments (x_1...x_4), and see the
derstand basic math structures, such as, groups, rings, finite fields. These structures are vital
protocols, and, also ZKP protocols.
note that you already have all the numbers you need
Table 1 x z y ≡ ( x + z ) mod 2
0 0
0 1
1 0
1 1
that R2 – Multiply two numbers (x, z), and, calculate the remainder (y
. Hint: product when divided by 2. The values of x and z can only be 0 o
e Table 2
note that you already have all the numbers you need
Table 1 A B C ≡ ( A + B ) mod 5 A
0 0 0
0 1 0
0 2 0
0 3 0
0 4 0
1 0 1
1 1 1
1 2 1
1 3 1
1 4 1
2 0 2
2 1 2
2 2 2
2 3 2
2 4 2
3 0 3
3 1 3
3 2 3
3 3 3
3 4 3
4 0 4
4 1 4
4 2 4
4 3 4
4 4 4
R4 - Given the set of integers N5 = { 0, 1, 2, 3, 4 }. Multiply each R5 - Given the set
element of N5 with all the others, one by one. And, calculate the each element of N
remainder (C) of that number when divided by 5. See Table 2. the remainder (C)
See Table 3.
B C ≡ ( A * B ) mod 5 Table 2 A
0 0
1 0
2 0
3 0
4 0
0 1
1 1
2 1
3 1
4 1
0 2
1 2
2 2
3 2
4 2
0 3
1 3
2 3
3 3
4 3
0 4
1 4
2 4
3 4
4 4
R6 – Given the set of integ
R5 - Given the set of integers N5 = { 0, 1, 2, 3, 4 }. Add
Multiply each element of N
each element of N5 with B = 0, one by one. And, calculate
And, calculate the remaind
the remainder (C) of that number when divided by 5. when divided by 5. See Ta
See Table 3.
B C ≡ ( A + 0 ) mod 5 Table 3 A B
0 0 1
0 0 1
0 0 1
0 0 1
0 0 1
0 1 1
0 1 1
0 1 1
0 1 1
0 1 1
0 2 1
0 2 1
0 2 1
0 2 1
0 2 1
0 3 1
0 3 1
0 3 1
0 3 1
0 3 1
0 4 1
0 4 1
0 4 1
0 4 1
0 4 1
Given the set of integers N5 = { 0, 1, 2, 3, 4 }.
ply each element of N5 with B = 1, one by one.
calculate the remainder (C) of that number
divided by 5. See Table 4.
C ≡ ( A * 1 ) mod 5Table 4
G1 - Given the set of positive integers Hn=9 = { 0, 1, 2, 3, 4, 5, 6
1 . Calculate the GCD (Greatest Common Divisor) of each elem
i.e., they are coprime, and belongs to set C.
2. Multiply each element of C by all the others, one by one, and
3. Add each element of C with all others, one by one, and divide
Table 1 - Get those numbers Table 2 - Fill the rowi and columnj (those color
that are coprime of n=9, and
put them in column C. element belonging to the set C. For example, in
with the first element of C, and so on. In other c
remainder (item 2).
GCD( Ni, 9 ) column1 column2
Ni 9 C C
0 9 row1 0
1 row2
2 row3
3 row4
4 row5
5 row6
6
7 Table 3 - Fill the rowi and columnj (those colo
8
element belonging to the set C. For example, i
with the first element of C, and so on. In other
remainder (item 3).
one by one, and divide the product by 9 and get the remainder of that division
one, and divide the product by 9 and get the remainder of that division. See T
and its commentary at cell 'C21' and check the cardinality of the Zn* . Coprimes or relatively prim
times do you have to multiply Ni by itself in order to get the remainder = 1 when dividing the pr
erve any cyclic pattern after you find a remainder =1? Observe the patterns in Table 2. You can
a cyclic pattern Table 3 - How many times, X, did you have to repeat
mn C ≡ mod(a * R,
n= 11
the step A until you got the number 1 as the
Ni = 1 remainder?
seudoAlgorithm'
a=3
num_times
1 3 = 31 * 1 = 3 ≡ 3 mod 11
2 32 = 3 * 3 = 9 ≡ 9 mod 11
3 33 = 9 * 3 = 27 ≡ 5 mod 11
4 34 = 5 * 3 = 15 ≡ 4 mod 11
5 35 = 4 * 3 = 12 ≡ 1 mod 11
, Z11* = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, with cardinality equal to 10, where, Zn* is a set
. These numbers represent the cardinality of the set Z n* . Please, look at Table 1.
Ni, n) = 1, where Ni are the elements that belong to Z n* . GCD (Greatest Common
t a remainder R equal to 1 when divided by 11? Or, in generical terms, how many
der R = 1 when divided by n?
* a * ... * a ≡ R mod n
a=3
a1 = a0 * 3 = 3 ≡ 3 mod 11, where R1 = 3
a2 = a1 * 3 = 9 ≡ 9 mod 11, where R2 = 9
a3 = a2 * 3 = 27 ≡ 5 mod 11, where R3 = 5
a4 = a3 * 3 = 15 ≡ 4 mod 11, where R4 = 4
a5 = a4 * 3 = 12 ≡ 1 mod 11, where R5 = 1
a6 = a5 * 3 = 3 ≡ 3 mod 11
a7 = a6 * 3 = 9 ≡ 9 mod 11
... ...
a199 = a198 * 3 = 15 ≡ 4 mod 11
a200 = a199 * 3 = 12 ≡ 1 mod 11
Zn* is a set
able 1.
ommon
w many
R1 - Sum two numbers (x, z), and, calculate the remainder (y) of that sum w
values of x and z can only be 0 or 1 . Hint: use the Excel MOD function or
version)
ave all the numbers you need to start the calculatios in columns
y ≡ ( x + z ) mod 2 x z
0 0 0
1 0 1
1 1 0
0 1 1
monly used in encryption. Let's encrypt the The results represent the o
1010110. The encryption occurs bit-bit. AND.
x 0 1 z
0 0 1
1 1 0
x 0 1 z
0 0 0
1 0 1
Multiply two numbers (x, z), and, calculate the remainder (y) of that
ct when divided by 2. The values of x and z can only be 0 or 1.
os in columns x and z
y ≡ ( x * z ) mod 2Table 2
0
0
0
1
note that you already have all the numbers you need
Table 1 A B C ≡ ( A + B ) mod 5 A
0 0 0 0
0 1 1 0
0 2 2 0
0 3 3 0
0 4 4 0
1 0 1 1
1 1 2 1
1 2 3 1
1 3 4 1
1 4 0 1
2 0 2 2
2 1 3 2
2 2 4 2
2 3 0 2
2 4 1 2
3 0 3 3
3 1 4 3
3 2 0 3
3 3 1 3
3 4 2 3
4 0 4 4
4 1 0 4
4 2 1 4
4 3 2 4
4 4 3 4
R4 - Given the set of integers N5 = { 0, 1, 2, 3, 4 }. Multiply each R5 - Given the set
element of N5 with all the others, one by one. And, calculate the each element of N
remainder (C) of that number when divided by 5. See Table 2. the remainder (C)
See Table 3.
B C ≡ ( A * B ) mod 5 Table 2 A
0 0 0
1 0 0
2 0 0
3 0 0
4 0 0
0 0 1
1 1 1
2 2 1
3 3 1
4 4 1
0 0 2
1 2 2
2 4 2
3 1 2
4 3 2
0 0 3
1 3 3
2 1 3
3 4 3
4 2 3
0 0 4
1 4 4
2 3 4
3 2 4
4 1 4
R6 – Given the set of integ
R5 - Given the set of integers N5 = { 0, 1, 2, 3, 4 }. Add
Multiply each element of N
each element of N5 with B = 0, one by one. And, calculate
And, calculate the remaind
the remainder (C) of that number when divided by 5. when divided by 5. See Ta
See Table 3.
B C ≡ ( A + 0 ) mod 5 Table 3 A B
0 0 0 1
0 0 0 1
0 0 0 1
0 0 0 1
0 0 0 1
0 1 1 1
0 1 1 1
0 1 1 1
0 1 1 1
0 1 1 1
0 2 2 1
0 2 2 1
0 2 2 1
0 2 2 1
0 2 2 1
0 3 3 1
0 3 3 1
0 3 3 1
0 3 3 1
0 3 3 1
0 4 4 1
0 4 4 1
0 4 4 1
0 4 4 1
0 4 4 1
Given the set of integers N5 = { 0, 1, 2, 3, 4 }.
ply each element of N5 with B = 1, one by one.
calculate the remainder (C) of that number
divided by 5. See Table 4.
C ≡ ( A * 1 ) mod 5Table 4
0
0
0
0
0
1
1
1
1
1
2
2
2
2
2
3
3
3
3
3
4
4
4
4
4
G1 - Given the set of positive integers Hn=9 = { 0, 1, 2, 3, 4, 5, 6
1 . Calculate the GCD (Greatest Common Divisor) of each elem
i.e., they are coprime, and belongs to set C.
2. Multiply each element of C by all the others, one by one. And
Table 1 - Get those numbers Table 2 - Fill the rowi and columnj (those color
that are coprime of n=9, and
element belonging to the set C. For example, in
put them in column C.
with the first element of C, and so on. In other c
remainder (item 2).
GCD( Ni, 9 ) column1 column2
Ni 9 C C 1 2
0 9 1 row1 1 1 2
1 1 2 row2 2 2 4
2 1 4 row3 4 4 8
3 3 5 row4 5 5 1
4 1 7 row5 7 7 5
5 1 8 row6 8 8 7
6 3
7 1
8 1
column1 column2
C 1 2
row1 1 2 3
row2 2 3 4
row3 4 5 6
row4 5 6 7
row5 7 8 0
row6 8 0 1
, 1, 2, 3, 4, 5, 6, 7, 8 }, where n=9 is the number of elements belonging to H.
or) of each element of H with n=9 (Table 1) and select those H elements wher
one by one. And, calculate that number's remainder (P) when divided by 9. Se
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
50 1
51 1
52 1
53 1
54 1
55 1
56 1
57 1
58 1
59 1
60 1
61 1
62 1
63 1
64 1
65 1
66 1
67 1
68 1
69 1
70 1
71 1
72 1
73 1
74 1
75 1
76 1
77 1
78 1
79 1
80 1
81 1
82 1
83 1
84 1
85 1
86 1
87 1
88 1
89 1
90 1
91 1
92 1
93 1
94 1
95 1
96 1
97 1
98 1
99 1
100 1
101 1
102 1
103 1
104 1
105 1
106 1
107 1
108 1
109 1
110 1
111 1
112 1
113 1
114 1
115 1
116 1
117 1
118 1
119 1
120 1
121 1
122 1
123 1
124 1
125 1
126 1
127 1
128 1
129 1
130 1
131 1
132 1
133 1
134 1
135 1
136 1
137 1
138 1
139 1
140 1
141 1
142 1
143 1
144 1
145 1
146 1
147 1
148 1
149 1
150 1
151 1
152 1
153 1
154 1
155 1
156 1
157 1
158 1
159 1
160 1
161 1
162 1
163 1
164 1
165 1
166 1
167 1
168 1
169 1
170 1
171 1
172 1
173 1
174 1
175 1
176 1
177 1
178 1
179 1
180 1
181 1
182 1
183 1
184 1
185 1
186 1
187 1
188 1
189 1
190 1
191 1
192 1
193 1
194 1
195 1
196 1
197 1
198 1
199 1
200 1
11= { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, with cardinality equal to 10. Zn* is a set of elements smaller th
*
and its commentary at cell 'C21' and check the cardinality of the Zn* . Coprimes or relatively prim
times do you have to multiply Ni by itself in order to get the remainder = 1 when dividing the pr
erve any cyclic pattern after you find a remainder =1? Observe the patterns in Table 2. You can
l you got the number 1 as the remainder. Complete the Table 3.
f a cyclic pattern Table 3 - How many times, X, did you have to repeat the
I16'.
n= 11
step A until you got the number 1 as the remainder?
'algorithm' Ni = 1
1 1 Table 5 Ni
1 1 α=6
1 1
1 1 Table 8 Ni
1 1 α=7
1 1
1 1 Table 7 Ni
1 1 α=8
1 1
1 1
1 1
1 1 The Discrete Logarith
1 1
given:
1 1
the 'p' prime number, th
1 1
An example, given α =
1 1
following set, S, can be
1 1 S = { 4, 14, 24, 34, 44,
1 1
1 1 The DLP are fundamen
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
et of elements smaller than 'n' and are coprime to 'n'. These numbers
oprimes or relatively prime means that for Ni < n, GCD(Ni, n) = 1,
For which of the elements from Table 3 did it take a number of repetitions equal to the
cardinality of Z11*, to generate a remainder = 1? These numbers are called 'generators' or
'primitives'.
The generators of Z*11 are the set G = { 2, 6, 7, 8 }, i.e., αi ≡ ß mod11, where i = 1...10, α
Є G, and, ß Є Z*11. You can check with Tables 4, 5, 6, 7.
1 2 3 4 5 6 7 8 9 10
2 4 8 5 10 9 7 3 6 1
1 2 3 4 5 6 7 8 9 10
6 3 7 9 10 5 8 4 2 1
1 2 3 4 5 6 7 8 9 10
7 5 2 3 10 4 6 9 8 1
1 2 3 4 5 6 7 8 9 10
8 9 6 4 10 3 2 5 7 1
The Discrete Logarithm Problem (DLP) consist in finding the integer 'x' such that, αx ≡ ß mo
given:
the 'p' prime number, the generator 'α' Є Z*p, and ß an integer Є Z*p. , where Z*p is a finite cycli
An example, given α = 7, p=11, ß = 3, from Table 2 (Ni = α; n = p), we can see that anyone of
following set, S, can be the value 'x':
S = { 4, 14, 24, 34, 44, 54, 64, 74, 84, 94, 104, 114, 124, 134, 144, 154, 164, 174, 184, 194 }
The DLP are fundamental to the Diffie-Hellman Key Exchange and Elgamal encryption schem
ons equal to the
ed 'generators' or
here i = 1...10, α
such that, αx ≡ ß mod(p),