viff
view viff/hash_broadcast.py @ 1430:0164b895d948
Hash_broadcast: Removed the signal round since it does not improve security.
| author | Janus Dam Nielsen <janus.nielsen@alexandra.dk> |
|---|---|
| date | Tue Feb 02 17:08:16 2010 +0100 (2 years ago) |
| parents | 878eeda73dab |
| children | 6d838b2d24a2 |
line source
1 #!/usr/bin/env python
3 # Copyright 2009 VIFF Development Team.
4 #
5 # This file is part of VIFF, the Virtual Ideal Functionality Framework.
6 #
7 # VIFF is free software: you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License (LGPL) as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
11 #
12 # VIFF is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15 # Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
31 pass
34 """A weak-crusader broadcast scheme.
36 A value is send using `send_value` and when received a hash is
37 generated and exchanged among the receivers. If a receiver
38 receives a hash which is not equal to the one he generated, then
39 he aborts. Else he returns the received value and the computation
40 continues."""
47 # The result.
49 # The message store.
51 # The hash store
55 # Store the hash.
57 # If we have received a hash from everybody, then compute check them.
59 # We check if the hashes we received are equal to
60 # the hash we computed ourselves.
61 s = reduce(lambda x, y: (a_hashes[self.id] == y and x) or INCONSISTENTHASH, [OK] + a_hashes.values())
63 # Make the result ready.
69 # Store the message.
71 # Compute hash of message.
73 # Store hash.
75 # Send the hash to all receivers.
79 # Set up receiver for hashes.
80 # Note, we use the unique_pc to avoid data to cross
81 # method invocation boundaries.
88 # Set up receiving of the message.
97 """Broadcast the messeage from senders to receivers.
99 Returns a list of deferreds if the calling player is among
100 the receivers and there are multiple senders.
101 Returns a single element if there is only on sender, or the
102 calling player is among the senders only.
104 The order of the resulting list is guaranteed to be the same order
105 as the list of senders.
107 Senders and receivers should be lists containing the id of the senders
108 and receivers, respectively.
110 Note: You send implicitly to your self."""
