Zero-Knowledge Proof Demo - Problem
Implement a simplified zero-knowledge proof protocol to demonstrate the concept where a prover can convince a verifier that they know a secret without revealing the secret itself.
For this problem, we'll implement a basic discrete logarithm zero-knowledge proof protocol:
1. Setup Phase: Given a prime p, generator g, and public key y = g^x mod p where x is the secret
2. Proof Phase: The prover generates a random r, computes commitment t = g^r mod p
3. Challenge Phase: The verifier sends a random challenge c
4. Response Phase: The prover computes response s = (r + c*x) mod (p-1)
5. Verification: The verifier checks if g^s ≡ t * y^c (mod p)
Given the protocol parameters, simulate one round of this zero-knowledge proof and return whether the verification succeeds.
Input & Output
Constraints
- 2 ≤ p ≤ 109 (p is prime)
- 1 ≤ g < p (g is generator)
- 1 ≤ y < p (y = gx mod p)
- 1 ≤ x < p-1 (secret key)
- 0 ≤ r < p-1 (random nonce)
- 1 ≤ c < p-1 (challenge)