viff
view viff/bedoza/zero_knowledge.py @ 1572:54f02cd75714
BeDOZa: Improved comments.
| author | Thomas P Jakobsen <tpj@cs.au.dk> |
|---|---|
| date | Mon Oct 04 10:58:23 2010 +0200 (19 months ago) |
| parents | cb800e02f5bd |
| children |
line source
1 # Copyright 2010 VIFF Development Team.
2 #
3 # This file is part of VIFF, the Virtual Ideal Functionality Framework.
4 #
5 # VIFF is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License (LGPL) as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
9 #
10 # VIFF is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 # Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
26 """Zero-knowledge protocol used as part of the Share protocol.
28 In this proof, a player (the player with id prover_id) inputs s
29 ciphertexts c[i] = E(x[j], r[j]), for i = 1, ..., s, created using
30 the modified Paillier cipher and proves to the other players that
31 he knows the plaintexts x[j] and that the x[i]'s are of limited
32 size, e.g. that abs(x[i]) <= 2**k.
33 """
36 """
37 random: a random source (e.g. viff.util.Random)
39 All players must submit the same vector c, but only the player
40 with id prover_id should submit the corresponding x and r, e.g. where
41 c_i = E_i(x_i, r_i).
42 """
60 # TODO: Use the n**2 already in the pubkey.
64 """Executes this zero-knowledge proof.
66 Returns a deferred evaluating to True if the proof succeeds
67 and False otherwise. The proof succeeds if the verifiers,
68 e.g. all players except the player with prover_id are able to
69 verify that each number inside the encryptions c are
70 numerically at most 2**(s + 2k).
72 The result also evaluates to True or False as above for the
73 proving player, even though this is not needed.
74 """
87 # The prover don't need to prove to himself.
94 T = [mpz(self.paillier.encrypt(int(self.Z[j]), player_id=self.prover_id, random_elm=int(self.W[j])))
97 # TODO: Return false if S[j] != T[j].
99 # TODO: Proof failed, return false!
100 pass
102 # TODO: Proof failed, return false!
103 pass
105 # TODO: Fix zero-knowledge proof!!!
126 # TODO: Should we somehow compress message for improved
127 # performance?
136 # We remove quotes before evaluation in order to get a list.
143 """Returns list of first no_of_bits from the given string."""
159 """Generating an s-bit challenge e by the Fiat-Shamir heuristic.
161 In other security models, generating the challenge requires
162 interaction.
164 The challenge is a list of 0's and 1's of length s.
165 """
166 # This can be easily fixed by using the hash as seed for a
167 # secure prng.
188 """Computes the value of the entry in the matrix E at the given row
189 and column.
191 The first column of E consists of the bits of e followed by 0's;
192 The next column has one zero, then the bits of e, followed by 0's,
193 etc.
194 """
204 """Takes an s x 1 vector x and returns the m x 1 vector xE."""
205 # TODO: This could probably be optimized since we know the
206 # structure of E.
219 """Computes and returns the m := 2s-1 length vector y**E."""
226 # TODO: Should we reduce modulo n each time?
