| Title | Author | Created | Published | Tags |
| -------------------- | ---------------------------- | -------------- | -------------- | -------------------------------------------------- |
| Complete Study Guide | <ul><li>Jon Marien</li></ul> | April 17, 2025 | April 17, 2025 | [[#classes\|#classes]], [[#MATH36206\|#MATH36206]] |
## Advanced Cryptology Final Exam Study Notes (Weeks 8-12)
### Week 8: NP-complete Problem Based Cryptosystems
#### 1. Subset-Sum Problem
- **Definition:** Given a set of numbers $S = {x_1, ..., x_k}$ and a target sum $t$, the Subset-Sum problem is to determine if there exists a subset of $S$ that sums to $t$. Mathematically, find $b_i \in {0, 1}$ such that $t = \sum_{i=1}^{k} b_i \cdot x_i$.
- **Complexity:** The general Subset-Sum problem is **NP-complete**. A brute-force approach to find a solution has a time complexity of $O(2^k)$.
#### 2. Subset-Sum Cryptography (Basic Idea)
- Use a set $S$ as the **public key**. Encrypt a binary message $b_1b_2...b_k$ as the sum $t = \sum_{i=1}^{k} b_i \cdot s_i$, where $s_i \in S$.
- **Problem:** Decrypting $t$ to find the original binary message is equivalent to solving the hard Subset-Sum problem, making it computationally infeasible. Also, solutions may not be unique.
#### 3. Superincreasing Sequences
- **Definition:** A sequence $S = {s_1, s_2, ..., s_n}$ is **superincreasing** if each element is greater than the sum of all preceding elements: $s_i > \sum_{j=1}^{i-1} s_j$ for all $i > 1$. Example: ${3, 5, 9, 18, 38, 75, 155, 310}$.
- **Solving Subset-Sum with Superincreasing Sequences:** This can be done in **polynomial time** using a greedy algorithm.
- To find a subset of $S$ that sums to $t$: Start with the largest element $s_n$. If $t \ge s_n$, include $s_n$ in the subset and update $t = t - s_n$. Repeat this process for the remaining elements in decreasing order.
- **Example:** $S = {3, 5, 9, 18, 38, 75, 155, 310}$, $t = 242$.
- $242 \ge 310$? No.
- $242 \ge 155$? Yes. $t = 242 - 155 = 87$. Subset includes 155.
- $87 \ge 75$? Yes. $t = 87 - 75 = 12$. Subset includes 75.
- $12 \ge 38$? No.
- $12 \ge 18$? No.
- $12 \ge 9$? Yes. $t = 12 - 9 = 3$. Subset includes 9.
- $3 \ge 5$? No.
- $3 \ge 3$? Yes. $t = 3 - 3 = 0$. Subset includes 3.
- Solution: ${3, 9, 75, 155}$, corresponding to binary string $10100110$.
#### 4. Trapdoor Functions for Subset-Sum
- **Trapdoor:** A way to transform a hard problem into an easy one using secret information. In the context of Subset-Sum cryptography, the trapdoor involves transforming a superincreasing set $S$ (easy to solve Subset-Sum) into a seemingly random set $A$ (hard to solve Subset-Sum without the trapdoor) using two integers $u$ and $v$:
- $\text{GCD}(u, v) = 1$
- $u > \sum_{i=1}^{n} s_i$ (or $u > 2s_n$)
- $a_i = v \cdot s_i \pmod{u}$ for $1 \le i \le n$. The set $A = {a_1, a_2, ..., a_n}$ is the **public key**.
#### 5. Merkle-Hellman Knapsack Cipher
- **Private Key:** A superincreasing set $S = {s_1, ..., s_n}$ and the integers $u$ and $v$ used to generate the public key $A$.
- **Public Key:** The set $A = {a_1, ..., a_n}$.
- **Encryption:** To encrypt an $n$-bit plaintext $b_1b_2...b_n$, compute the ciphertext $t' = \sum_{i=1}^{n} b_i \cdot a_i$.
- **Decryption:** To decrypt $t'$:
1. Compute the modular inverse of $v$ modulo $u$: $v^{-1} \pmod{u}$. This can be done using the Extended Euclidean Algorithm since $\text{GCD}(u, v) = 1$.
2. Compute the target sum $t$ with respect to the superincreasing set $S$: $t = t' \cdot v^{-1} \pmod{u}$.
3. Solve the Subset-Sum problem for $\langle S, t \rangle$. Since $S$ is superincreasing, this can be done in polynomial time to recover the binary plaintext $b_1b_2...b_n$.
- **Example:** Encrypt "Bat" using 8-bit ASCII and $A = {39, 65, 117, 234, 494, 303, 671, 670}$, $u = 672, v = 13$.
- B (01000010): $t' = 0(39) + 1(65) + 0(117) + 0(234) + 0(494) + 0(303) + 1(671) + 0(670) = 736$.
- a (01100001): $t' = 0(39) + 1(65) + 1(117) + 0(234) + 0(494) + 0(303) + 0(671) + 1(670) = 852$.
- t (01110100): $t' = 0(39) + 1(65) + 1(117) + 1(234) + 0(494) + 1(303) + 0(671) + 0(670) = 719$.
- Decryption of 736: $v^{-1} \pmod{u} = 13^{-1} \pmod{672} = 517$. $t = 736 \cdot 517 \pmod{672} = 160$. Solving Subset-Sum for $S = {3, 5, 9, 18, 38, 75, 155, 310}$ and $t = 160$ gives $155 + 5$, so $01000010$ (B).
- **Security Basis:** Relies on the assumption that solving the general Subset-Sum problem is hard (NP-complete), while solving it for a superincreasing set is easy. The trapdoor $(u, v)$ allows the legitimate user to transform the hard problem back to the easy one.
- **Resistance to Quantum Attacks:** Not directly broken by known quantum algorithms like Shor's algorithm (which targets factoring and discrete logarithms). However, the security relies on the classical hardness of Subset-Sum. Future advancements in quantum algorithms could potentially impact its security.
- **Time Complexity:**
- Key Generation: Generating a superincreasing sequence of length $n$ takes $O(n)$. Modular multiplications to get $A$ take $O(n)$. Finding $v^{-1}$ using EEA takes roughly $O(\log^2 u)$.
- Encryption: Summation of $n$ terms, $O(n)$.
- Decryption: Modular multiplication $O(\log^2 u)$. Solving superincreasing Subset-Sum takes $O(n)$.
- **Classical vs. Post-Quantum:** A classical public-key cryptosystem based on the hardness of an NP-complete problem.
- **Exam-style Exercises:** Determine if a set is superincreasing. Compute the public key $A$ from $S, u, v$. Encrypt and decrypt using Merkle-Hellman. Prove Subset-Sum is in P for superincreasing sets. Explain the condition $u > 2s_n$.
- **Short Solutions/Outlines:**
- 8.1 a) Check if each element is greater than the sum of the preceding ones. Then use the greedy algorithm for Subset-Sum.
- 8.2 Use $s_i = v^{-1} a_i \pmod{u}$.
- 8.3 Use $a_i = v s_i \pmod{u}$.
- 8.4 Perform the summation $t' = \sum b_i a_i$.
- 8.5 a) Use EEA. b) $s_i = v^{-1} a_i \pmod{u}$, $t = t' v^{-1} \pmod{u}$. c) Greedy algorithm on $S$ with target $t$. d) Verify the sum.
- 8.6 Describe the greedy algorithm and its linear time complexity.
- 8.7 To ensure that the result of $t' v^{-1} \pmod{u}$ corresponds to a unique sum of elements in $S$ with binary coefficients, avoiding wrap-around issues.
#### Flashcards (Week 8)
- **Subset-Sum Problem:** Finding a subset of a set that sums to a target.
- **NP-complete:** A class of problems believed to be computationally hard to solve in polynomial time.
- **Superincreasing Sequence:** Each element is greater than the sum of preceding elements.
- **Polynomial Time:** Computational time that grows polynomially with the input size (considered efficient).
- **Trapdoor Function:** A function easy to compute in one direction but hard to reverse without special information (the trapdoor).
- **Modular Inverse:** An element $v^{-1}$ such that $v \cdot v^{-1} \equiv 1 \pmod{u}$.
- **Merkle-Hellman Knapsack Cipher:** A public-key cryptosystem based on the Subset-Sum problem and superincreasing sequences.
- **Public Key (Merkle-Hellman):** The transformed set $A$.
- **Private Key (Merkle-Hellman):** The superincreasing set $S$ and the moduli $u, v$.
- **Encryption (Merkle-Hellman):** Sum of a subset of the public key elements.
- **Decryption (Merkle-Hellman):** Uses the trapdoor to solve an easy Subset-Sum problem.
#### Original Practice Problems (Week 8)
1. Determine if the set $S = {2, 3, 6, 13, 27}$ is superincreasing. If it is, find a subset that sums to $t = 32$.
- **Solution:**
- Is it superincreasing? $3 > 2$ (Yes), $6 > 2+3=5$ (Yes), $13 > 2+3+6=11$ (Yes), $27 > 2+3+6+13=24$ (Yes). So, $S$ is superincreasing.
- Subset sum for $t=32$:
- $32 \ge 27$? Yes. $t = 32 - 27 = 5$. Subset includes 27.
- $5 \ge 13$? No.
- $5 \ge 6$? No.
- $5 \ge 3$? Yes. $t = 5 - 3 = 2$. Subset includes 3.
- $2 \ge 2$? Yes. $t = 2 - 2 = 0$. Subset includes 2.
- Subset: ${2, 3, 27}$, corresponding to binary $11001$.
2. Given the superincreasing set $S = {5, 8, 17, 35}$ and $u = 80, v = 21$. Compute the public key $A$ for the Merkle-Hellman knapsack cipher.
- **Solution:**
- $a_1 = 21 \cdot 5 \pmod{80} = 105 \pmod{80} = 25$.
- $a_2 = 21 \cdot 8 \pmod{80} = 168 \pmod{80} = 8$.
- $a_3 = 21 \cdot 17 \pmod{80} = 357 \pmod{80} = 37$.
- $a_4 = 21 \cdot 35 \pmod{80} = 735 \pmod{80} = 15$.
- Public key $A = {25, 8, 37, 15}$.
3. Encrypt the message "101" using the public key $A = {25, 8, 37, 15}$ from the previous problem.
- **Solution:**
- Plaintext "1010" (assuming 4-bit message).
- $t' = 1(25) + 0(8) + 1(37) + 0(15) = 25 + 37 = 62$.
- Ciphertext: $62$.
4. Given $u = 80, v = 21$, find $v^{-1} \pmod{u}$.
- **Solution:** We need to find $x$ such that $21x \equiv 1 \pmod{80}$. Using the Extended Euclidean Algorithm:
- $80 = 3 \cdot 21 + 17$
- $21 = 1 \cdot 17 + 4$
- $17 = 4 \cdot 4 + 1$
- $1 = 17 - 4 \cdot 4 = 17 - 4 \cdot (21 - 1 \cdot 17) = 17 - 4 \cdot 21 + 4 \cdot 17 = 5 \cdot 17 - 4 \cdot 21 = 5 \cdot (80 - 3 \cdot 21) - 4 \cdot 21 = 5 \cdot 80 - 15 \cdot 21 - 4 \cdot 21 = 5 \cdot 80 - 19 \cdot 21$.
- So, $-19 \cdot 21 \equiv 1 \pmod{80}$. $-19 \equiv -19 + 80 = 61 \pmod{80}$.
- $v^{-1} \equiv 61 \pmod{80}$.
5. Consider a Merkle-Hellman cryptosystem with superincreasing set $S = {2, 7, 15}$ and $u = 32, v = 3$. The public key is $A = {6, 21, 13}$. You receive a ciphertext $t' = 27$. Decrypt the ciphertext.
- **Solution:**
- Find $v^{-1} \pmod{u}$: $3x \equiv 1 \pmod{32}$. Using EEA (or by inspection), $x = 11$ since $3 \cdot 11 = 33 \equiv 1 \pmod{32}$. So, $v^{-1} = 11$.
- Compute $t = t' \cdot v^{-1} \pmod{u} = 27 \cdot 11 \pmod{32} = 297 \pmod{32} = 9$.
- Solve Subset-Sum for $S = {2, 7, 15}$ and $t = 9$:
- $9 \ge 15$? No.
- $9 \ge 7$? Yes. $t = 9 - 7 = 2$. Subset includes 7.
- $2 \ge 2$? Yes. $t = 2 - 2 = 0$. Subset includes 2.
- Plaintext: $110$.
### Week 9: Hash-based Signature Schemes
#### 1. Lamport Signature Scheme
- **Key Generation:** For a $k$-bit message, generate $2k$ private keys $y_{i,j}$ (for $1 \le i \le k, j \in {0, 1}$). Compute the corresponding public keys $z_{i,j} = h(y_{i,j})$, where $h$ is a secure hash function. The public key is the set of all $z_{i,j}