Zero Knowledge Proofs
Sam Goto
This is an interactive explanation of the protocol described here.
Alice
wants to prove that it knows x
= such that g ^ x mod p = y
without revealing to Bob
the value of x
, having agreed ahead of time on a large prime number p
= , a primitive root g
= and an integer y
= .
The way they accomplish that is by:
Alice
generates a random numberr
= and commits to it by computingC
=g ^ r mod p
=^
mod
=
=
C
and sending it toBob
.Bob
asks forw
=(x + r) mod (p - 1)
with the samer
that was committed toC
Alice
computesw
=(x + r) mod (p - 1)
= (+
) mod (
- 1)=
=
w
and sends it toBob
.Bob
knows that:a ^ x * a ^ y = a ^ (x + y)
(arithmetic),a ^ x mod p = a ^ (x mod (p - 1)) mod p
(fermat's little theorem)y = g ^ x mod p
(definition)
- So
y * C mod p
=g ^ x * g ^ r mod p
=g ^ (x + r) mod p
=g ^ ((x + r) mod (p - 1))
=g ^ w mod p
. Bob
computesy * C mod p
=*
mod
=
and
g ^ w mod p
=^
mod
=
- And if these numbers match,
Bob
knows thatAlice
knowsx
unlessAlice
wasn't cheating.
Bob
is suspicious that if Alice picks a specificr
=z
= and responded withC
=g ^ (z / y) mod p
=^ (
/
) mod
=
=
C
andw
=z
==
w
, then- Then
Bob
would compute=
y * C mod p
=y * g ^ (z / y) mod p
=g ^ z mod p
=without
Alice
knowing whatx
is.
Bob
also knows that:- To prove that
Alice
chose a randomr
, Bob would have to ask for it, so that it can check ifg ^ r mod p
=C
matches what he got. - But, if
Bob
asks for both(x + r) mod (p - 1)
andr
, then that reveals toBob
whatx
is.
- To prove that
- So,
Bob
asksAlice
repeatedly until it is confident thatAlice
isn't cheating- Commit and send me a
C
and - I'll ask you one of the following requests after you commit to a
C
:- Send me
r
(without revealing mex
) so that I can check if you didn't cheat at constructingC
=g ^ (z / y) mod p
but rather usedg ^ r mod p
=C
that I got. - Send me
w
(without revealing mer
), so that I can check ify * C mod p
=g ^ w mod p
with theC
that I got.
- Send me
- Commit and send me a
- Every time
Bob
repeats this process, he gets exponentially confident thatAlice
(a) isn't cheating and (b) knows the value ofx
.