密码学题型en

11 阅读7分钟

Cryptography Final Exam Key Problems - English Version

Problem Type Description

This problem set contains four exam question types:

  1. Concept Explanation: Explain cryptographic concepts, definitions, properties, etc.
  2. Scheme Design: Design cryptographic schemes to meet specific security requirements
  3. Proof Problems: Prove security or insecurity of cryptographic schemes
  4. Calculation Problems: Perform specific cryptographic calculations

Part 1: Symmetric Tools

Type 1: Concept Explanation

Problem 1: Explain PRG Security Definition

Problem: Please explain in detail the security definition of Pseudo-Random Generator (PRG), including: (1) Formal definition (2) Concept of distinguisher (3) Meaning of negligible function (4) Why this definition ensures PRG security

Complete Solution:

(1) Formal Definition

Let G:{0,1}n{0,1}lG: \{0,1\}^n \rightarrow \{0,1\}^l be a function where l>nl > n (expansion requirement). GG is a secure PRG if for all polynomial-time distinguishers DD, there exists a negligible function ϵ\epsilon such that: Pr[D(G(s))=1]Pr[D(r)=1]ϵ(n)|\Pr[D(G(s)) = 1] - \Pr[D(r) = 1]| \leq \epsilon(n) where:

  • s{0,1}ns \leftarrow \{0,1\}^n is a random seed
  • r{0,1}lr \leftarrow \{0,1\}^l is a truly random string
  • DD is a distinguisher algorithm that outputs 0 or 1

(2) Concept of Distinguisher

A distinguisher DD is a polynomial-time algorithm that attempts to distinguish PRG output from a truly random string:

  • If DD outputs 1, it means it thinks the input is random
  • If DD outputs 0, it means it thinks the input is not random (possibly PRG output)

The distinguisher's goal is to maximize distinguishing advantage: AdvD=Pr[D(G(s))=1]Pr[D(r)=1]\text{Adv}_D = |\Pr[D(G(s)) = 1] - \Pr[D(r) = 1]|

(3) Meaning of Negligible Function

A negligible function ϵ:NR\epsilon: \mathbb{N} \rightarrow \mathbb{R} satisfies: for all polynomials pp, there exists NN such that for all n>Nn > N, we have ϵ(n)<1/p(n)\epsilon(n) < 1/p(n).

Intuitive understanding: A negligible function decays faster than the reciprocal of any polynomial. For example:

  • ϵ(n)=2n\epsilon(n) = 2^{-n} is negligible
  • ϵ(n)=n100\epsilon(n) = n^{-100} is negligible
  • ϵ(n)=1/n\epsilon(n) = 1/n is not negligible (because 1/n>1/n21/n > 1/n^2 for large nn)

(4) Why This Definition Ensures PRG Security

If PRG is secure, then:

  • Any polynomial-time algorithm cannot distinguish G(s)G(s) from a truly random string rr with non-negligible advantage
  • This means G(s)G(s) is computationally indistinguishable from a truly random string
  • Therefore, using G(s)G(s) instead of a truly random string does not significantly reduce security
  • This ensures PRG can be safely used in cryptographic applications (e.g., generating key streams)

If there exists a distinguisher that can distinguish with non-negligible advantage, then PRG is insecure and cannot be used in cryptographic applications.


Problem 2: Explain the Role of IV in Stream Cipher

Problem: In stream ciphers, what is the role of Initialization Vector (IV)? Why does IV not need to be secret? What security problems occur if the same combination of key and IV is reused? Please explain in detail.

Complete Solution:

Role of IV

The Initialization Vector (IV) in stream ciphers has the following roles:

  1. Ensures Uniqueness of Key Stream: Even with the same key kk, different IVs produce different key streams

    • Key stream: K=G(k,IV)K = G(k, IV)
    • If IV1IV2IV_1 \neq IV_2, then G(k,IV1)G(k,IV2)G(k, IV_1) \neq G(k, IV_2) (for secure PRG)
  2. Prevents Same Plaintext from Producing Same Ciphertext:

    • If IVIV is different, even if plaintext mm is the same, ciphertext c=mG(k,IV)c = m \oplus G(k, IV) will be different
    • This provides semantic security
  3. Supports Parallel Encryption: Different messages can use different IVs, enabling parallel encryption

Why IV Does Not Need to Be Secret

Reasons why IV does not need to be secret:

  1. IV's Role is to Provide Randomness, Not Confidentiality:

    • Confidentiality is provided by key kk and encryption function
    • IV's role is to ensure each encryption produces different ciphertexts
  2. Even if Attacker Knows IV, Stream Cipher Remains CPA Secure as Long as IV is Random:

    • Attacker knows IVIV and c=mG(k,IV)c = m \oplus G(k, IV)
    • But without knowing key kk, cannot compute G(k,IV)G(k, IV)
    • Therefore cannot obtain information about plaintext mm
  3. Practical Considerations:

    • IV is usually transmitted together with ciphertext
    • Can be stored publicly
    • But must ensure IV uniqueness (cannot be reused)

Security Problems from Reusing Same Key and IV

If the same combination of key and IV is reused, serious security problems occur:

Attack Scenario: Assume using the same (k,IV)(k, IV) to encrypt two messages m1m_1 and m2m_2:

  • c1=m1G(k,IV)c_1 = m_1 \oplus G(k, IV)
  • c2=m2G(k,IV)c_2 = m_2 \oplus G(k, IV)

Attack Method: Attacker can compute: c1c2=(m1G(k,IV))(m2G(k,IV))=m1m2c_1 \oplus c_2 = (m_1 \oplus G(k, IV)) \oplus (m_2 \oplus G(k, IV)) = m_1 \oplus m_2

Security Consequences:

  1. Leaks XOR of Plaintexts: Attacker obtains m1m2m_1 \oplus m_2, which leaks the XOR of two plaintexts
  2. If One Plaintext is Known, Can Recover the Other:
    • If attacker knows m1m_1, then m2=c1c2m1m_2 = c_1 \oplus c_2 \oplus m_1
  3. Pattern Analysis: Attacker can analyze patterns in plaintexts

Practical Example: If m1="HELLO"m_1 = "HELLO" and m2="WORLD"m_2 = "WORLD", attacker computing c1c2c_1 \oplus c_2 may leak partial information.

Conclusion:

  • Absolutely forbidden to reuse the same (k,IV)(k, IV) combination
  • Each encryption must use a different IV
  • IV can be a counter, random number, or timestamp, but must ensure uniqueness

Type 2: Scheme Design

Problem 3: Design a Secure File Transfer Scheme

Problem: Design a secure file transfer scheme that satisfies the following requirements:

  1. File size is 10GB (very large)
  2. Payment information is confidential (No one knows the payment amount)
  3. File integrity (Integrity)
  4. Only Bob can check the file content

Please: (1) Choose appropriate cryptographic tools (2) Explain the scheme's working process in detail (3) Explain how the scheme satisfies each requirement

Complete Solution:

(1) Choose Appropriate Cryptographic Tools

Based on requirements, we need the following tools:

  • Symmetric Encryption: For encrypting large files (efficient)
  • Public Key Encryption: For transmitting symmetric key (only Bob can decrypt)
  • Hash Function: For file integrity verification
  • Digital Signature (optional): For authenticating sender identity

Specific Choices:

  • Symmetric Encryption: AES-256-CTR (suitable for large files, supports parallelization)
  • Public Key Encryption: RSA-OAEP or Elgamal (for encrypting symmetric key)
  • Hash Function: SHA-256 (for integrity)
  • Digital Signature: RSA-FDH or Schnorr (for authentication)

(2) Detailed Scheme Design

Scheme: Hybrid Encryption + Hash + Digital Signature

Step 1: Sender (Alice) Prepares File

  1. Generate random symmetric key: k{0,1}256k \leftarrow \{0,1\}^{256} (AES-256 key)
  2. Choose random IV: IV{0,1}128IV \leftarrow \{0,1\}^{128}
  3. Encrypt file using AES-CTR:
    • Split 10GB file into blocks: F1,F2,,FnF_1, F_2, \ldots, F_n
    • Encrypt each block: Ci=FiAESk(IV+i)C_i = F_i \oplus AES_k(IV + i)
    • Ciphertext file: C=C1C2CnC = C_1 || C_2 || \ldots || C_n
  4. Compute file hash: h=SHA256(F)h = SHA256(F) (compute for entire original file)
  5. Encrypt symmetric key using Bob's public key: Kenc=RSA-OAEPpkB(kIV)K_{enc} = RSA\text{-}OAEP_{pk_B}(k || IV)
  6. (Optional) Sign hash value using Alice's private key: σ=SignskA(h)\sigma = Sign_{sk_A}(h)

Step 2: Send Alice sends to Bob:

  • Encrypted file: CC (10GB)
  • Encrypted key: KencK_{enc}
  • File hash value: hh
  • (Optional) Signature: σ\sigma

Step 3: Receiver (Bob) Verifies and Decrypts

  1. Decrypt key using Bob's private key: (kIV)=RSA-OAEPskB1(Kenc)(k || IV) = RSA\text{-}OAEP_{sk_B}^{-1}(K_{enc})
  2. Decrypt file using AES-CTR:
    • Decrypt each block: Fi=CiAESk(IV+i)F_i = C_i \oplus AES_k(IV + i)
    • Recover file: F=F1F2FnF = F_1 || F_2 || \ldots || F_n
  3. Compute hash of received file: h=SHA256(F)h' = SHA256(F)
  4. Verify integrity: Check if h=hh' = h
    • If equal, file is intact; otherwise file has been tampered with
  5. (Optional) Verify signature: VerifypkA(h,σ)Verify_{pk_A}(h, \sigma)

(3) Explain How Each Requirement is Satisfied

Requirement 1: File Size is 10GB (Very Large)

  • Solution: Use symmetric encryption (AES-CTR)
    • Symmetric encryption is fast, suitable for large files
    • CTR mode supports parallel encryption/decryption
    • 10GB file can be processed efficiently
  • Why Not Use Public Key Encryption Directly for File:
    • Public key encryption is slow (100-1000 times slower than symmetric encryption)
    • RSA can only encrypt data smaller than modulus
    • Therefore use hybrid encryption: public key encrypts small key (256 bits), symmetric encrypts large file (10GB)

Requirement 2: Payment Information Confidential (No One Knows)

  • Solution: Use public key encryption to protect symmetric key
    • Only Bob has private key skBsk_B, only Bob can decrypt KencK_{enc} to obtain kk
    • Without kk, cannot decrypt file CC
    • Therefore, except Bob, no one can know file content (including payment information)
  • Security Guarantee:
    • RSA-OAEP is CPA secure
    • Even if attacker intercepts KencK_{enc}, cannot decrypt (unless can break RSA)

Requirement 3: File Integrity (Integrity)

  • Solution: Use hash function to verify integrity
    • Alice computes hash of original file h=SHA256(F)h = SHA256(F)
    • Bob computes hash of received file h=SHA256(F)h' = SHA256(F') after decryption
    • If h=hh' = h, file is intact; otherwise file has been tampered with
  • Security Guarantee:
    • SHA-256 has collision resistance
    • Attacker cannot find different files producing the same hash value
    • Therefore can detect any tampering

Requirement 4: Only Bob Can Check File Content

  • Solution: Use Bob's public key encryption
    • Symmetric key kk is encrypted using Bob's public key pkBpk_B
    • Only Bob has private key skBsk_B, only Bob can decrypt to obtain kk
    • Without kk, cannot decrypt file
  • Security Guarantee:
    • Public key encryption ensures only private key holder (Bob) can decrypt
    • Even if attacker intercepts all transmitted data, cannot obtain file content

Scheme Summary:

  • ✅ Satisfies large file requirement: Uses efficient symmetric encryption
  • ✅ Satisfies confidentiality requirement: Uses public key encryption to protect key
  • ✅ Satisfies integrity requirement: Uses hash function for verification
  • ✅ Satisfies access control requirement: Only Bob can decrypt

Type 3: Proof Problems

Problem 4: Prove ECB Mode is Not CPA Secure

Problem: Please strictly prove that ECB (Electronic Codebook) mode is not CPA (Chosen Plaintext Attack) secure.

Requirements: (1) Give formal definition of CPA security (2) Construct attacker algorithm (3) Analyze attacker's success probability (4) Draw conclusion

Complete Solution:

(1) Formal Definition of CPA Security

Encryption scheme (Gen,Enc,Dec)(Gen, Enc, Dec) is CPA secure if for all polynomial-time attackers AA, there exists a negligible function ϵ\epsilon such that: Pr[CPA-Game(A)=1]12+ϵ(n)\Pr[\text{CPA-Game}(A) = 1] \leq \frac{1}{2} + \epsilon(n)

CPA Game:

  1. Challenger generates key kGen(1n)k \leftarrow Gen(1^n)
  2. Attacker can query encryption oracle Enck()Enc_k(\cdot) arbitrarily many polynomial times
  3. Attacker chooses two equal-length plaintexts m0,m1m_0, m_1 (m0=m1|m_0| = |m_1|)
  4. Challenger randomly chooses b{0,1}b \leftarrow \{0,1\}, returns challenge ciphertext c=Enck(mb)c^* = Enc_k(m_b)
  5. Attacker continues to query encryption oracle
  6. Attacker outputs b{0,1}b' \in \{0,1\}
  7. If b=bb' = b, attacker wins, game outputs 1; otherwise outputs 0

Attacker's Advantage: AdvCPA(A)=Pr[CPA-Game(A)=1]12\text{Adv}_{CPA}(A) = |\Pr[\text{CPA-Game}(A) = 1] - \frac{1}{2}|

If AdvCPA(A)ϵ(n)\text{Adv}_{CPA}(A) \leq \epsilon(n) (negligible), then scheme is CPA secure.

(2) Construct Attacker Algorithm

ECB Mode Encryption: For message m=P1P2Pnm = P_1 || P_2 || \ldots || P_n (split into blocks), ECB mode encryption is: Ci=Ek(Pi)for i=1,2,,nC_i = E_k(P_i) \quad \text{for } i = 1, 2, \ldots, n Ciphertext: c=C1C2Cnc = C_1 || C_2 || \ldots || C_n

Construction of Attacker AA:

Algorithm AA:

  1. Choose Challenge Plaintexts:

    • Choose two blocks PP and QQ such that PQP \neq Q (e.g., P=0128P = 0^{128}, Q=1128Q = 1^{128})
    • Set m0=PPm_0 = P || P (two identical blocks)
    • Set m1=PQm_1 = P || Q (two different blocks)
    • Send (m0,m1)(m_0, m_1) to challenger
  2. Receive Challenge Ciphertext:

    • Receive challenge ciphertext c=c1c2c^* = c_1^* || c_2^* (two ciphertext blocks)
  3. Distinguish:

    • If c1=c2c_1^* = c_2^*, output b=0b' = 0
    • If c1c2c_1^* \neq c_2^*, output b=1b' = 1

(3) Analyze Attacker's Success Probability

