changeset 591:80e49a760164

More whitespace changes.
author Martin Geisler <mg@daimi.au.dk>
date Thu, 20 Mar 2008 00:11:48 +0100
parents 8a79bf7ed805
children ac18c350f8ca
files viff/comparison.py viff/runtime.py viff/shamir.py viff/test/loopback.py viff/test/test_active_runtime.py viff/test/test_async.py viff/test/test_matrix.py
diffstat 7 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/viff/comparison.py	Thu Mar 20 00:09:46 2008 +0100
+++ b/viff/comparison.py	Thu Mar 20 00:11:48 2008 +0100
@@ -28,6 +28,7 @@
 from viff.runtime import Runtime, Share, gather_shares, increment_pc
 from viff.field import GF256, FieldElement
 
+
 class ComparisonToft05Mixin:
     """Comparison by Tomas Toft, 2005."""
 
@@ -137,6 +138,7 @@
         bot = top_b * (bot_a ^ bot_b) ^ bot_b
         return (top, bot)
 
+
 class Toft05Runtime(ComparisonToft05Mixin, Runtime):
     """Default mix of L{ComparisonToft05Mixin} and L{Runtime}."""
     pass
@@ -337,6 +339,7 @@
         return self.greater_than_equal_online(share_a, share_b, preproc,
                                               field)
 
+
 class Toft07Runtime(ComparisonToft07Mixin, Runtime):
     """Default mix of L{ComparisonToft07Mixin} and L{Runtime}."""
     pass
--- a/viff/runtime.py	Thu Mar 20 00:09:46 2008 +0100
+++ b/viff/runtime.py	Thu Mar 20 00:11:48 2008 +0100
@@ -136,6 +136,7 @@
         Works like L{util.clone_deferred} except that it returns a new
         Share instead of a Deferred.
         """
+
         def split_result(result):
             clone.callback(result)
             return result
@@ -188,6 +189,7 @@
 
     Roughly modelled after the Twisted C{gatherResults} function.
     """
+
     def filter_results(results):
         return [share for (_, share) in results]
     share_list = ShareList(shares)
@@ -279,7 +281,6 @@
 
         self.sendData(program_counter, "share", share.value)
 
-
     def loseConnection(self):
         """Disconnect this protocol instance."""
         self.transport.loseConnection()
@@ -479,6 +480,7 @@
         All connections are closed and the runtime cannot be used
         again after this has been called.
         """
+
         def stop(_):
             println("Initiating shutdown sequence.")
             for protocol in self.protocols.itervalues():
@@ -1008,10 +1010,10 @@
         who wish to broadcast a message. If this player wishes to
         broadcast, its id must be in the list of senders and the
         optional message parameter must be used.
-        
+
         If the list of senders consists only of a single sender, the
         result will be a single element, otherwise it will be a list.
-        
+
         A Bracha broadcast is reliable against an active adversary
         corrupting up to t < n/3 of the players. For more details, see
         the paper "An asynchronous [(n-1)/3]-resilient consensus
@@ -1034,7 +1036,7 @@
 
         if len(result) == 1:
             return result[0]
-        
+
         return result
 
     @increment_pc
--- a/viff/shamir.py	Thu Mar 20 00:09:46 2008 +0100
+++ b/viff/shamir.py	Thu Mar 20 00:11:48 2008 +0100
@@ -119,14 +119,14 @@
 
     >>> from field import GF
     >>> Zp = GF(47)
-    >>> shares = [(Zp(i), Zp(i**2)) for i in range(1, 6)] 
-    >>> print shares                                      
+    >>> shares = [(Zp(i), Zp(i**2)) for i in range(1, 6)]
+    >>> print shares
     [({1}, {1}), ({2}, {4}), ({3}, {9}), ({4}, {16}), ({5}, {25})]
     >>> verify_sharing(shares, 2)
     True
     >>> verify_sharing(shares, 1)
     False
-    >>> 
+    >>>
 
     @param shares: The shares to be checked.
     @param degree: The maximum degree of the interpolating polynomial.
@@ -138,7 +138,7 @@
             return False
 
     return True
-        
+
 
 if __name__ == "__main__":
     import doctest    #pragma NO COVER
--- a/viff/test/loopback.py	Thu Mar 20 00:09:46 2008 +0100
+++ b/viff/test/loopback.py	Thu Mar 20 00:11:48 2008 +0100
@@ -66,6 +66,7 @@
 
 from viff.util import rand
 
+
 class _LoopbackQueue(object):
     """
     Trivial wrapper around a list to give it an interface like a queue, which
@@ -79,23 +80,19 @@
     def __init__(self):
         self._queue = []
 
-
     def put(self, v):
         self._queue.append(v)
         if self._notificationDeferred is not None:
             d, self._notificationDeferred = self._notificationDeferred, None
             d.callback(None)
 
-
     def __nonzero__(self):
         return bool(self._queue)
 
-
     def get(self):
         return self._queue.pop(0)
 
 
-
 class _LoopbackAddress(object):
     implements(IAddress)
 
@@ -107,6 +104,7 @@
     producer = None
 
     # ITransport
+
     def __init__(self, q):
         self.q = q
         self._buffer = ''
@@ -125,7 +123,7 @@
         if self.q.disconnect:
             # We are disconnected, so just return.
             return
-            
+
         if self._pending is None or not self._pending.active():
             delay = rand.uniform(0, 0.001)
             self._pending = reactor.callLater(delay, self._send_some_bytes)
@@ -179,6 +177,7 @@
         return _LoopbackAddress()
 
     # IConsumer
+
     def registerProducer(self, producer, streaming):
         assert self.producer is None
         self.producer = producer
--- a/viff/test/test_active_runtime.py	Thu Mar 20 00:09:46 2008 +0100
+++ b/viff/test/test_active_runtime.py	Thu Mar 20 00:11:48 2008 +0100
@@ -49,8 +49,6 @@
             y, z = runtime.broadcast([2, 3])
 
         x.addCallback(self.assertEquals, "Hello world!")
-        
         y.addCallback(self.assertEquals, "Hello two!")
         z.addCallback(self.assertEquals, "Hello three!")
-        
         return gatherResults([x, y, z])
--- a/viff/test/test_async.py	Thu Mar 20 00:09:46 2008 +0100
+++ b/viff/test/test_async.py	Thu Mar 20 00:11:48 2008 +0100
@@ -76,7 +76,7 @@
         closed = DeferredList([closed_a, closed_b])
         closed.addCallback(check, server_a, client_a, server_b, client_b)
         return closed
-        
+
     def test_interleaving(self):
         """Ensure that protocol runs are interleaved differently each time."""
 
--- a/viff/test/test_matrix.py	Thu Mar 20 00:09:46 2008 +0100
+++ b/viff/test/test_matrix.py	Thu Mar 20 00:11:48 2008 +0100
@@ -25,10 +25,10 @@
 from viff.prss import generate_subsets
 from twisted.trial.unittest import TestCase
 
+
 class MatrixTest(TestCase):
     """Matrix tests."""
 
-    
     def is_hyper(self, mat):
         """Checks if a square matrix is hyper-invertible.
 
@@ -54,4 +54,3 @@
         for i in range(1, 6):
             m = hyper(i, Zp)
             self.assertTrue(self.is_hyper(m))
-