The set of all invertible elements of the ring \(\mathbb{Z}_n\) is denoted \(U(n)\), and is called the group of units of \(\mathbb{Z}_n\).
Exercise: Find all the elements of \(U(8)\), and make a multiplication table. Is U(8) a ring? Why or why not?
A set with (an associative) multiplication and multiplicative inverses is called a group. For example, \(U(n)\) is a group.
If all the elements of a group \(G\) are powers of a single element \(\alpha\) of the group, then \(G\) is called a cyclic group, and \(\alpha\) is called a generator of the group \(G\).
Exercise: Which of the following are cyclic groups?
- \(U(8)\)
- \(U(10)\)
- \(U(7)\)
Theorem. The group \(U(n)\) is cyclic if and only if \(n\) is \(1\), \(2\), \(4\), \(p^k\), or \(2p^k\), where \(p\) is an odd prime and \(k\geq 1\).
For a proof, see [Guichard], Mathematics Magazine 72:2, April 1999, pp. 139–142.
When \(U(n)\) is cyclic, a generator of \(U(n)\) is called a primitive root modulo \(n\).
Definition. Let \(G\) be a finite group, and let \(g\in G\). The order of the element \(g\) is the smallest number \(e\) such that \(g^e = 1\).
Theorem. The order of an element in a finite group divides the size of the group.
Proof: Math 110
(Example)
Example: Find a generator of \(U(43)\) (i.e., a primitive root modulo 43)
Is 2 primitive in \(U(43)\)?
Big Integer ('bigz') object of length 42:
[1] 2 4 8 16 32 21 42 41 39 35 27 11 22 1 2 4 8 16 32 21 42 41 39 35 27 11 22 1 2 4 8 16
[33] 32 21 42 41 39 35 27 11 22 1
Is 3 primitive in \(U(43)\)?
Big Integer ('bigz') object of length 42:
[1] 3 9 27 38 28 41 37 25 32 10 30 4 12 36 22 23 26 35 19 14 42 40 34 16 5 15 2 6 18 11 33 13
[33] 39 31 7 21 20 17 8 24 29 1
Suppose \(p\) is prime and \(p-1 = q_1^{i_1}q_2^{i_2}\cdots q_n^{i_n}\) is a prime factorization.
Is 2 primitive?
Big Integer ('bigz') object of length 3:
[1] 42 21 1
Is 3 primitive?
Big Integer ('bigz') object of length 3:
[1] 42 41 36
Alice and Bob wish to create a shared secret \(K\) (e.g., to make an AES key) using unencrypted communication.
In practice, an AES (or other) key is obtained by taking a “hash” of \(K\). (More details in Chapter 8.)
In the Diffie-Hellman key exchange, Eve can observe \(\alpha^x\) and \(\alpha^y\), but she can’t obtain the secret \(K\) unless she knows \(x\) or \(y\). So the security of this algorithm relies on the fact that, in \(U(p)\), the equation \[ \beta = \alpha^x \] is difficult to solve for \(x\).
Definition. Let \(\alpha,\beta \in U(p)\), with \(p\) prime. The least nonnegative integer \(x\) that satisfies the equation \(\beta = \alpha^x\) is called the discrete logarithm of \(\beta\) with respect to \(\alpha\), denoted \(L_\alpha(\beta)\).
Example: In \(U(11)\), compute \(L_3(4)\).
Suppose \(\alpha\) is a primitive root modulo \(p\) and consider solving \(\beta = \alpha^x\) in \(U(p)\). (i.e., compute \(L_\alpha(\beta)\) modulo \(p\).)
The size of \(U(p)\) is \(p-1\). Write \(p-1 = 2c\).
Exercise 1. All calculations below are in \(U(p)\).
If \(x\) is even, what must be true? What if \(x\) is odd?
Exercise 2. Find a value of \(x\) that satisfies both of the following congruences. \[ \begin{aligned} x &\equiv 3 \pmod{5} \\ x &\equiv 2 \pmod{7} \end{aligned} \]
Exercise 3. Find a value of \(x\) that satisfies both of the following congruences. \[ \begin{aligned} x &\equiv 3 \pmod{4} \\ x &\equiv 2 \pmod{6} \end{aligned} \]
Theorem. Let \(m_1, m_2, \ldots m_k\) be integers that are pairwise relatively prime, and let \(M = m_1m_2\cdots m_k\). Given integers \(a_1, a_2, \ldots, a_k\), there is a solution \(x\) to the following simultaneous congruences. Furthermore, this solution is unique modulo \(M\). \[ \begin{aligned} x &\equiv a_1 \pmod{m_1} \\ x &\equiv a_2 \pmod{m_2} \\ &\,\,\vdots \\ x &\equiv a_k \pmod{m_k} \\ \end{aligned} \]
Constructive proof: Let \(x = a_1y_1z_1 + a_2y_2z_2 + \ldots + a_ky_kz_k\), where \(z_i = M/m_i\) and \(y_i = z_i^{-1} \bmod m_i\).
Exercise 4. Find a value of \(x\) that satisfies all of the following congruences. \[ \begin{aligned} x &\equiv 2 \pmod{5} \\ x &\equiv 1 \pmod{6} \\ x &\equiv 3 \pmod{7} \end{aligned} \]
Suppose \(p-1 = m_1m_2\cdots m_k\), where each \(m_i\) is a power of a small prime.
Facts used:
Compute \(L_7(12)\) in \(U(41)\). (i.e., Solve \(7^x = 12\).)
How to avoid this attack: Make sure \(p-1\) has at least one large prime factor.
[1] 2
Big Integer ('bigz') object of length 6:
[1] 2 2 5 5 13 180618958189
(Similar to meet-in-the-middle attack.)
To solve \(\alpha^x = \beta\) in \(U(p)\): Choose large \(N > \sqrt{p-1}\)
If a match is found in these two lists, \(x=j+Nk\) is a solution. (Note that \(k\) and \(j\) are the “digits” in the base \(N\) representation of \(x\).)
We can use match
.
w1 <- c("I", "thought", "you", "said", "your", "dog", "did", "not", "bite")
w2 <- c("That", "is", "not", "my", "dog")
m <- match(w1, w2)
m
[1] NA NA NA NA NA 5 NA 3 NA
[1] 6 8
[1] NA NA NA NA NA "dog" NA "not" NA
[1] "dog" "not"
Big Integer ('bigz') :
[1] 41425148
How to avoid this attack: Use large primes.
Decryption: In \(U(p)\), Bob uses the secret \(a\) to compute \(tr^{-a}\). This works because \[ tr^{-a} = \beta^km(\alpha^k)^{-a} = (\alpha^a)^km\alpha^{-ak} = m \]