Case 1: b=0b = 0 (Encrypt m0=PPm_0 = P || P)

  • ECB encryption: c1=Ek(P)c_1^* = E_k(P), c2=Ek(P)c_2^* = E_k(P)
  • Since EkE_k is deterministic function, Ek(P)=Ek(P)E_k(P) = E_k(P)
  • Therefore c1=c2c_1^* = c_2^*
  • Attacker observes c1=c2c_1^* = c_2^*, outputs b=0b' = 0
  • Success: b=b=0b' = b = 0

Case 2: b=1b = 1 (Encrypt m1=PQm_1 = P || Q)

  • ECB encryption: c1=Ek(P)c_1^* = E_k(P), c2=Ek(Q)c_2^* = E_k(Q)
  • Since PQP \neq Q and EkE_k is a permutation, Ek(P)Ek(Q)E_k(P) \neq E_k(Q)
  • Therefore c1c2c_1^* \neq c_2^*
  • Attacker observes c1c2c_1^* \neq c_2^*, outputs b=1b' = 1
  • Success: b=b=1b' = b = 1

Success Probability Analysis:

  • Pr[CPA-Game(A)=1]=Pr[b=b]\Pr[\text{CPA-Game}(A) = 1] = \Pr[b' = b]
  • In Case 1: Pr[b=0b=0]=1\Pr[b' = 0 | b = 0] = 1
  • In Case 2: Pr[b=1b=1]=1\Pr[b' = 1 | b = 1] = 1
  • Since bb is uniformly random: Pr[b=0]=Pr[b=1]=12\Pr[b = 0] = \Pr[b = 1] = \frac{1}{2}
  • Therefore: Pr[b=b]=Pr[b=0]Pr[b=0b=0]+Pr[b=1]Pr[b=1b=1]\Pr[b' = b] = \Pr[b = 0] \cdot \Pr[b' = 0 | b = 0] + \Pr[b = 1] \cdot \Pr[b' = 1 | b = 1] =12×1+12×1=1= \frac{1}{2} \times 1 + \frac{1}{2} \times 1 = 1

Attacker's Advantage: AdvCPA(A)=Pr[CPA-Game(A)=1]12=112=12\text{Adv}_{CPA}(A) = |\Pr[\text{CPA-Game}(A) = 1] - \frac{1}{2}| = |1 - \frac{1}{2}| = \frac{1}{2}

(4) Draw Conclusion

  • Attacker AA's success probability is 1 (perfect distinguishing)
  • Attacker's advantage is 12\frac{1}{2}, which is non-negligible (constant, not negligible function)
  • According to CPA security definition, if there exists attacker with non-negligible advantage, then scheme is not CPA secure
  • Therefore, ECB mode is not CPA secure

Further Explanation:

  • Problem with ECB mode: Identical plaintext blocks always produce identical ciphertext blocks
  • This allows attackers to infer plaintext information by observing ciphertext patterns
  • Therefore, ECB mode should not be used in practical applications
  • Should use CBC, CTR, etc., which are secure encryption modes

Problem 5: Prove Insecurity of Schnorr Signature When Random Number is Restricted

Problem: Prove that if in Schnorr signature the random number rr is only chosen from set {r1,r2,r3}\{r_1, r_2, r_3\} (instead of uniformly randomly from entire Zq\mathbb{Z}_q), then the signature scheme is insecure.

Require complete attack construction and success probability analysis.

Complete Solution:

Schnorr Signature Review:

  • Private key: xZqx \in \mathbb{Z}_q
  • Public key: y=gxmodpy = g^x \bmod p
  • Signature: Choose rZqr \leftarrow \mathbb{Z}_q, compute R=grR = g^r, c=H(mR)c = H(m || R), s=r+cxmodqs = r + cx \bmod q
  • Signature: σ=(R,s)\sigma = (R, s)
  • Verification: Check gs=Rycg^s = R \cdot y^c

(1) Attack Scenario Setup

Assume signer uses restricted random number set: r{r1,r2,r3}r \in \{r_1, r_2, r_3\}, instead of randomly from entire Zq\mathbb{Z}_q.

(2) Attacker Construction

Attacker AA's Goal: Recover private key xx or forge signatures

Attack Algorithm:

Step 1: Observe Signatures

  1. Attacker AA queries signature oracle, obtains signature σ=(R,s)\sigma = (R, s) for message mm
  2. AA knows R=grR = g^r, where r{r1,r2,r3}r \in \{r_1, r_2, r_3\}

Step 2: Exhaustive Search for rr For each ri{r1,r2,r3}r_i \in \{r_1, r_2, r_3\}:

  1. Compute Ri=grimodpR_i = g^{r_i} \bmod p
  2. Check if Ri=RR_i = R
  3. If equal, found the used rir_i

Step 3: Recover Private Key Once rir_i is found, attacker can recover private key:

  • From signature: s=ri+cxmodqs = r_i + cx \bmod q
  • Where c=H(mR)c = H(m || R) is known
  • Therefore: x=(sri)c1modqx = (s - r_i) \cdot c^{-1} \bmod q

(3) Success Probability Analysis

Probability of Finding rr:

  • Random number rr is uniformly chosen from {r1,r2,r3}\{r_1, r_2, r_3\}
  • Attacker needs to try at most 3 times
  • Success probability: Pr[find r]=1\Pr[\text{find } r] = 1 (after at most 3 attempts)

Probability of Recovering Private Key:

  • Once rr is found, can deterministically compute xx
  • Success probability: Pr[recover xfind r]=1\Pr[\text{recover } x | \text{find } r] = 1

Overall Success Probability: Pr[attack succeeds]=Pr[find r]×Pr[recover xfind r]=1×1=1\Pr[\text{attack succeeds}] = \Pr[\text{find } r] \times \Pr[\text{recover } x | \text{find } r] = 1 \times 1 = 1

Time Complexity:

  • Need to compute grig^{r_i} at most 3 times
  • Each computation requires O(logri)O(\log r_i) modular exponentiations
  • Total time complexity: O(3×logq)=O(logq)O(3 \times \log q) = O(\log q) (polynomial time)

(4) Forge Signatures

Once attacker obtains private key xx, can:

  1. Generate valid signatures for arbitrary messages mm^*
  2. Choose arbitrary rr^* (even without restriction)
  3. Compute R=grR^* = g^{r^*}, c=H(mR)c^* = H(m^* || R^*), s=r+cxmodqs^* = r^* + c^* x \bmod q
  4. Output signature σ=(R,s)\sigma^* = (R^*, s^*)

(5) Comparison: If rr is Chosen from Entire Zq\mathbb{Z}_q

If rr is uniformly randomly chosen from entire Zq\mathbb{Z}_q:

  • Zq=q|\mathbb{Z}_q| = q (typically q2256q \approx 2^{256})
  • Attacker needs to try average q/2q/2 times to find rr
  • Success probability: Pr[find r]2256\Pr[\text{find } r] \approx 2^{-256} (negligible)
  • Therefore attack is infeasible

(6) Conclusion

  • If random number rr is only chosen from {r1,r2,r3}\{r_1, r_2, r_3\}, attacker can recover private key in polynomial time with probability 1
  • This violates unforgeability of digital signatures (attacker can forge arbitrary signatures)
  • Therefore, Schnorr signature is insecure when random number is restricted
  • Must require rr to be uniformly randomly chosen from entire Zq\mathbb{Z}_q

Type 4: Calculation Problems

Problem 6: Complete RSA Encryption/Decryption Calculation

Problem: Given RSA parameters:

  • p=17p = 17, q=19q = 19
  • Public exponent e=5e = 5
  • Plaintext m=123m = 123

Please complete the following calculations: (1) Compute modulus nn and Euler's totient function ϕ(n)\phi(n) (2) Verify ee is coprime with ϕ(n)\phi(n) (3) Compute private exponent dd (4) Compute ciphertext cc (5) Verify decryption process

Complete Solution:

(1) Compute Modulus and Euler's Totient Function

Modulus: n=p×q=17×19=323n = p \times q = 17 \times 19 = 323

Euler's Totient Function: ϕ(n)=(p1)(q1)=(171)(191)=16×18=288\phi(n) = (p-1)(q-1) = (17-1)(19-1) = 16 \times 18 = 288

(2) Verify ee is Coprime with ϕ(n)\phi(n)

Need to verify gcd(e,ϕ(n))=gcd(5,288)=1\gcd(e, \phi(n)) = \gcd(5, 288) = 1

Using Euclidean Algorithm:

  • 288=5×57+3288 = 5 \times 57 + 3
  • 5=3×1+25 = 3 \times 1 + 2
  • 3=2×1+13 = 2 \times 1 + 1
  • 2=1×2+02 = 1 \times 2 + 0

Therefore gcd(5,288)=1\gcd(5, 288) = 1

(3) Compute Private Exponent dd

Need to find dd such that ed1(modϕ(n))ed \equiv 1 \pmod{\phi(n)}, i.e., 5d1(mod288)5d \equiv 1 \pmod{288}

Using Extended Euclidean Algorithm:

From above calculation:

  • 288=5×57+3288 = 5 \times 57 + 33=2885×573 = 288 - 5 \times 57
  • 5=3×1+25 = 3 \times 1 + 22=53×12 = 5 - 3 \times 1
  • 3=2×1+13 = 2 \times 1 + 11=32×11 = 3 - 2 \times 1

Back Substitution: 1=32×11 = 3 - 2 \times 1 =3(53×1)×1=35+3=2×35= 3 - (5 - 3 \times 1) \times 1 = 3 - 5 + 3 = 2 \times 3 - 5 =2×(2885×57)5=2×288114×55= 2 \times (288 - 5 \times 57) - 5 = 2 \times 288 - 114 \times 5 - 5 =2×288115×5= 2 \times 288 - 115 \times 5

Therefore 1=2×288115×51 = 2 \times 288 - 115 \times 5

So d=115mod288=288115=173d = -115 \bmod 288 = 288 - 115 = 173

Verification: 5×173=8655 \times 173 = 865 865mod288=8653×288=865864=1865 \bmod 288 = 865 - 3 \times 288 = 865 - 864 = 1

Therefore d=173d = 173

(4) Compute Ciphertext cc

Public Key: pk=(n,e)=(323,5)pk = (n, e) = (323, 5) Plaintext: m=123m = 123

Check Plaintext Range: 123<323123 < 323 ✓ (plaintext is in valid range)

Encryption: c=memodn=1235mod323c = m^e \bmod n = 123^5 \bmod 323

Using Modular Exponentiation:

First express exponent 5 in binary: 5=1012=22+20=4+15 = 101_2 = 2^2 + 2^0 = 4 + 1

Compute 1232imod323123^{2^i} \bmod 323:

  • 1231=123mod323=123123^1 = 123 \bmod 323 = 123
  • 1232=15129mod323123^2 = 15129 \bmod 323

Compute 15129mod32315129 \bmod 323:

  • 323×46=14858323 \times 46 = 14858

  • 1512914858=27115129 - 14858 = 271

  • Therefore 1232=271mod323123^2 = 271 \bmod 323

  • 1234=(1232)2=2712mod323123^4 = (123^2)^2 = 271^2 \bmod 323

Compute 2712=73441mod323271^2 = 73441 \bmod 323:

  • 323×227=73321323 \times 227 = 73321
  • 7344173321=12073441 - 73321 = 120
  • Therefore 1234=120mod323123^4 = 120 \bmod 323

Now compute 1235123^5: 1235=1234×1231=120×123mod323123^5 = 123^4 \times 123^1 = 120 \times 123 \bmod 323

Compute 120×123=14760mod323120 \times 123 = 14760 \bmod 323:

  • 323×45=14535323 \times 45 = 14535
  • 1476014535=22514760 - 14535 = 225
  • Therefore c=225c = 225

(5) Verify Decryption Process

Private Key: sk=(n,d)=(323,173)sk = (n, d) = (323, 173) Ciphertext: c=225c = 225

Decryption: m=cdmodn=225173mod323m' = c^d \bmod n = 225^{173} \bmod 323

Using Modular Exponentiation:

Express exponent 173 in binary: 173=101011012=128+32+8+4+1173 = 10101101_2 = 128 + 32 + 8 + 4 + 1

Compute 2252imod323225^{2^i} \bmod 323:

  • 2251=225mod323=225225^1 = 225 \bmod 323 = 225
  • 2252=50625mod323225^2 = 50625 \bmod 323

Compute 50625mod32350625 \bmod 323:

  • 323×156=50388323 \times 156 = 50388

  • 5062550388=23750625 - 50388 = 237

  • Therefore 2252=237mod323225^2 = 237 \bmod 323

  • 2254=(2252)2=2372mod323225^4 = (225^2)^2 = 237^2 \bmod 323

Compute 2372=56169mod323237^2 = 56169 \bmod 323:

  • 323×173=55879323 \times 173 = 55879

  • 5616955879=29056169 - 55879 = 290

  • Therefore 2254=290mod323225^4 = 290 \bmod 323

  • 2258=(2254)2=2902mod323225^8 = (225^4)^2 = 290^2 \bmod 323

Compute 2902=84100mod323290^2 = 84100 \bmod 323:

  • 323×260=83980323 \times 260 = 83980

  • 8410083980=12084100 - 83980 = 120

  • Therefore 2258=120mod323225^8 = 120 \bmod 323

  • 22516=(2258)2=1202mod323225^{16} = (225^8)^2 = 120^2 \bmod 323

Compute 1202=14400mod323120^2 = 14400 \bmod 323:

  • 323×44=14212323 \times 44 = 14212

  • 1440014212=18814400 - 14212 = 188

  • Therefore 22516=188mod323225^{16} = 188 \bmod 323

  • 22532=(22516)2=1882mod323225^{32} = (225^{16})^2 = 188^2 \bmod 323

Compute 1882=35344mod323188^2 = 35344 \bmod 323:

  • 323×109=35207323 \times 109 = 35207

  • 3534435207=13735344 - 35207 = 137

  • Therefore 22532=137mod323225^{32} = 137 \bmod 323

  • 22564=(22532)2=1372mod323225^{64} = (225^{32})^2 = 137^2 \bmod 323

Compute 1372=18769mod323137^2 = 18769 \bmod 323:

  • 323×58=18734323 \times 58 = 18734

  • 1876918734=3518769 - 18734 = 35

  • Therefore 22564=35mod323225^{64} = 35 \bmod 323

  • 225128=(22564)2=352mod323225^{128} = (225^{64})^2 = 35^2 \bmod 323

Compute 352=1225mod32335^2 = 1225 \bmod 323:

  • 323×3=969323 \times 3 = 969
  • 1225969=2561225 - 969 = 256
  • Therefore 225128=256mod323225^{128} = 256 \bmod 323

Now compute 225173225^{173}: 225173=225128×22532×2258×2254×2251225^{173} = 225^{128} \times 225^{32} \times 225^8 \times 225^4 \times 225^1 =256×137×120×290×225mod323= 256 \times 137 \times 120 \times 290 \times 225 \bmod 323

Compute step by step:

  • 256×137=35072mod323256 \times 137 = 35072 \bmod 323

Compute 35072mod32335072 \bmod 323:

  • 323×108=34884323 \times 108 = 34884

  • 3507234884=18835072 - 34884 = 188

  • Therefore intermediate result = 188188

  • 188×120=22560mod323188 \times 120 = 22560 \bmod 323

Compute 22560mod32322560 \bmod 323:

  • 323×69=22287323 \times 69 = 22287

  • 2256022287=27322560 - 22287 = 273

  • Therefore intermediate result = 273273

  • 273×290=79170mod323273 \times 290 = 79170 \bmod 323

Compute 79170mod32379170 \bmod 323:

  • 323×245=79135323 \times 245 = 79135

  • 7917079135=3579170 - 79135 = 35

  • Therefore intermediate result = 3535

  • 35×225=7875mod32335 \times 225 = 7875 \bmod 323

Compute 7875mod3237875 \bmod 323:

  • 323×24=7752323 \times 24 = 7752
  • 78757752=1237875 - 7752 = 123
  • Therefore m=123m' = 123

Verification:

  • Original plaintext: m=123m = 123
  • Decrypted plaintext: m=123m' = 123
  • m=mm = m'

Decryption Successful!


Problem 7: Complete Elgamal Encryption/Decryption Calculation

Problem: Given Elgamal encryption parameters:

  • p=23p = 23, g=5g = 5
  • Private key x=6x = 6
  • Plaintext m=7m = 7
  • Random number r=3r = 3

Please complete: (1) Compute public key yy (2) Compute ciphertext (c1,c2)(c_1, c_2) (3) Verify decryption process

Complete Solution:

(1) Compute Public Key yy

Private Key: x=6x = 6 Generator: g=5g = 5 Modulus: p=23p = 23

Public Key: y=gxmodp=56mod23y = g^x \bmod p = 5^6 \bmod 23

Compute 56mod235^6 \bmod 23:

  • 52=25mod23=25^2 = 25 \bmod 23 = 2
  • 54=(52)2=22=4mod23=45^4 = (5^2)^2 = 2^2 = 4 \bmod 23 = 4
  • 56=54×52=4×2=8mod23=85^6 = 5^4 \times 5^2 = 4 \times 2 = 8 \bmod 23 = 8

Therefore y=8y = 8

Public Key: pk=(p,g,y)=(23,5,8)pk = (p, g, y) = (23, 5, 8)

(2) Compute Ciphertext (c1,c2)(c_1, c_2)

Plaintext: m=7m = 7 Random Number: r=3r = 3 Public Key: y=8y = 8

Elgamal Encryption Formula:

  • c1=grmodpc_1 = g^r \bmod p
  • c2=myrmodpc_2 = m \cdot y^r \bmod p

Compute c1c_1: c1=grmodp=53mod23=125mod23c_1 = g^r \bmod p = 5^3 \bmod 23 = 125 \bmod 23

Compute 125mod23125 \bmod 23:

  • 23×5=11523 \times 5 = 115
  • 125115=10125 - 115 = 10

Therefore c1=10c_1 = 10

Compute c2c_2: c2=myrmodp=783mod23c_2 = m \cdot y^r \bmod p = 7 \cdot 8^3 \bmod 23

First compute 83mod238^3 \bmod 23:

  • 81=8mod23=88^1 = 8 \bmod 23 = 8
  • 82=64mod23=642×23=6446=188^2 = 64 \bmod 23 = 64 - 2 \times 23 = 64 - 46 = 18
  • 83=82×8=18×8=144mod238^3 = 8^2 \times 8 = 18 \times 8 = 144 \bmod 23

Compute 144mod23144 \bmod 23:

  • 23×6=13823 \times 6 = 138
  • 144138=6144 - 138 = 6

Therefore 83=6mod238^3 = 6 \bmod 23

So c2=7×6=42mod23=421×23=19c_2 = 7 \times 6 = 42 \bmod 23 = 42 - 1 \times 23 = 19

Ciphertext: c=(c1,c2)=(10,19)c = (c_1, c_2) = (10, 19)

(3) Verify Decryption Process

Private Key: x=6x = 6 Ciphertext: c=(10,19)c = (10, 19)

Elgamal Decryption Formula: m=c2(c1x)1modpm = c_2 \cdot (c_1^x)^{-1} \bmod p

Step 1: Compute c1xc_1^x c1x=106mod23c_1^x = 10^6 \bmod 23

Compute 106mod2310^6 \bmod 23:

  • 102=100mod23=1004×23=10092=810^2 = 100 \bmod 23 = 100 - 4 \times 23 = 100 - 92 = 8
  • 104=(102)2=82=64mod23=1810^4 = (10^2)^2 = 8^2 = 64 \bmod 23 = 18
  • 106=104×102=18×8=144mod23=610^6 = 10^4 \times 10^2 = 18 \times 8 = 144 \bmod 23 = 6

Therefore c1x=6c_1^x = 6

Step 2: Compute (c1x)1mod23(c_1^x)^{-1} \bmod 23

Need to find 61mod236^{-1} \bmod 23, i.e., find dd such that 6d1(mod23)6d \equiv 1 \pmod{23}

Using Extended Euclidean Algorithm:

  • 23=6×3+523 = 6 \times 3 + 5
  • 6=5×1+16 = 5 \times 1 + 1
  • 5=1×5+05 = 1 \times 5 + 0

Back substitution:

  • 1=65×11 = 6 - 5 \times 1
  • 5=236×35 = 23 - 6 \times 3
  • 1=6(236×3)=623+6×3=6×4231 = 6 - (23 - 6 \times 3) = 6 - 23 + 6 \times 3 = 6 \times 4 - 23

Therefore 614(mod23)6^{-1} \equiv 4 \pmod{23}

Verify: 6×4=241(mod23)6 \times 4 = 24 \equiv 1 \pmod{23}

Step 3: Compute Plaintext m=c2(c1x)1modp=19×4mod23=76mod23m = c_2 \cdot (c_1^x)^{-1} \bmod p = 19 \times 4 \bmod 23 = 76 \bmod 23

Compute 76mod2376 \bmod 23:

  • 23×3=6923 \times 3 = 69
  • 7669=776 - 69 = 7

Therefore m=7m = 7

Verification:

  • Original plaintext: m=7m = 7
  • Decrypted plaintext: m=7m = 7
  • They are equal ✓

Decryption Successful!


Problem 8: Complete Schnorr Signature Calculation

Problem: Given Schnorr signature parameters:

  • p=23p = 23, q=11q = 11 (112211 | 22 ✓)
  • g=5g = 5 (generator)
  • Private key x=3x = 3
  • Message m=7m = 7
  • Random number r=4r = 4
  • Hash function: H(mR)=(mR)mod11H(m || R) = (m \cdot R) \bmod 11 (simplified)

Please complete: (1) Compute public key yy (2) Generate signature (R,s)(R, s) (3) Verify signature

Complete Solution:

(1) Compute Public Key yy

Private Key: x=3x = 3 Generator: g=5g = 5 Modulus: p=23p = 23

Public Key: y=gxmodp=53mod23=125mod23=1255×23=125115=10y = g^x \bmod p = 5^3 \bmod 23 = 125 \bmod 23 = 125 - 5 \times 23 = 125 - 115 = 10

Therefore y=10y = 10

Public Key: pk=y=10pk = y = 10

(2) Generate Signature (R,s)(R, s)

Message: m=7m = 7 Random Number: r=4r = 4

Step 1: Compute Commitment RR R=grmodp=54mod23R = g^r \bmod p = 5^4 \bmod 23

Compute 54mod235^4 \bmod 23:

  • 52=25mod23=25^2 = 25 \bmod 23 = 2
  • 54=(52)2=22=4mod23=45^4 = (5^2)^2 = 2^2 = 4 \bmod 23 = 4

Therefore R=4R = 4

Step 2: Compute Challenge cc c=H(mR)=(mR)mod11=(7×4)mod11=28mod11=6c = H(m || R) = (m \cdot R) \bmod 11 = (7 \times 4) \bmod 11 = 28 \bmod 11 = 6

Therefore c=6c = 6

Step 3: Compute Response ss s=r+cxmodq=4+6×3mod11=4+18mod11=22mod11=0s = r + cx \bmod q = 4 + 6 \times 3 \bmod 11 = 4 + 18 \bmod 11 = 22 \bmod 11 = 0

Therefore s=0s = 0

Signature: σ=(R,s)=(4,0)\sigma = (R, s) = (4, 0)

(3) Verify Signature

Public Key: y=10y = 10 Message: m=7m = 7 Signature: σ=(R,s)=(4,0)\sigma = (R, s) = (4, 0)

Verification Formula: Check if gs=Ryc(modp)g^s = R \cdot y^c \pmod{p}

Step 1: Recompute Challenge cc c=H(mR)=(7×4)mod11=6c = H(m || R) = (7 \times 4) \bmod 11 = 6

Step 2: Compute Left Side gsg^s gs=50mod23=1g^s = 5^0 \bmod 23 = 1

Step 3: Compute Right Side RycR \cdot y^c Ryc=4×106mod23R \cdot y^c = 4 \times 10^6 \bmod 23

First compute 106mod2310^6 \bmod 23:

  • 102=100mod23=1004×23=10092=810^2 = 100 \bmod 23 = 100 - 4 \times 23 = 100 - 92 = 8
  • 104=(102)2=82=64mod23=1810^4 = (10^2)^2 = 8^2 = 64 \bmod 23 = 18
  • 106=104×102=18×8=144mod23=1446×23=144138=610^6 = 10^4 \times 10^2 = 18 \times 8 = 144 \bmod 23 = 144 - 6 \times 23 = 144 - 138 = 6

Therefore Ryc=4×6=24mod23=2423=1R \cdot y^c = 4 \times 6 = 24 \bmod 23 = 24 - 23 = 1

Step 4: Compare

  • Left side: gs=1g^s = 1
  • Right side: Ryc=1R \cdot y^c = 1
  • 1=11 = 1

Verification Passed! Signature is Valid!


Part 2: Public Key Cryptography

Type 1: Concept Explanation

Problem 9: Explain Security of Diffie-Hellman Key Agreement

Problem: Please explain in detail the security of Diffie-Hellman key agreement protocol, including: (1) Basic principles of the protocol (2) Which hard problem the security is based on (3) Why attackers cannot obtain the shared key (4) Security assumptions of the protocol

Complete Solution:

(1) Basic Principles of the Protocol

Diffie-Hellman Key Agreement Protocol allows two communicating parties to establish a shared key over an insecure channel.

Protocol Steps:

  1. Public Parameters: Choose large prime pp and generator gZpg \in \mathbb{Z}_p^*, parameters (p,g)(p, g) are public
  2. Alice:
    • Randomly choose private key aZp1a \leftarrow \mathbb{Z}_{p-1}
    • Compute public key A=gamodpA = g^a \bmod p
    • Send AA to Bob
  3. Bob:
    • Randomly choose private key bZp1b \leftarrow \mathbb{Z}_{p-1}
    • Compute public key B=gbmodpB = g^b \bmod p
    • Send BB to Alice
  4. Shared Key:
    • Alice computes: K=Bamodp=(gb)amodp=gabmodpK = B^a \bmod p = (g^b)^a \bmod p = g^{ab} \bmod p
    • Bob computes: K=Abmodp=(ga)bmodp=gabmodpK = A^b \bmod p = (g^a)^b \bmod p = g^{ab} \bmod p
    • Both parties obtain the same shared key K=gabmodpK = g^{ab} \bmod p

(2) Which Hard Problem Security is Based On

The security of Diffie-Hellman key agreement is based on the hardness of the Discrete Logarithm Problem (DLP).

Discrete Logarithm Problem: Given group GG (e.g., Zp\mathbb{Z}_p^*), generator gg, and element h=gxh = g^x, computing x=logghx = \log_g h is computationally infeasible.

In DH Protocol:

  • Attacker sees A=gaA = g^a and B=gbB = g^b
  • Attacker wants to compute K=gabK = g^{ab}
  • This is equivalent to computing Diffie-Hellman problem (CDH)
  • Hardness of CDH is based on hardness of DLP

(3) Why Attackers Cannot Obtain Shared Key

Information Observed by Attacker:

  • Public parameters: (p,g)(p, g)
  • Alice's public key: A=gamodpA = g^a \bmod p
  • Bob's public key: B=gbmodpB = g^b \bmod p

What Attacker Wants to Compute:

  • Shared key: K=gabmodpK = g^{ab} \bmod p

Attacker's Difficulties:

Method 1: Directly Compute gabg^{ab}

  • Attacker needs to know aa or bb
  • But aa and bb are private keys, only known to Alice and Bob
  • Attacker cannot compute aa from A=gaA = g^a (this is DLP, computationally infeasible)

Method 2: Compute KK from AA and BB

  • This is equivalent to solving Computational Diffie-Hellman (CDH) problem
  • CDH problem is computationally infeasible (based on DLP hardness)

Method 3: Man-in-the-Middle Attack (MITM)

  • Attacker can intercept AA and BB, and send own public key
  • But this requires attacker to be able to modify communication channel
  • In standard DH protocol, assume communication channel is authenticated (or use digital signatures to prevent MITM)

(4) Security Assumptions of the Protocol

Computational Assumptions:

  1. Discrete Logarithm Assumption (DL Assumption):

    • In group Zp\mathbb{Z}_p^*, given gg and gxg^x, computing xx is computationally infeasible
    • This is the foundation of protocol security
  2. Computational Diffie-Hellman Assumption (CDH Assumption):

    • Given gg, gag^a, gbg^b, computing gabg^{ab} is computationally infeasible
    • Directly guarantees security of shared key
  3. Decisional Diffie-Hellman Assumption (DDH Assumption) (stronger assumption):

    • Given gg, gag^a, gbg^b, ZZ, deciding whether Z=gabZ = g^{ab} or ZZ is a random element is computationally infeasible
    • Used for stronger security guarantees

Protocol Assumptions:

  1. Parameter Selection:

    • pp must be a large prime (typically 2048 bits or larger)
    • gg must be a generator (or large-order element)
    • Parameters must be correctly generated
  2. Randomness:

    • Private keys aa and bb must be uniformly randomly chosen from Zp1\mathbb{Z}_{p-1}
    • Cannot use weak random number generators
  3. Communication Security:

    • Standard DH does not provide authentication, vulnerable to man-in-the-middle attacks
    • In practice, need to combine with digital signatures or certificates

Security Summary:

  • DH key agreement is secure under DLP/CDH assumptions
  • Attackers cannot compute shared key from public information
  • But need to prevent man-in-the-middle attacks (use authentication mechanisms)

Type 2: Scheme Design

Problem 10: Design a Secure Electronic Voting Scheme

Problem: Design an electronic voting scheme using homomorphic encryption that satisfies the following requirements:

  1. Each voter can only vote once
  2. Votes are confidential (No one knows specific voting content)
  3. Can correctly count voting results
  4. Voters can verify their votes are correctly recorded

Please: (1) Choose appropriate cryptographic tools (2) Describe voting process in detail (3) Explain how each requirement is satisfied

Complete Solution:

(1) Choose Appropriate Cryptographic Tools

Based on requirements, we need the following tools:

  • Homomorphic Encryption: Allows computation on ciphertexts, used for vote counting
  • Zero Knowledge Proof: Used to prove vote validity (vote value is in allowed range)
  • Digital Signature: Used to authenticate voter identity
  • Commitment Protocol: Used to ensure vote binding

Specific Choices:

  • Homomorphic Encryption: Elgamal homomorphic encryption (supports multiplicative homomorphism)
  • Zero Knowledge Proof: Schnorr signature or Sigma protocol
  • Digital Signature: RSA-FDH or Schnorr
  • Commitment Protocol: Pedersen commitment

(2) Detailed Scheme Design

Scheme: Voting Scheme Based on Elgamal Homomorphic Encryption

Setup Phase:

  1. Choose Elgamal parameters: large prime pp, generator gZpg \in \mathbb{Z}_p^*
  2. Voting authority generates key pair: private key xx, public key y=gxmodpy = g^x \bmod p
  3. Public parameters: (p,g,y)(p, g, y)

Voting Phase (Voter ViV_i):

  1. Identity Authentication: Voter uses digital signature to prove identity
  2. Choose Vote: Voter chooses b{0,1}b \in \{0, 1\} (support or oppose)
  3. Encrypt Vote:
    • Randomly choose rZp1r \leftarrow \mathbb{Z}_{p-1}
    • Compute: c1=grmodpc_1 = g^r \bmod p
    • Compute: c2=gbyrmodpc_2 = g^b \cdot y^r \bmod p (Note: here gbg^b represents vote, b{0,1}b \in \{0,1\})
    • Ciphertext: C=(c1,c2)C = (c_1, c_2)
  4. Zero Knowledge Proof: Voter generates ZK proof proving b{0,1}b \in \{0, 1\} (using OR proof)
  5. Submit: Voter submits (C,ZK proof,signature)(C, \text{ZK proof}, \text{signature})

Counting Phase:

  1. Verify All Votes:
    • Verify each voter's identity (digital signature)
    • Verify each vote's ZK proof (ensure b{0,1}b \in \{0,1\})
  2. Homomorphic Computation:
    • For all valid vote ciphertexts Ci=(c1,i,c2,i)C_i = (c_{1,i}, c_{2,i}), compute:
    • Ctotal=i=1nCi=(i=1nc1,i,i=1nc2,i)C_{total} = \prod_{i=1}^n C_i = (\prod_{i=1}^n c_{1,i}, \prod_{i=1}^n c_{2,i})
    • Due to Elgamal's multiplicative homomorphism: Ctotal=(gri,gbiyri)C_{total} = (g^{\sum r_i}, g^{\sum b_i} \cdot y^{\sum r_i})
  3. Decrypt Counting Result:
    • Use private key xx to decrypt CtotalC_{total}
    • Compute: gbi=c2,total(c1,total)xmodpg^{\sum b_i} = c_{2,total} \cdot (c_{1,total})^{-x} \bmod p
    • Compute discrete logarithm: bi=logg(gbi)\sum b_i = \log_g (g^{\sum b_i}) (since bi\sum b_i is small, can exhaustively search)
    • Counting result: Support votes = bi\sum b_i, Oppose votes = nbin - \sum b_i

(3) Explain How Each Requirement is Satisfied

Requirement 1: Each Voter Can Only Vote Once

  • Solution: Use digital signature to authenticate identity
    • Each voter signs vote with own private key
    • Voting authority maintains list of voters who have voted
    • If same identity votes again, reject second vote
  • Technical Details:
    • Voter submits (C,σ)(C, \sigma), where σ=SignskV(Ctimestamp)\sigma = Sign_{sk_V}(C || timestamp)
    • Voting authority verifies signature and checks if identity has voted

Requirement 2: Votes are Confidential (No One Knows Specific Voting Content)

  • Solution: Use Elgamal encryption
    • Each vote bb is encrypted as C=(c1,c2)C = (c_1, c_2)
    • Only voting authority has private key xx, can decrypt
    • But voting authority can only see counting result, cannot see individual votes (if using threshold decryption)
  • Technical Details:
    • Use random number rr to ensure same vote produces different ciphertexts
    • Encryption is CPA secure
    • Can further use threshold encryption, requiring multiple authorities to cooperate for decryption

Requirement 3: Can Correctly Count Voting Results

  • Solution: Use homomorphic encryption
    • Elgamal supports multiplicative homomorphism: Enc(b1)Enc(b2)=Enc(b1+b2)Enc(b_1) \cdot Enc(b_2) = Enc(b_1 + b_2) (in exponent)
    • Multiply all vote ciphertexts to get encryption of total votes
    • After decryption, get bi\sum b_i, which is support votes
  • Technical Details:
    • Homomorphism: Enc(b1)Enc(b2)=(gr1+r2,gb1+b2yr1+r2)Enc(b_1) \cdot Enc(b_2) = (g^{r_1+r_2}, g^{b_1+b_2} \cdot y^{r_1+r_2})
    • After decryption, get gb1+b2g^{b_1+b_2}, compute discrete logarithm to get b1+b2b_1 + b_2
    • For nn votes, bin\sum b_i \leq n, can exhaustively compute discrete logarithm

Requirement 4: Voters Can Verify Their Votes are Correctly Recorded

  • Solution: Use commitment and verification mechanism
    • When voter submits vote, also submit commitment commit=Commit(b,r)commit = Commit(b, r')
    • Voting authority publishes all vote ciphertexts (without correspondence)
    • Voters can verify their ciphertext is in the list
    • After counting, voters can verify commitment (optional)
  • Technical Details:
    • Voter computes commit=H(brID)commit = H(b || r' || ID)
    • Submits (C,commit)(C, commit)
    • Voting authority publishes list of all (Ci,commiti)(C_i, commit_i)
    • Voter checks own (C,commit)(C, commit) is in list
    • After counting, can reveal bb and rr' to verify commitment

Scheme Summary:

  • ✅ Satisfies uniqueness: Digital signature prevents duplicate voting
  • ✅ Satisfies confidentiality: Elgamal encryption protects vote content
  • ✅ Satisfies correctness: Homomorphic encryption supports correct counting
  • ✅ Satisfies verifiability: Commitment mechanism allows verification

Type 3: Proof Problems

Problem 11: Prove Relationship Between Three Security Properties of Hash Functions

Problem: Prove the relationship between three security properties of hash functions: (1) Collision Resistance (2) Second Preimage Resistance (3) Preimage Resistance

Please prove:

  • Collision Resistance \Rightarrow Second Preimage Resistance
  • Second Preimage Resistance \Rightarrow Preimage Resistance (in random oracle model)

Complete Solution:

(1) Define Three Security Properties

Preimage Resistance: For all polynomial-time attackers AA, there exists negligible function ϵ\epsilon such that: Pr[x{0,1},y=H(x),A(y)=x and H(x)=y]ϵ(n)\Pr[x \leftarrow \{0,1\}^*, y = H(x), A(y) = x' \text{ and } H(x') = y] \leq \epsilon(n) That is: Given hash value yy, finding xx such that H(x)=yH(x) = y is computationally infeasible.

Second Preimage Resistance: For all polynomial-time attackers AA, there exists negligible function ϵ\epsilon such that: Pr[x{0,1},A(x)=xx and H(x)=H(x)]ϵ(n)\Pr[x \leftarrow \{0,1\}^*, A(x) = x' \neq x \text{ and } H(x') = H(x)] \leq \epsilon(n) That is: Given xx, finding xxx' \neq x such that H(x)=H(x)H(x) = H(x') is computationally infeasible.

Collision Resistance: For all polynomial-time attackers AA, there exists negligible function ϵ\epsilon such that: Pr[A()=(x,x) and xx and H(x)=H(x)]ϵ(n)\Pr[A() = (x, x') \text{ and } x \neq x' \text{ and } H(x) = H(x')] \leq \epsilon(n) That is: Finding arbitrary x,xx, x' such that xxx \neq x' but H(x)=H(x)H(x) = H(x') is computationally infeasible.

(2) Prove: Collision Resistance \Rightarrow Second Preimage Resistance

Proof Method: Proof by contradiction

Assume hash function HH is collision resistant but not second preimage resistant. We will construct an algorithm to find collision, contradicting collision resistance.

Construct Attacker AcollisionA_{collision}:

Algorithm AcollisionA_{collision}:

  1. Randomly choose x{0,1}x \leftarrow \{0,1\}^*
  2. Call second preimage attacker A2ndA_{2nd} (assume exists), input xx
  3. A2ndA_{2nd} outputs xxx' \neq x such that H(x)=H(x)H(x') = H(x)
  4. Output collision (x,x)(x, x')

Success Probability Analysis:

  • If A2ndA_{2nd} can find second preimage with non-negligible probability δ\delta
  • Then AcollisionA_{collision} can find collision with same probability δ\delta
  • This contradicts assumption that HH is collision resistant

Conclusion:

  • If HH is collision resistant, then HH must be second preimage resistant
  • Therefore: Collision Resistance \Rightarrow Second Preimage Resistance

(3) Prove: Second Preimage Resistance \Rightarrow Preimage Resistance (in Random Oracle Model)

Proof Method: In random oracle model, if hash function is second preimage resistant, then it is also preimage resistant.

Proof Idea: In random oracle model, hash function HH behaves like a random function. If HH is second preimage resistant, then:

  1. Properties of Random Oracle:

    • For each input xx, H(x)H(x) is uniformly random
    • Outputs for different inputs are independent
  2. Difficulty of Preimage Attack:

    • Given hash value yy, attacker needs to find xx such that H(x)=yH(x) = y
    • Since HH is random, attacker can only search by querying HH
    • Each query succeeds with probability approximately 2n2^{-n} (nn is output length)
    • Need average 2n2^n queries to find preimage
  3. Relationship with Second Preimage Resistance:

    • If HH is second preimage resistant, then given xx, finding xx' such that H(x)=H(x)H(x') = H(x) is difficult
    • In random oracle model, this is equivalent to preimage resistance
    • Because if can find preimage, then can find second preimage (by first randomly choosing xx, then finding preimage of H(x)H(x))

Formal Proof (simplified): Assume there exists preimage attacker ApreimageA_{preimage} that can find preimage with non-negligible probability. Construct second preimage attacker A2ndA_{2nd}:

Algorithm A2nd(x)A_{2nd}(x):

  1. Compute y=H(x)y = H(x)
  2. Call Apreimage(y)A_{preimage}(y), obtain xx'
  3. If xxx' \neq x and H(x)=yH(x') = y, output xx'
  4. Otherwise output failure

Success Probability:

  • If ApreimageA_{preimage} successfully finds preimage, and xxx' \neq x (high probability, since input space is large)
  • Then A2ndA_{2nd} successfully finds second preimage
  • This contradicts second preimage resistance

Conclusion:

  • In random oracle model, Second Preimage Resistance \Rightarrow Preimage Resistance
  • Note: This conclusion depends on random oracle model, may not hold for actual hash functions

(4) Summary

Relationship between three security properties:

  • Collision Resistance \Rightarrow Second Preimage Resistance (unconditionally holds)
  • Second Preimage Resistance \Rightarrow Preimage Resistance (holds in random oracle model)
  • Preimage Resistance ⇏\not\Rightarrow Second Preimage Resistance (does not hold)
  • Second Preimage Resistance ⇏\not\Rightarrow Collision Resistance (does not hold)

Practical Significance:

  • Collision resistance is the strongest property
  • When designing hash functions, usually directly prove collision resistance
  • If hash function is collision resistant, automatically satisfies other two properties

Type 4: Calculation Problems

Problem 12: Complete Diffie-Hellman Key Agreement Calculation

Problem: Given Diffie-Hellman parameters:

  • p=23p = 23, g=5g = 5 (55 is a generator of Z23\mathbb{Z}_{23}^*)
  • Alice chooses private key a=6a = 6
  • Bob chooses private key b=15b = 15

Please complete: (1) Compute Alice's and Bob's public keys (2) Compute shared keys calculated by both parties (3) Verify both parties obtain the same key (4) Directly compute gabg^{ab} to verify result

Complete Solution:

(1) Compute Alice's and Bob's Public Keys

Alice's Public Key: A=gamodp=56mod23A = g^a \bmod p = 5^6 \bmod 23

Compute 56mod235^6 \bmod 23:

  • 52=25mod23=2523=25^2 = 25 \bmod 23 = 25 - 23 = 2
  • 54=(52)2=22=4mod23=45^4 = (5^2)^2 = 2^2 = 4 \bmod 23 = 4
  • 56=54×52=4×2=8mod23=85^6 = 5^4 \times 5^2 = 4 \times 2 = 8 \bmod 23 = 8

Therefore A=8A = 8

Bob's Public Key: B=gbmodp=515mod23B = g^b \bmod p = 5^{15} \bmod 23

Compute 515mod235^{15} \bmod 23:

  • 15=8+4+2+1=23+22+21+2015 = 8 + 4 + 2 + 1 = 2^3 + 2^2 + 2^1 + 2^0
  • 51=55^1 = 5
  • 52=25^2 = 2 (already computed)
  • 54=45^4 = 4 (already computed)
  • 58=(54)2=42=16mod23=165^8 = (5^4)^2 = 4^2 = 16 \bmod 23 = 16
  • 515=58×54×52×51=16×4×2×5=640mod235^{15} = 5^8 \times 5^4 \times 5^2 \times 5^1 = 16 \times 4 \times 2 \times 5 = 640 \bmod 23

Compute 640mod23640 \bmod 23:

  • 23×27=62123 \times 27 = 621
  • 640621=19640 - 621 = 19

Therefore B=19B = 19

(2) Compute Shared Keys Calculated by Both Parties

Shared Key Calculated by Alice: KA=Bamodp=196mod23K_A = B^a \bmod p = 19^6 \bmod 23

Compute 196mod2319^6 \bmod 23:

  • 19mod23=1919 \bmod 23 = 19 (since 19<2319 < 23)
  • 192=361mod23=36115×23=361345=1619^2 = 361 \bmod 23 = 361 - 15 \times 23 = 361 - 345 = 16
  • 194=(192)2=162=256mod23=25611×23=256253=319^4 = (19^2)^2 = 16^2 = 256 \bmod 23 = 256 - 11 \times 23 = 256 - 253 = 3
  • 196=194×192=3×16=48mod23=482×23=4846=219^6 = 19^4 \times 19^2 = 3 \times 16 = 48 \bmod 23 = 48 - 2 \times 23 = 48 - 46 = 2

Therefore KA=2K_A = 2

Shared Key Calculated by Bob: KB=Abmodp=815mod23K_B = A^b \bmod p = 8^{15} \bmod 23

Compute 815mod238^{15} \bmod 23:

  • 81=88^1 = 8
  • 82=64mod23=642×23=6446=188^2 = 64 \bmod 23 = 64 - 2 \times 23 = 64 - 46 = 18
  • 84=(82)2=182=324mod23=32414×23=324322=28^4 = (8^2)^2 = 18^2 = 324 \bmod 23 = 324 - 14 \times 23 = 324 - 322 = 2
  • 88=(84)2=22=4mod23=48^8 = (8^4)^2 = 2^2 = 4 \bmod 23 = 4
  • 15=8+4+2+115 = 8 + 4 + 2 + 1
  • 815=88×84×82×81=4×2×18×8=1152mod238^{15} = 8^8 \times 8^4 \times 8^2 \times 8^1 = 4 \times 2 \times 18 \times 8 = 1152 \bmod 23

Compute 1152mod231152 \bmod 23:

  • 23×50=115023 \times 50 = 1150
  • 11521150=21152 - 1150 = 2

Therefore KB=2K_B = 2

(3) Verify Both Parties Obtain the Same Key

  • Key calculated by Alice: KA=2K_A = 2
  • Key calculated by Bob: KB=2K_B = 2
  • KA=KB=2K_A = K_B = 2

Shared Key: K=2K = 2

(4) Directly Compute gabg^{ab} to Verify Result

gab=56×15=590mod23g^{ab} = 5^{6 \times 15} = 5^{90} \bmod 23

Since 5221(mod23)5^{22} \equiv 1 \pmod{23} (by Fermat's little theorem, because 55 is coprime with 2323, and order of 55 divides 2222), we can simplify:

  • 90=4×22+290 = 4 \times 22 + 2
  • 590=(522)4×5214×22(mod23)5^{90} = (5^{22})^4 \times 5^2 \equiv 1^4 \times 2 \equiv 2 \pmod{23}

Therefore gab=2g^{ab} = 2, consistent with previous calculation ✓

Verification Complete!


Problem 13: Complete Elliptic Curve Point Operation Calculation

Problem: Given elliptic curve E:y2=x3+2x+3(mod11)E: y^2 = x^3 + 2x + 3 \pmod{11}, point P=(2,2)P = (2, 2).

Please complete: (1) Verify point PP is on the curve (2) Compute 2P2P (point doubling) (3) If Q=(3,6)Q = (3, 6) is also on the curve, compute P+QP + Q (point addition)

Complete Solution:

(1) Verify Point PP is on the Curve

Curve Equation: y2=x3+2x+3(mod11)y^2 = x^3 + 2x + 3 \pmod{11}

Point P=(2,2)P = (2, 2):

  • Left side: y2=22=4mod11=4y^2 = 2^2 = 4 \bmod 11 = 4
  • Right side: x3+2x+3=23+2×2+3=8+4+3=15mod11=4x^3 + 2x + 3 = 2^3 + 2 \times 2 + 3 = 8 + 4 + 3 = 15 \bmod 11 = 4

4=44 = 4 ✓, therefore point P=(2,2)P = (2, 2) is on the curve.

(2) Compute 2P2P (Point Doubling)

Point Doubling Formula (P=PP = P):

  • Slope: λ=3x12+a2y1modp\lambda = \frac{3x_1^2 + a}{2y_1} \bmod p
  • x3=λ22x1modpx_3 = \lambda^2 - 2x_1 \bmod p
  • y3=λ(x1x3)y1modpy_3 = \lambda(x_1 - x_3) - y_1 \bmod p

Given Parameters:

  • P=(x1,y1)=(2,2)P = (x_1, y_1) = (2, 2)
  • a=2a = 2 (curve parameter)
  • p=11p = 11

Compute Slope λ\lambda: λ=3x12+a2y1modp=3×22+22×2mod11=3×4+24mod11=144mod11\lambda = \frac{3x_1^2 + a}{2y_1} \bmod p = \frac{3 \times 2^2 + 2}{2 \times 2} \bmod 11 = \frac{3 \times 4 + 2}{4} \bmod 11 = \frac{14}{4} \bmod 11

Compute 41mod114^{-1} \bmod 11:

  • Need 4d1(mod11)4d \equiv 1 \pmod{11}
  • 4×3=121(mod11)4 \times 3 = 12 \equiv 1 \pmod{11}, so 41=34^{-1} = 3

Therefore λ=14×3mod11=42mod11=423×11=4233=9\lambda = 14 \times 3 \bmod 11 = 42 \bmod 11 = 42 - 3 \times 11 = 42 - 33 = 9

Compute x3x_3: x3=λ22x1modp=922×2mod11=814mod11=77mod11=0x_3 = \lambda^2 - 2x_1 \bmod p = 9^2 - 2 \times 2 \bmod 11 = 81 - 4 \bmod 11 = 77 \bmod 11 = 0

Compute y3y_3: y3=λ(x1x3)y1modp=9(20)2mod11=182mod11=16mod11=5y_3 = \lambda(x_1 - x_3) - y_1 \bmod p = 9(2 - 0) - 2 \bmod 11 = 18 - 2 \bmod 11 = 16 \bmod 11 = 5

Therefore 2P=(0,5)2P = (0, 5)

Verification: Check if (0,5)(0, 5) is on the curve

  • Left side: y2=52=25mod11=3y^2 = 5^2 = 25 \bmod 11 = 3
  • Right side: x3+2x+3=0+0+3=3mod11=3x^3 + 2x + 3 = 0 + 0 + 3 = 3 \bmod 11 = 3
  • 3=33 = 3

(3) Compute P+QP + Q (Point Addition)

First Verify Q=(3,6)Q = (3, 6) is on the Curve:

  • Left side: y2=62=36mod11=3y^2 = 6^2 = 36 \bmod 11 = 3
  • Right side: x3+2x+3=33+2×3+3=27+6+3=36mod11=3x^3 + 2x + 3 = 3^3 + 2 \times 3 + 3 = 27 + 6 + 3 = 36 \bmod 11 = 3
  • 3=33 = 3 ✓, QQ is on the curve

Point Addition Formula (PQP \neq Q):

  • Slope: λ=y2y1x2x1modp\lambda = \frac{y_2 - y_1}{x_2 - x_1} \bmod p
  • x3=λ2x1x2modpx_3 = \lambda^2 - x_1 - x_2 \bmod p
  • y3=λ(x1x3)y1modpy_3 = \lambda(x_1 - x_3) - y_1 \bmod p

Given Parameters:

  • P=(x1,y1)=(2,2)P = (x_1, y_1) = (2, 2)
  • Q=(x2,y2)=(3,6)Q = (x_2, y_2) = (3, 6)
  • p=11p = 11

Compute Slope λ\lambda: λ=y2y1x2x1modp=6232mod11=41mod11=4\lambda = \frac{y_2 - y_1}{x_2 - x_1} \bmod p = \frac{6 - 2}{3 - 2} \bmod 11 = \frac{4}{1} \bmod 11 = 4

Compute x3x_3: x3=λ2x1x2modp=4223mod11=165mod11=11mod11=0x_3 = \lambda^2 - x_1 - x_2 \bmod p = 4^2 - 2 - 3 \bmod 11 = 16 - 5 \bmod 11 = 11 \bmod 11 = 0

Compute y3y_3: y3=λ(x1x3)y1modp=4(20)2mod11=82mod11=6y_3 = \lambda(x_1 - x_3) - y_1 \bmod p = 4(2 - 0) - 2 \bmod 11 = 8 - 2 \bmod 11 = 6

Therefore P+Q=(0,6)P + Q = (0, 6)

Verification: Check if (0,6)(0, 6) is on the curve

  • Left side: y2=62=36mod11=3y^2 = 6^2 = 36 \bmod 11 = 3
  • Right side: x3+2x+3=0+0+3=3mod11=3x^3 + 2x + 3 = 0 + 0 + 3 = 3 \bmod 11 = 3
  • 3=33 = 3

All Calculations Complete!


Part 3: Digital Signatures

Type 1: Concept Explanation

Problem 14: Explain EU-CMA Security Model of Digital Signatures

Problem: Please explain in detail the EU-CMA (Existential Unforgeability under Chosen Message Attack) security model of digital signatures, including: (1) Definition of EU-CMA game (2) Meaning of existential unforgeability (3) Meaning of adaptive chosen message attack (4) Why this security model is reasonable

Complete Solution:

(1) Definition of EU-CMA Game

EU-CMA Security Game is an interactive game used to define security of digital signatures:

Game Participants:

  • Challenger: Runs signature scheme, generates key pair
  • Attacker: Attempts to forge signatures

Game Steps:

  1. Initialization Phase:

    • Challenger generates key pair: (pk,sk)Gen(1n)(pk, sk) \leftarrow Gen(1^n)
    • Challenger sends public key pkpk to attacker
    • Private key sksk is kept secret
  2. Learning Phase:

    • Attacker can query signature oracle Signsk()Sign_{sk}(\cdot) arbitrarily many polynomial times
    • For each query message mim_i, attacker obtains signature σi=Signsk(mi)\sigma_i = Sign_{sk}(m_i)
    • Attacker obtains signature pairs: (m1,σ1),(m2,σ2),,(mq,σq)(m_1, \sigma_1), (m_2, \sigma_2), \ldots, (m_q, \sigma_q)
    • Where qq is polynomially bounded number of queries
  3. Forgery Phase:

    • Attacker outputs forgery: (m,σ)(m^*, \sigma^*)
    • Requirement: m{m1,m2,,mq}m^* \notin \{m_1, m_2, \ldots, m_q\} (mm^* is not a queried message)
  4. Decision Phase:

    • Challenger verifies: Verifypk(m,σ)Verify_{pk}(m^*, \sigma^*)
    • If verification passes (outputs 1), attacker wins, game outputs 1
    • Otherwise attacker fails, game outputs 0

Attacker's Advantage: AdvEUCMA(A)=Pr[EU-CMA-Game(A)=1]\text{Adv}_{EU-CMA}(A) = \Pr[\text{EU-CMA-Game}(A) = 1]

(2) Meaning of Existential Unforgeability

Existential Unforgeability:

  • Attacker cannot generate valid signatures for any message
  • Even if the message may be meaningless, random, or constructed by attacker
  • As long as attacker has not queried signature for that message, cannot forge

Difference from Strong Unforgeability:

  • Existential Unforgeability: Attacker cannot forge signatures for new messages
  • Strong Unforgeability: Even if attacker sees signature σ\sigma for message mm, cannot generate another valid signature σσ\sigma' \neq \sigma for that message

Practical Significance:

  • Existential unforgeability is already strong enough, because attacker cannot forge signatures for any new message
  • This guarantees the basic security goal of digital signatures

(3) Meaning of Adaptive Chosen Message Attack

Adaptive Chosen Message Attack (CMA):

  • Attacker can adaptively choose messages to query signatures
  • Attacker can choose next message to query based on previous query results
  • This models real scenarios where attacker can observe signatures and choose attack strategy accordingly

Why "Adaptive":

  • Attacker does not need to submit all messages to query at once
  • Can dynamically choose next message based on previous query results
  • This makes attack more powerful, security model more strict

Comparison with Other Attack Models:

  • Known Message Attack: Attacker can only see random message-signature pairs, cannot choose messages
  • Chosen Message Attack: Attacker can choose messages, but must submit all messages at once (non-adaptive)
  • Adaptive Chosen Message Attack: Attacker can adaptively choose messages (strongest)

(4) Why This Security Model is Reasonable

Reasonableness Analysis:

  1. Models Real Attack Scenarios:

    • In reality, attacker may be able to obtain signatures for some messages
    • Attacker can choose attack strategy based on observed signatures
    • EU-CMA model accurately models this scenario
  2. Provides Strong Enough Security Guarantee:

    • Even if attacker obtains many message signatures, still cannot forge signatures for new messages
    • This guarantees core security goal of digital signatures: unforgeability
  3. Security in Practical Applications:

    • If digital signature scheme is EU-CMA secure, then in practical applications, even if attacker observes many signatures, cannot forge
    • This applies to most practical application scenarios
  4. Relationship with Other Security Goals:

    • EU-CMA security is the basic security requirement for digital signatures
    • Stronger security models (such as strong unforgeability) are needed in some special scenarios, but EU-CMA is sufficient

Summary:

  • EU-CMA security model is the standard security definition for digital signature schemes
  • It accurately models real attack scenarios
  • Provides strong enough security guarantee
  • Is a reasonable standard for evaluating security of digital signature schemes

Type 2: Scheme Design

Problem 15: Design a Secure File Sharing Scheme

Problem: Design a secure file sharing scheme that satisfies the following requirements:

  1. File size is 10GB (very large)
  2. Payment information is confidential (Payment - No one knows)
  3. File integrity (Integrity)
  4. Only Bob can check the file content

Please: (1) Choose appropriate cryptographic tools (2) Explain the scheme's working process in detail (3) Explain how the scheme satisfies each requirement

Complete Solution:

(1) Choose Appropriate Cryptographic Tools

Based on requirement analysis:

  • Large File (10GB): Need to use efficient symmetric encryption
  • Payment Information Confidential: Need to use public key encryption to protect key
  • Integrity: Need to use hash function or MAC
  • Only Bob Can Access: Need to use Bob's public key encryption

Chosen Tools:

  • Symmetric Encryption: AES-256-CTR mode (suitable for large files, supports parallelization)
  • Public Key Encryption: RSA-OAEP or Elgamal (for encrypting symmetric key)
  • Hash Function: SHA-256 (for integrity verification)
  • Digital Signature (optional): For authenticating sender

(2) Detailed Scheme Design

Scheme: Hybrid Encryption + Hash Verification

Step 1: Sender (Alice) Prepares File

  1. Generate Symmetric Key:

    • Randomly generate symmetric key: k{0,1}256k \leftarrow \{0,1\}^{256} (AES-256 key)
    • Choose random IV: IV{0,1}128IV \leftarrow \{0,1\}^{128}
  2. Encrypt File:

    • Split 10GB file FF into blocks: F1,F2,,FnF_1, F_2, \ldots, F_n (each block 128 bits)
    • Use AES-CTR mode encryption:
      • For each block: Ci=FiAESk(IV+i)C_i = F_i \oplus AES_k(IV + i)
      • Ciphertext file: C=C1C2CnC = C_1 || C_2 || \ldots || C_n
  3. Compute File Hash:

    • Compute hash of original file: h=SHA256(F)h = SHA256(F)
    • This is used for integrity verification
  4. Encrypt Symmetric Key:

    • Use Bob's public key encryption: Kenc=RSA-OAEPpkB(kIV)K_{enc} = RSA\text{-}OAEP_{pk_B}(k || IV)
    • Only Bob can decrypt to obtain kk and IVIV
  5. (Optional) Sign Hash Value:

    • Use Alice's private key to sign: σ=SignskA(h)\sigma = Sign_{sk_A}(h)
    • Used to authenticate file source

Step 2: Send Alice sends to Bob:

  • Encrypted file: CC (10GB)
  • Encrypted key: KencK_{enc}
  • File hash value: hh
  • (Optional) Signature: σ\sigma

Step 3: Receiver (Bob) Verifies and Decrypts

  1. Decrypt Key:

    • Use Bob's private key to decrypt: (kIV)=RSA-OAEPskB1(Kenc)(k || IV) = RSA\text{-}OAEP_{sk_B}^{-1}(K_{enc})
    • Only Bob has skBsk_B, only Bob can decrypt
  2. Decrypt File:

    • Use AES-CTR decryption:
      • For each block: Fi=CiAESk(IV+i)F_i = C_i \oplus AES_k(IV + i)
      • Recover file: F=F1F2FnF = F_1 || F_2 || \ldots || F_n
  3. Verify Integrity:

    • Compute hash of received file: h=SHA256(F)h' = SHA256(F)
    • Check if h=hh' = h
    • If equal, file is intact; otherwise file has been tampered with
  4. (Optional) Verify Signature:

    • Verify VerifypkA(h,σ)Verify_{pk_A}(h, \sigma)
    • Confirm file is from Alice

(3) Explain How Each Requirement is Satisfied

Requirement 1: File Size is 10GB (Very Large)

  • Solution: Use symmetric encryption (AES-CTR)
    • Symmetric encryption is fast, suitable for large files
    • CTR mode supports parallel encryption/decryption
    • 10GB file can be processed efficiently
  • Why Not Use Public Key Encryption Directly for File:
    • Public key encryption is slow (100-1000 times slower than symmetric encryption)
    • RSA can only encrypt data smaller than modulus (typically 2048 bits)
    • Therefore use hybrid encryption: public key encrypts small key (256 bits), symmetric encrypts large file (10GB)

Requirement 2: Payment Information Confidential (Payment - No one knows)

  • Solution: Use Bob's public key encryption for symmetric key
    • Symmetric key kk is encrypted using Bob's public key pkBpk_B
    • Only Bob has private key skBsk_B, only Bob can decrypt KencK_{enc} to obtain kk
    • Without kk, cannot decrypt file CC
    • Therefore, except Bob, no one can know file content (including payment information)
  • Security Guarantee:
    • RSA-OAEP is CPA secure
    • Even if attacker intercepts KencK_{enc}, cannot decrypt (unless can break RSA)
    • Even if attacker intercepts encrypted file CC, without kk cannot decrypt

Requirement 3: File Integrity (Integrity)

  • Solution: Use hash function to verify integrity
    • Alice computes hash of original file h=SHA256(F)h = SHA256(F)
    • Bob computes hash of received file h=SHA256(F)h' = SHA256(F') after decryption
    • If h=hh' = h, file is intact; otherwise file has been tampered with
  • Security Guarantee:
    • SHA-256 has collision resistance
    • Attacker cannot find different files producing the same hash value
    • Therefore can detect any tampering
  • If File is Tampered:
    • Attacker modifies CC to get CC'
    • Bob decrypts to get FFF' \neq F
    • Computes h=SHA256(F)hh' = SHA256(F') \neq h
    • Verification fails, Bob knows file has been tampered with

Requirement 4: Only Bob Can Check File Content

  • Solution: Use Bob's public key encryption
    • Symmetric key kk is encrypted using Bob's public key pkBpk_B
    • Only Bob has private key skBsk_B, only Bob can decrypt to obtain kk
    • Without kk, cannot decrypt file
  • Security Guarantee:
    • Public key encryption ensures only private key holder (Bob) can decrypt
    • Even if attacker intercepts all transmitted data (CC, KencK_{enc}, hh), cannot obtain file content
    • This provides access control

Scheme Summary:

  • ✅ Satisfies large file requirement: Uses efficient symmetric encryption (AES-CTR)
  • ✅ Satisfies confidentiality requirement: Uses public key encryption to protect key (RSA-OAEP)
  • ✅ Satisfies integrity requirement: Uses hash function for verification (SHA-256)
  • ✅ Satisfies access control requirement: Only Bob can decrypt (using Bob's public key)

Security Analysis:

  • Confidentiality: Guaranteed by RSA-OAEP and AES-CTR
  • Integrity: Guaranteed by SHA-256 hash verification
  • Authentication (optional): Guaranteed by digital signature
  • Access Control: Guaranteed by public key encryption, only Bob can access

Type 3: Proof Problems

Problem 16: Prove CBC Mode Security under CPA (Simplified Proof)

Problem: Please prove that CBC (Cipher Block Chaining) mode is semantically secure under CPA (Chosen Plaintext Attack).

Requirements: (1) Give proof assumptions (2) Use game hopping technique (3) Analyze differences between each game (4) Draw conclusion

Complete Solution:

(1) Proof Assumptions

Assumptions:

  1. Underlying block cipher EkE_k is a pseudo-random permutation (PRP)
  2. Initialization vector IVIV is randomly chosen (different for each encryption)

CBC Mode Review:

  • Encryption: C0=IVC_0 = IV, Ci=Ek(PiCi1)C_i = E_k(P_i \oplus C_{i-1}) for i1i \geq 1
  • Decryption: Pi=Dk(Ci)Ci1P_i = D_k(C_i) \oplus C_{i-1}

(2) Proof Using Game Hopping Technique

Game Hopping is a proof technique that proves security through a series of games, where each game differs only slightly from the previous one.

Game 0 (Real CBC Mode):

  1. Challenger generates key kGen(1n)k \leftarrow Gen(1^n)
  2. Attacker queries encryption oracle, obtains (mi,EncCBC(mi))(m_i, Enc_{CBC}(m_i))
  3. Attacker chooses (m0,m1)(m_0, m_1), obtains challenge ciphertext c=EncCBC(mb)c^* = Enc_{CBC}(m_b)
  4. Attacker outputs bb'

Game 1 (Use Random Permutation Instead of Block Cipher):

  1. Challenger chooses random permutation π\pi (instead of using EkE_k)
  2. Encryption uses: Ci=π(PiCi1)C_i = \pi(P_i \oplus C_{i-1})
  3. Other steps same as Game 0

Game 2 (Use True Random Function):

  1. Challenger chooses true random function ff (instead of permutation)
  2. Encryption uses: Ci=f(PiCi1)C_i = f(P_i \oplus C_{i-1})
  3. Other steps same as Game 1

Game 3 (Ideal Case):

  1. Challenger directly outputs random ciphertext (independent of plaintext)
  2. Attacker cannot obtain any information about mbm_b

(3) Analyze Differences Between Each Game

Difference from Game 0 to Game 1:

  • Use random permutation π\pi instead of EkE_k
  • If EkE_k is PRP, then Game 0 and Game 1 are computationally indistinguishable
  • Difference: Pr[Game0]Pr[Game1]ϵPRP(n)|\Pr[Game_0] - \Pr[Game_1]| \leq \epsilon_{PRP}(n) (negligible)

Difference from Game 1 to Game 2:

  • Use random function ff instead of random permutation π\pi
  • Since difference between permutation and function is small (birthday paradox), difference is negligible
  • Difference: Pr[Game1]Pr[Game2]ϵbirthday(n)|\Pr[Game_1] - \Pr[Game_2]| \leq \epsilon_{birthday}(n) (negligible)

Difference from Game 2 to Game 3:

  • In Game 2, if IVIV is random, then each block's input PiCi1P_i \oplus C_{i-1} looks random
  • Random function ff's output also looks random
  • Therefore, entire ciphertext looks random, independent of plaintext
  • Difference: Pr[Game2]Pr[Game3]ϵrandom(n)|\Pr[Game_2] - \Pr[Game_3]| \leq \epsilon_{random}(n) (negligible)

(4) Draw Conclusion

Attacker's Advantage in Game 3:

  • In Game 3, ciphertext is completely random, contains no information about mbm_b
  • Attacker's advantage: AdvGame3(A)=0\text{Adv}_{Game_3}(A) = 0 (cannot distinguish)

Attacker's Advantage in Game 0: AdvGame0(A)AdvGame3(A)+ϵPRP+ϵbirthday+ϵrandom\text{Adv}_{Game_0}(A) \leq \text{Adv}_{Game_3}(A) + \epsilon_{PRP} + \epsilon_{birthday} + \epsilon_{random} =0+ϵPRP+ϵbirthday+ϵrandom= 0 + \epsilon_{PRP} + \epsilon_{birthday} + \epsilon_{random} =ϵ(n)= \epsilon(n) (negligible function)

Conclusion:

  • If underlying block cipher EkE_k is PRP, and IVIV is random
  • Then CBC mode is semantically secure under CPA
  • Attacker's advantage is negligible

Important Condition:

  • IVIV must be random (different for each encryption)
  • If IVIV is fixed or predictable, CBC mode is insecure

Type 4: Calculation Problems

Problem 17: Complete RSA-FDH Signature Calculation

Problem: Given RSA-FDH parameters:

  • p=17p = 17, q=19q = 19
  • Public exponent e=5e = 5
  • Message m="Hello"m = "Hello", assume H("Hello")=100H("Hello") = 100

Please complete: (1) Compute key pair (2) Generate signature σ\sigma (3) Verify signature

Complete Solution:

(1) Compute Key Pair

Modulus: n=p×q=17×19=323n = p \times q = 17 \times 19 = 323

Euler's Totient Function: ϕ(n)=(p1)(q1)=16×18=288\phi(n) = (p-1)(q-1) = 16 \times 18 = 288

Verify ee is Coprime with ϕ(n)\phi(n):

  • gcd(5,288)=1\gcd(5, 288) = 1 ✓ (because 5 is prime, and 5 does not divide 288)

Compute Private Exponent dd: Need 5d1(mod288)5d \equiv 1 \pmod{288}

Using extended Euclidean algorithm:

  • 288=5×57+3288 = 5 \times 57 + 3
  • 5=3×1+25 = 3 \times 1 + 2
  • 3=2×1+13 = 2 \times 1 + 1
  • 2=1×2+02 = 1 \times 2 + 0

Back substitution:

  • 1=32×11 = 3 - 2 \times 1
  • 2=53×12 = 5 - 3 \times 1
  • 1=3(53)=2×351 = 3 - (5 - 3) = 2 \times 3 - 5
  • 3=2885×573 = 288 - 5 \times 57
  • 1=2×(2885×57)5=2×288115×51 = 2 \times (288 - 5 \times 57) - 5 = 2 \times 288 - 115 \times 5

Therefore d=115mod288=288115=173d = -115 \bmod 288 = 288 - 115 = 173

Verification: 5×173=8651(mod288)5 \times 173 = 865 \equiv 1 \pmod{288}

Key Pair:

  • Public key: pk=(n,e)=(323,5)pk = (n, e) = (323, 5)
  • Private key: sk=(n,d)=(323,173)sk = (n, d) = (323, 173)

(2) Generate Signature σ\sigma

Message Hash: h=H("Hello")=100h = H("Hello") = 100

Check Range: 100<323100 < 323 ✓ (in valid range)

Compute Signature: σ=hdmodn=100173mod323\sigma = h^d \bmod n = 100^{173} \bmod 323

Using Modular Exponentiation:

Express exponent 173 in binary: 173=101011012=128+32+8+4+1173 = 10101101_2 = 128 + 32 + 8 + 4 + 1

Compute 1002imod323100^{2^i} \bmod 323:

  • 1001=100mod323=100100^1 = 100 \bmod 323 = 100
  • 1002=10000mod323=1000030×323=100009690=310100^2 = 10000 \bmod 323 = 10000 - 30 \times 323 = 10000 - 9690 = 310
  • 1004=(1002)2=3102=96100mod323=96100297×323=9610095931=169100^4 = (100^2)^2 = 310^2 = 96100 \bmod 323 = 96100 - 297 \times 323 = 96100 - 95931 = 169
  • 1008=(1004)2=1692=28561mod323=2856188×323=2856128424=137100^8 = (100^4)^2 = 169^2 = 28561 \bmod 323 = 28561 - 88 \times 323 = 28561 - 28424 = 137
  • 10016=(1008)2=1372=18769mod323=1876958×323=1876918734=35100^{16} = (100^8)^2 = 137^2 = 18769 \bmod 323 = 18769 - 58 \times 323 = 18769 - 18734 = 35
  • 10032=(10016)2=352=1225mod323=12253×323=1225969=256100^{32} = (100^{16})^2 = 35^2 = 1225 \bmod 323 = 1225 - 3 \times 323 = 1225 - 969 = 256
  • 10064=(10032)2=2562=65536mod323=65536202×323=6553665246=290100^{64} = (100^{32})^2 = 256^2 = 65536 \bmod 323 = 65536 - 202 \times 323 = 65536 - 65246 = 290
  • 100128=(10064)2=2902=84100mod323=84100260×323=8410083980=120100^{128} = (100^{64})^2 = 290^2 = 84100 \bmod 323 = 84100 - 260 \times 323 = 84100 - 83980 = 120

Compute 100173100^{173}: 100173=100128×10032×1008×1004×1001100^{173} = 100^{128} \times 100^{32} \times 100^8 \times 100^4 \times 100^1 =120×256×137×169×100mod323= 120 \times 256 \times 137 \times 169 \times 100 \bmod 323

Compute step by step:

  • 120×256=30720mod323=3072095×323=3072030685=35120 \times 256 = 30720 \bmod 323 = 30720 - 95 \times 323 = 30720 - 30685 = 35
  • 35×137=4795mod323=479514×323=47954522=27335 \times 137 = 4795 \bmod 323 = 4795 - 14 \times 323 = 4795 - 4522 = 273
  • 273×169=46137mod323=46137142×323=4613745866=271273 \times 169 = 46137 \bmod 323 = 46137 - 142 \times 323 = 46137 - 45866 = 271
  • 271×100=27100mod323=2710083×323=2710026809=291271 \times 100 = 27100 \bmod 323 = 27100 - 83 \times 323 = 27100 - 26809 = 291

Therefore σ=291\sigma = 291

(3) Verify Signature

Public Key: (n,e)=(323,5)(n, e) = (323, 5) Message Hash: h=100h = 100 Signature: σ=291\sigma = 291

Verification: Check if hσe(modn)h \equiv \sigma^e \pmod{n}, i.e., 1002915(mod323)100 \equiv 291^5 \pmod{323}

Compute 2915mod323291^5 \bmod 323:

  • 2912=84681mod323=84681262×323=8468184626=55291^2 = 84681 \bmod 323 = 84681 - 262 \times 323 = 84681 - 84626 = 55
  • 2914=(2912)2=552=3025mod323=30259×323=30252907=118291^4 = (291^2)^2 = 55^2 = 3025 \bmod 323 = 3025 - 9 \times 323 = 3025 - 2907 = 118
  • 2915=2914×2911=118×291=34338mod323291^5 = 291^4 \times 291^1 = 118 \times 291 = 34338 \bmod 323

Compute 34338mod32334338 \bmod 323:

  • 323×106=34238323 \times 106 = 34238
  • 3433834238=10034338 - 34238 = 100

Therefore 2915100(mod323)291^5 \equiv 100 \pmod{323}

Verification Passed! Signature is Valid!


Part 4: Advanced Topics

Type 1: Concept Explanation

Problem 18: Explain Three Properties of Zero Knowledge Proof

Problem: Please explain in detail the three properties of Zero Knowledge Proof: (1) Completeness (2) Soundness (3) Zero-Knowledge

And explain the practical significance of each property.

Complete Solution:

(1) Completeness

Definition: If the prover indeed knows the secret (or the statement is true), then an honest verifier always accepts the proof.

Formal Definition: Pr[Verifier acceptsProver knows secret]=1\Pr[\text{Verifier accepts} | \text{Prover knows secret}] = 1

Intuitive Understanding:

  • If the prover really knows the secret and honestly executes the protocol
  • The verifier should always accept the proof (will not incorrectly reject)
  • This guarantees the "usability" of the protocol: honest prover can successfully prove

Practical Significance:

  • If completeness is not satisfied, even if prover knows the secret, may be rejected
  • This would make the protocol unusable
  • Completeness guarantees "true statements can always be proven"

Example: In zero knowledge proof of discrete logarithm:

  • If prover knows xx such that y=gxy = g^x
  • And honestly executes the protocol (computes correct response z=r+cxz = r + cx)
  • Then verifier always accepts (because gz=grycg^z = g^r \cdot y^c)

(2) Soundness

Definition: If the prover does not know the secret (or the statement is false), then the verifier rejects the proof with high probability.

Formal Definition: Pr[Verifier acceptsProver doesn’t know secret]ϵ\Pr[\text{Verifier accepts} | \text{Prover doesn't know secret}] \leq \epsilon where ϵ\epsilon is a negligible function.

Intuitive Understanding:

  • If the prover does not know the secret but tries to deceive the verifier
  • The verifier should reject with high probability (will not incorrectly accept)
  • This guarantees the "security" of the protocol: prover without secret cannot pass verification

Practical Significance:

  • If soundness is not satisfied, prover without secret may pass verification
  • This would make the protocol insecure
  • Soundness guarantees "false statements are almost always rejected"

Example: In zero knowledge proof of discrete logarithm:

  • If prover does not know xx, cannot compute correct response zz
  • Verifier's check gz=Rycg^z = R \cdot y^c will fail
  • Verifier rejects with high probability

(3) Zero-Knowledge

Definition: The verifier cannot obtain any information about the secret from the proof process (except the fact that the prover knows the secret).

Formal Definition (Simulator Definition): There exists a simulator SS that can generate proof records indistinguishable from real proofs without knowing the secret.

Intuitive Understanding:

  • The verifier can only know the fact that "the prover knows the secret"
  • Cannot obtain the secret itself or any other information about the secret
  • This guarantees the "privacy" of the protocol

Practical Significance:

  • If zero-knowledge is not satisfied, verifier may extract secret information from the proof process
  • This would cause privacy leakage
  • Zero-knowledge guarantees "except that the statement is true, no other information is leaked"

Example: In zero knowledge proof of discrete logarithm:

  • Verifier sees (R,c,z)(R, c, z)
  • But cannot extract information about xx from these values
  • Because RR is random, cc is chosen by verifier itself, zz depends on random number rr

Relationship Between Three Properties:

  • Completeness: Guarantees protocol usability (true statements can be proven)
  • Soundness: Guarantees protocol security (false statements are rejected)
  • Zero-Knowledge: Guarantees protocol privacy (does not leak secret information)

All Three Are Indispensable:

  • Only completeness: Protocol usable but insecure
  • Only soundness: Protocol secure but may be unusable
  • Only zero-knowledge: Protocol private but may be insecure
  • All three satisfied: Protocol is usable, secure, and privacy-preserving

Type 2: Scheme Design

Problem 19: Design Voting Scheme Based on Homomorphic Encryption

Problem: Design an electronic voting scheme using homomorphic encryption that satisfies the following requirements:

  1. Each voter can only vote once
  2. Votes are confidential (No one knows specific voting content)
  3. Can correctly count voting results
  4. If someone lies (vote value not in allowed range), use zero knowledge proof to prove

Please: (1) Choose appropriate cryptographic tools (2) Describe voting process in detail (3) Explain how to detect and prove vote value is not in {0,1}\{0,1\} range

Complete Solution:

(1) Choose Appropriate Cryptographic Tools

Based on requirements, we need the following tools:

  • Homomorphic Encryption: Elgamal encryption (supports multiplicative homomorphism, can be used for counting)
  • Zero Knowledge Proof: Sigma protocol (for proving vote value is in allowed range)
  • Digital Signature: For authenticating voter identity
  • Hash Function: For computing challenge

Specific Choices:

  • Homomorphic Encryption: Elgamal encryption (Enc(b)=(gr,gbyr)Enc(b) = (g^r, g^b \cdot y^r), where b{0,1}b \in \{0,1\})
  • Zero Knowledge Proof: OR proof (prove b{0,1}b \in \{0,1\})
  • Digital Signature: Schnorr signature or RSA-FDH
  • Hash Function: SHA-256

(2) Detailed Scheme Design

Scheme: Voting Scheme Based on Elgamal Homomorphic Encryption

Setup Phase:

  1. Choose Elgamal parameters: large prime pp, generator gZpg \in \mathbb{Z}_p^*
  2. Voting authority generates key pair: private key xx, public key y=gxmodpy = g^x \bmod p
  3. Public parameters: (p,g,y)(p, g, y)

Voting Phase (Voter ViV_i):

  1. Identity Authentication:

    • Voter uses digital signature to prove identity
    • Voting authority verifies signature and checks if already voted
  2. Choose Vote:

    • Voter chooses b{0,1}b \in \{0, 1\} (0 = oppose, 1 = support)
  3. Encrypt Vote:

    • Randomly choose rZp1r \leftarrow \mathbb{Z}_{p-1}
    • Compute: c1=grmodpc_1 = g^r \bmod p
    • Compute: c2=gbyrmodpc_2 = g^b \cdot y^r \bmod p
    • Ciphertext: C=(c1,c2)C = (c_1, c_2)
  4. Zero Knowledge Proof:

    • Generate ZK proof proving b{0,1}b \in \{0, 1\}
    • Use OR proof: prove knowledge of logg(c2/yr0)\log_g (c_2 / y^{r_0}) or logg(c2/yr1)\log_g (c_2 / y^{r_1}), where r0,r1r_0, r_1 are random numbers for b=0b=0 and b=1b=1
  5. Submit:

    • Voter submits (C,ZK proof,signature)(C, \text{ZK proof}, \text{signature})

Counting Phase:

  1. Verify All Votes:

    • Verify each voter's identity (digital signature)
    • Verify each vote's ZK proof (ensure b{0,1}b \in \{0,1\})
  2. Homomorphic Computation:

    • For all valid vote ciphertexts Ci=(c1,i,c2,i)C_i = (c_{1,i}, c_{2,i}), compute:
    • Ctotal=i=1nCi=(i=1nc1,i,i=1nc2,i)C_{total} = \prod_{i=1}^n C_i = (\prod_{i=1}^n c_{1,i}, \prod_{i=1}^n c_{2,i})
    • Due to Elgamal's multiplicative homomorphism: Ctotal=(gri,gbiyri)C_{total} = (g^{\sum r_i}, g^{\sum b_i} \cdot y^{\sum r_i})
  3. Decrypt Counting Result:

    • Use private key xx to decrypt CtotalC_{total}
    • Compute: gbi=c2,total(c1,total)xmodpg^{\sum b_i} = c_{2,total} \cdot (c_{1,total})^{-x} \bmod p
    • Compute discrete logarithm: bi=logg(gbi)\sum b_i = \log_g (g^{\sum b_i}) (since bin\sum b_i \leq n, can exhaustively search)
    • Counting result: Support votes = bi\sum b_i, Oppose votes = nbin - \sum b_i

(3) Explain How to Detect and Prove Vote Value is Not in {0,1}\{0,1\} Range

Problem: If someone lies, vote value b{0,1}b \notin \{0,1\}, how to detect?

Solution: Use Zero Knowledge Proof

OR Proof Construction:

Voter needs to prove: b{0,1}b \in \{0, 1\}, i.e., prove one of the following two statements is true:

  • Statement 1: b=0b = 0, i.e., c2/yr=g0=1c_2 / y^r = g^0 = 1
  • Statement 2: b=1b = 1, i.e., c2/yr=g1=gc_2 / y^r = g^1 = g

OR Proof Steps:

  1. For b=0b = 0 case (if voter really chooses b=0b = 0):

    • True relation: c2=yrc_2 = y^r (because g0=1g^0 = 1)
    • Prover knows rr, can generate true proof
    • For b=1b = 1 relation, generate simulated proof
  2. For b=1b = 1 case (if voter really chooses b=1b = 1):

    • True relation: c2=gyrc_2 = g \cdot y^r, i.e., c2/yr=gc_2 / y^r = g
    • Prover knows rr, can generate true proof
    • For b=0b = 0 relation, generate simulated proof
  3. Verification:

    • Verifier checks if OR proof is valid
    • If b{0,1}b \notin \{0,1\}, voter cannot generate valid OR proof
    • Verifier rejects the vote

Specific Implementation (simplified):

Voter Generates Proof:

  • If b=0b = 0:
    • True proof: Prove knowledge of rr such that c2=yrc_2 = y^r (i.e., c2/yr=1c_2 / y^r = 1)
    • Simulated proof: Generate simulated proof for b=1b = 1 case
  • If b=1b = 1:
    • True proof: Prove knowledge of rr such that c2=gyrc_2 = g \cdot y^r (i.e., c2/yr=gc_2 / y^r = g)
    • Simulated proof: Generate simulated proof for b=0b = 0 case

Verifier Verifies:

  • Verify validity of OR proof
  • If proof is invalid, reject vote

If Someone Lies (b{0,1}b \notin \{0,1\}):

  • Voter cannot generate true proof for b=0b = 0 or b=1b = 1
  • Can only generate two simulated proofs
  • But simulated proofs cannot pass verification (because challenge distribution is incorrect)
  • Verifier detects proof is invalid, rejects vote

Scheme Summary:

  • ✅ Satisfies uniqueness: Digital signature prevents duplicate voting
  • ✅ Satisfies confidentiality: Elgamal encryption protects vote content
  • ✅ Satisfies correctness: Homomorphic encryption supports correct counting
  • ✅ Satisfies verifiability: Zero knowledge proof ensures vote value is in allowed range

Type 3: Proof Problems

Problem 20: Prove AND Proof Satisfies Soundness Property

Problem: Prove that AND proof in zero knowledge proof satisfies Soundness property.

Given: Prover wants to prove knowledge of x1x_1 and x2x_2 such that y1=g1x1y_1 = g_1^{x_1} and y2=g2x2y_2 = g_2^{x_2}.

Please prove: If prover does not know x1x_1 or x2x_2, then verifier rejects proof with high probability.

Complete Solution:

AND Proof Protocol Review:

Protocol Steps:

  1. Commitment: Prover sends (a1,a2)(a_1, a_2), where a1=g1r1a_1 = g_1^{r_1}, a2=g2r2a_2 = g_2^{r_2}, r1,r2Zqr_1, r_2 \leftarrow \mathbb{Z}_q
  2. Challenge: Verifier sends cZqc \leftarrow \mathbb{Z}_q
  3. Response: Prover sends (z1,z2)(z_1, z_2), where z1=r1+cx1modqz_1 = r_1 + cx_1 \bmod q, z2=r2+cx2modqz_2 = r_2 + cx_2 \bmod q
  4. Verification: Verifier checks g1z1=a1y1cg_1^{z_1} = a_1 \cdot y_1^c and g2z2=a2y2cg_2^{z_2} = a_2 \cdot y_2^c

(1) Proof Idea

Use proof by contradiction: Assume there exists attacker that can pass verification with non-negligible probability even without knowing x1x_1 or x2x_2. We will prove this contradicts hardness of discrete logarithm problem.

(2) Case Analysis

Case 1: Prover Does Not Know x1x_1

Assume prover does not know x1x_1 but knows x2x_2.

Attacker Strategy:

  • Attacker can correctly compute z2=r2+cx2z_2 = r_2 + cx_2 (because knows x2x_2)
  • But cannot correctly compute z1=r1+cx1z_1 = r_1 + cx_1 (because does not know x1x_1)

Verification Failure Analysis:

  • Verifier checks: g1z1=a1y1cg_1^{z_1} = a_1 \cdot y_1^c
  • If attacker does not know x1x_1, cannot compute correct z1z_1
  • Assume attacker guesses z1z_1', then: g1z1a1y1c=g1r1(g1x1)c=g1r1+cx1g_1^{z_1'} \neq a_1 \cdot y_1^c = g_1^{r_1} \cdot (g_1^{x_1})^c = g_1^{r_1 + cx_1}
  • Verification failure probability: Pr[verification fails]1ϵ\Pr[\text{verification fails}] \geq 1 - \epsilon, where ϵ\epsilon is negligible

Case 2: Prover Does Not Know x2x_2

Similarly, if prover does not know x2x_2, cannot correctly compute z2z_2, verification fails.

Case 3: Prover Does Not Know x1x_1 and x2x_2

If prover knows neither x1x_1 nor x2x_2, cannot correctly compute z1z_1 and z2z_2, verification must fail.

(3) Formal Proof

Assumption: There exists attacker AA that can pass verification with non-negligible probability δ\delta even without knowing x1x_1 or x2x_2.

Construct Algorithm BB to Solve Discrete Logarithm Problem:

Given discrete logarithm problem instance: (g1,y1)(g_1, y_1), want to compute x1=logg1y1x_1 = \log_{g_1} y_1.

Algorithm BB:

  1. Set g2g_2 and y2=g2x2y_2 = g_2^{x_2} (BB knows x2x_2)
  2. Run AND proof protocol as verifier
  3. If attacker AA passes verification, extract information from response

Key Observation:

  • If AA can pass verification, then g1z1=a1y1cg_1^{z_1} = a_1 \cdot y_1^c
  • I.e., g1z1=g1r1y1cg_1^{z_1} = g_1^{r_1} \cdot y_1^c
  • Therefore z1=r1+clogg1y1modqz_1 = r_1 + c \cdot \log_{g_1} y_1 \bmod q
  • If BB knows r1r_1 and cc, can compute: logg1y1=(z1r1)c1modq\log_{g_1} y_1 = (z_1 - r_1) \cdot c^{-1} \bmod q

Problem: BB does not know r1r_1 (because a1=g1r1a_1 = g_1^{r_1} is sent by attacker)

Use Replay Technique:

  1. BB runs protocol, obtains (a1,a2)(a_1, a_2), sends challenge cc, obtains (z1,z2)(z_1, z_2)
  2. BB replays protocol, uses same (a1,a2)(a_1, a_2), but sends different challenge cc'
  3. If AA passes verification again, obtains (z1,z2)(z_1', z_2')
  4. From two responses:
    • z1=r1+cx1modqz_1 = r_1 + cx_1 \bmod q
    • z1=r1+cx1modqz_1' = r_1 + c'x_1 \bmod q
    • Therefore: z1z1=(cc)x1modqz_1 - z_1' = (c - c')x_1 \bmod q
    • If ccc \neq c', then: x1=(z1z1)(cc)1modqx_1 = (z_1 - z_1') \cdot (c - c')^{-1} \bmod q

Success Probability:

  • If AA can pass verification with probability δ\delta
  • Then BB can solve discrete logarithm problem with probability approximately δ2\delta^2
  • If δ\delta is non-negligible, then δ2\delta^2 is also non-negligible
  • This contradicts hardness of discrete logarithm problem

(4) Conclusion

  • If prover does not know x1x_1 or x2x_2, cannot generate valid AND proof
  • Verifier rejects proof with high probability
  • Therefore, AND proof satisfies Soundness property

Soundness Error Probability:

  • If prover does not know secret, probability of passing verification ϵ\leq \epsilon (negligible function)
  • This guarantees security of protocol

Type 4: Calculation Problems

Problem 21: Elgamal Homomorphic Encryption Voting Calculation

Problem: In voting scheme based on Elgamal homomorphic encryption, given:

  • Parameters: p=23p = 23, g=5g = 5, public key y=8y = 8
  • Three voters' votes:
    • Voter 1: b1=1b_1 = 1 (support), random number r1=3r_1 = 3
    • Voter 2: b2=0b_2 = 0 (oppose), random number r2=4r_2 = 4
    • Voter 3: b3=1b_3 = 1 (support), random number r3=5r_3 = 5

Please complete: (1) Compute ciphertext for each vote (2) Use homomorphic property to compute total vote ciphertext (3) If private key x=6x = 6, decrypt to get total vote count

Complete Solution:

(1) Compute Ciphertext for Each Vote

Elgamal Encryption Formula:

  • c1=grmodpc_1 = g^r \bmod p
  • c2=gbyrmodpc_2 = g^b \cdot y^r \bmod p
  • Ciphertext: C=(c1,c2)C = (c_1, c_2)

Voter 1: b1=1b_1 = 1, r1=3r_1 = 3

  • c1,1=gr1=53mod23=125mod23=1255×23=125115=10c_{1,1} = g^{r_1} = 5^3 \bmod 23 = 125 \bmod 23 = 125 - 5 \times 23 = 125 - 115 = 10
  • c2,1=gb1yr1=5183mod23c_{2,1} = g^{b_1} \cdot y^{r_1} = 5^1 \cdot 8^3 \bmod 23

Compute 83mod238^3 \bmod 23:

  • 82=64mod23=188^2 = 64 \bmod 23 = 18
  • 83=18×8=144mod23=68^3 = 18 \times 8 = 144 \bmod 23 = 6

Therefore c2,1=5×6=30mod23=7c_{2,1} = 5 \times 6 = 30 \bmod 23 = 7

Vote 1 Ciphertext: C1=(10,7)C_1 = (10, 7)

Voter 2: b2=0b_2 = 0, r2=4r_2 = 4

  • c1,2=gr2=54mod23=625mod23=4c_{1,2} = g^{r_2} = 5^4 \bmod 23 = 625 \bmod 23 = 4 (from previous calculation)
  • c2,2=gb2yr2=5084mod23=184mod23c_{2,2} = g^{b_2} \cdot y^{r_2} = 5^0 \cdot 8^4 \bmod 23 = 1 \cdot 8^4 \bmod 23

Compute 84mod238^4 \bmod 23:

  • 84=(82)2=182=324mod23=28^4 = (8^2)^2 = 18^2 = 324 \bmod 23 = 2

Therefore c2,2=1×2=2mod23=2c_{2,2} = 1 \times 2 = 2 \bmod 23 = 2

Vote 2 Ciphertext: C2=(4,2)C_2 = (4, 2)

Voter 3: b3=1b_3 = 1, r3=5r_3 = 5

  • c1,3=gr3=55mod23c_{1,3} = g^{r_3} = 5^5 \bmod 23

Compute 55mod235^5 \bmod 23:

  • 54=45^4 = 4 (already computed)

  • 55=54×5=4×5=20mod23=205^5 = 5^4 \times 5 = 4 \times 5 = 20 \bmod 23 = 20

  • c2,3=gb3yr3=5185mod23c_{2,3} = g^{b_3} \cdot y^{r_3} = 5^1 \cdot 8^5 \bmod 23

Compute 85mod238^5 \bmod 23:

  • 84=28^4 = 2 (already computed)
  • 85=84×8=2×8=16mod23=168^5 = 8^4 \times 8 = 2 \times 8 = 16 \bmod 23 = 16

Therefore c2,3=5×16=80mod23=803×23=8069=11c_{2,3} = 5 \times 16 = 80 \bmod 23 = 80 - 3 \times 23 = 80 - 69 = 11

Vote 3 Ciphertext: C3=(20,11)C_3 = (20, 11)

(2) Use Homomorphic Property to Compute Total Vote Ciphertext

Elgamal Homomorphic Property: Enc(b1)Enc(b2)=(gr1,gb1yr1)(gr2,gb2yr2)=(gr1+r2,gb1+b2yr1+r2)Enc(b_1) \cdot Enc(b_2) = (g^{r_1}, g^{b_1} \cdot y^{r_1}) \cdot (g^{r_2}, g^{b_2} \cdot y^{r_2}) = (g^{r_1+r_2}, g^{b_1+b_2} \cdot y^{r_1+r_2})

Compute Total Ciphertext: Ctotal=C1C2C3=(i=13c1,i,i=13c2,i)C_{total} = C_1 \cdot C_2 \cdot C_3 = (\prod_{i=1}^3 c_{1,i}, \prod_{i=1}^3 c_{2,i})

Compute c1,totalc_{1,total}: c1,total=c1,1×c1,2×c1,3=10×4×20mod23=800mod23c_{1,total} = c_{1,1} \times c_{1,2} \times c_{1,3} = 10 \times 4 \times 20 \bmod 23 = 800 \bmod 23

Compute 800mod23800 \bmod 23:

  • 23×34=78223 \times 34 = 782
  • 800782=18800 - 782 = 18

Therefore c1,total=18c_{1,total} = 18

Compute c2,totalc_{2,total}: c2,total=c2,1×c2,2×c2,3=7×2×11mod23=154mod23c_{2,total} = c_{2,1} \times c_{2,2} \times c_{2,3} = 7 \times 2 \times 11 \bmod 23 = 154 \bmod 23

Compute 154mod23154 \bmod 23:

  • 23×6=13823 \times 6 = 138
  • 154138=16154 - 138 = 16

Therefore c2,total=16c_{2,total} = 16

Total Vote Ciphertext: Ctotal=(18,16)C_{total} = (18, 16)

(3) Decrypt to Get Total Vote Count

Private Key: x=6x = 6

Elgamal Decryption Formula: gbi=c2,total(c1,total)xmodpg^{\sum b_i} = c_{2,total} \cdot (c_{1,total})^{-x} \bmod p

Step 1: Compute (c1,total)x(c_{1,total})^x (c1,total)x=186mod23(c_{1,total})^x = 18^6 \bmod 23

Compute 186mod2318^6 \bmod 23:

  • 182=324mod23=32414×23=324322=218^2 = 324 \bmod 23 = 324 - 14 \times 23 = 324 - 322 = 2
  • 184=(182)2=22=4mod23=418^4 = (18^2)^2 = 2^2 = 4 \bmod 23 = 4
  • 186=184×182=4×2=8mod23=818^6 = 18^4 \times 18^2 = 4 \times 2 = 8 \bmod 23 = 8

Step 2: Compute (c1,total)x=81mod23(c_{1,total})^{-x} = 8^{-1} \bmod 23

Use extended Euclidean algorithm to find 81mod238^{-1} \bmod 23:

  • 23=8×2+723 = 8 \times 2 + 7
  • 8=7×1+18 = 7 \times 1 + 1
  • 7=1×7+07 = 1 \times 7 + 0

Back substitution:

  • 1=87×11 = 8 - 7 \times 1
  • 7=238×27 = 23 - 8 \times 2
  • 1=8(238×2)=8×3231 = 8 - (23 - 8 \times 2) = 8 \times 3 - 23

Therefore 813(mod23)8^{-1} \equiv 3 \pmod{23}

Verification: 8×3=241(mod23)8 \times 3 = 24 \equiv 1 \pmod{23}

Step 3: Compute gbig^{\sum b_i} gbi=c2,total(c1,total)x=16×3mod23=48mod23=482×23=4846=2g^{\sum b_i} = c_{2,total} \cdot (c_{1,total})^{-x} = 16 \times 3 \bmod 23 = 48 \bmod 23 = 48 - 2 \times 23 = 48 - 46 = 2

Therefore gbi=2mod23g^{\sum b_i} = 2 \bmod 23

Step 4: Compute Discrete Logarithm bi=log52mod23\sum b_i = \log_5 2 \bmod 23

Since bi3\sum b_i \leq 3 (only 3 votes), can exhaustively search:

  • 50=1mod23=15^0 = 1 \bmod 23 = 1
  • 51=5mod23=55^1 = 5 \bmod 23 = 5
  • 52=25mod23=25^2 = 25 \bmod 23 = 2

Therefore bi=2\sum b_i = 2

Verification:

  • Voter 1: b1=1b_1 = 1
  • Voter 2: b2=0b_2 = 0
  • Voter 3: b3=1b_3 = 1
  • bi=1+0+1=2\sum b_i = 1 + 0 + 1 = 2

Counting Result:

  • Support votes: bi=2\sum b_i = 2
  • Oppose votes: 32=13 - 2 = 1

Calculation Complete!


Problem 22: Complete Zero Knowledge Proof AND Proof Calculation

Problem: In zero knowledge proof AND proof, given:

  • Group Z23\mathbb{Z}_{23}^*, generators g1=2g_1 = 2, g2=3g_2 = 3
  • y1=4y_1 = 4 (assume y1=g1x1y_1 = g_1^{x_1}, i.e., 2x1=42^{x_1} = 4, so x1=2x_1 = 2)
  • y2=9y_2 = 9 (assume y2=g2x2y_2 = g_2^{x_2}, i.e., 3x2=93^{x_2} = 9, so x2=2x_2 = 2)
  • Prover knows x1=2x_1 = 2 and x2=2x_2 = 2
  • Prover chooses: r1=4r_1 = 4, r2=5r_2 = 5
  • Verifier chooses challenge: c=6c = 6

Please complete: (1) Compute commitment (a1,a2)(a_1, a_2) (2) Compute response (z1,z2)(z_1, z_2) (3) Verify proof

Complete Solution:

(1) Compute Commitment (a1,a2)(a_1, a_2)

Prover Knows: x1=2x_1 = 2, x2=2x_2 = 2 Prover Chooses: r1=4r_1 = 4, r2=5r_2 = 5

Compute Commitment:

  • a1=g1r1=24mod23=16a_1 = g_1^{r_1} = 2^4 \bmod 23 = 16
  • a2=g2r2=35mod23a_2 = g_2^{r_2} = 3^5 \bmod 23

Compute 35mod233^5 \bmod 23:

  • 32=9mod23=93^2 = 9 \bmod 23 = 9
  • 34=(32)2=92=81mod23=813×23=8169=123^4 = (3^2)^2 = 9^2 = 81 \bmod 23 = 81 - 3 \times 23 = 81 - 69 = 12
  • 35=34×3=12×3=36mod23=361×23=133^5 = 3^4 \times 3 = 12 \times 3 = 36 \bmod 23 = 36 - 1 \times 23 = 13

Therefore a2=13a_2 = 13

Commitment: (a1,a2)=(16,13)(a_1, a_2) = (16, 13)

(2) Compute Response (z1,z2)(z_1, z_2)

Verifier Challenge: c=6c = 6

Compute Response:

  • z1=r1+cx1modq=4+6×2mod11=4+12mod11=16mod11=5z_1 = r_1 + cx_1 \bmod q = 4 + 6 \times 2 \bmod 11 = 4 + 12 \bmod 11 = 16 \bmod 11 = 5
  • z2=r2+cx2modq=5+6×2mod11=5+12mod11=17mod11=6z_2 = r_2 + cx_2 \bmod q = 5 + 6 \times 2 \bmod 11 = 5 + 12 \bmod 11 = 17 \bmod 11 = 6

(Note: Here q=11q = 11 is the order of the group, known from previous calculations)

Response: (z1,z2)=(5,6)(z_1, z_2) = (5, 6)

(3) Verify Proof

Verification Formula:

  • Check g1z1=a1y1cg_1^{z_1} = a_1 \cdot y_1^c
  • Check g2z2=a2y2cg_2^{z_2} = a_2 \cdot y_2^c

Verify First Relation:

  • Left side: g1z1=25mod23=32mod23=3223=9g_1^{z_1} = 2^5 \bmod 23 = 32 \bmod 23 = 32 - 23 = 9
  • Right side: a1y1c=16×46mod23a_1 \cdot y_1^c = 16 \times 4^6 \bmod 23

Compute 46mod234^6 \bmod 23:

  • 42=16mod23=164^2 = 16 \bmod 23 = 16
  • 44=(42)2=162=256mod23=25611×23=256253=34^4 = (4^2)^2 = 16^2 = 256 \bmod 23 = 256 - 11 \times 23 = 256 - 253 = 3
  • 46=44×42=3×16=48mod23=482×23=4846=24^6 = 4^4 \times 4^2 = 3 \times 16 = 48 \bmod 23 = 48 - 2 \times 23 = 48 - 46 = 2

Therefore right side: 16×2=32mod23=916 \times 2 = 32 \bmod 23 = 9

  • Left side: 99
  • Right side: 99
  • 9=99 = 9

Verify Second Relation:

  • Left side: g2z2=36mod23g_2^{z_2} = 3^6 \bmod 23

Compute 36mod233^6 \bmod 23:

  • 36=35×3=13×3=39mod23=391×23=163^6 = 3^5 \times 3 = 13 \times 3 = 39 \bmod 23 = 39 - 1 \times 23 = 16

  • Right side: a2y2c=13×96mod23a_2 \cdot y_2^c = 13 \times 9^6 \bmod 23

Compute 96mod239^6 \bmod 23:

  • 92=81mod23=129^2 = 81 \bmod 23 = 12
  • 94=(92)2=122=144mod23=1446×23=144138=69^4 = (9^2)^2 = 12^2 = 144 \bmod 23 = 144 - 6 \times 23 = 144 - 138 = 6
  • 96=94×92=6×12=72mod23=723×23=7269=39^6 = 9^4 \times 9^2 = 6 \times 12 = 72 \bmod 23 = 72 - 3 \times 23 = 72 - 69 = 3

Therefore right side: 13×3=39mod23=1613 \times 3 = 39 \bmod 23 = 16

  • Left side: 1616
  • Right side: 1616
  • 16=1616 = 16

Both Verifications Pass! AND Proof is Valid!


Document continues with more key exam problems...