viff

changeset 1525:80841840990f

SimpleArithmetic, Orlandi, BeDOZa: Removed _get_triple.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Mon, 26 Jul 2010 14:46:15 +0200
parents 8da98c5697b5
children a87fd09f8c38
files viff/bedoza/bedoza.py viff/orlandi.py viff/simplearithmetic.py viff/test/test_bedoza_runtime.py viff/test/test_orlandi_runtime.py
diffstat 5 files changed, 123 insertions(+), 172 deletions(-) [+]
line diff
     1.1 --- a/viff/bedoza/bedoza.py	Mon Jul 26 11:11:05 2010 +0200
     1.2 +++ b/viff/bedoza/bedoza.py	Mon Jul 26 14:46:15 2010 +0200
     1.3 @@ -34,6 +34,7 @@
     1.4  
     1.5  from viff.bedoza.share_generators import ShareGenerator
     1.6  
     1.7 +
     1.8  class BeDOZaException(Exception):
     1.9      pass
    1.10  
    1.11 @@ -304,9 +305,6 @@
    1.12          assert(isinstance(c, FieldElement))
    1.13          return x.cmul(c)
    1.14  
    1.15 -    def _get_triple(self, field):
    1.16 -        return self.triples.pop(), False
    1.17 -
    1.18  
    1.19  class BeDOZaRuntime(BeDOZaMixin, SimpleArithmeticRuntime):
    1.20      """The BeDOZa runtime.
    1.21 @@ -328,8 +326,12 @@
    1.22      it is ready.
    1.23      """
    1.24  
    1.25 -    def __init__(self, player, threshold=None, options=None):
    1.26 -        """Initialize runtime."""
    1.27 +    def __init__(self, player, threshold=None, options=None, triples=[]):
    1.28 +        """Initialize runtime.
    1.29 +
    1.30 +        *triples* is a list of multiplicative triples previously
    1.31 +        generated using the bedoza_triple.TripleGenerator.
    1.32 +        """
    1.33          SimpleArithmeticRuntime.__init__(self, player, threshold, options)
    1.34          self.threshold = self.num_players - 1
    1.35 -
    1.36 +        self.triples = triples
     2.1 --- a/viff/orlandi.py	Mon Jul 26 11:11:05 2010 +0200
     2.2 +++ b/viff/orlandi.py	Mon Jul 26 14:46:15 2010 +0200
     2.3 @@ -35,6 +35,8 @@
     2.4  
     2.5  from viff.simplearithmetic import SimpleArithmeticRuntime
     2.6  
     2.7 +from viff.triple import Triple
     2.8 +
     2.9  from hash_broadcast import HashBroadcastMixin
    2.10  
    2.11  try:
    2.12 @@ -631,16 +633,6 @@
    2.13      
    2.14      def _wrap_in_share(self, (zi, rhoz, Cz), field):
    2.15          return OrlandiShare(self, field, zi, rhoz, Cz)
    2.16 -
    2.17 -    @preprocess("random_triple")
    2.18 -    def _get_triple(self, field):
    2.19 -        results = [Share(self, field) for i in range(3)]
    2.20 -        def chain(triple, results):
    2.21 -            for i, result in zip(triple, results):
    2.22 -                result.callback(i)
    2.23 -        self.random_triple(field, 1)[0].addCallbacks(chain, self.error_handler,
    2.24 -                                                     (results,))
    2.25 -        return results
    2.26      
    2.27      def sum_poly(self, j, ls):
    2.28          exp  = j
    2.29 @@ -665,7 +657,7 @@
    2.30          Communication cost: ???.
    2.31  
    2.32          Assuming a set of multiplicative triples:
    2.33 -        ``M = ([a_i], [b_i], [c_i]) for 1 <= i <= 2d + 1``.
    2.34 +        ``M = Triple([a_i], [b_i], [c_i]) for 1 <= i <= 2d + 1``.
    2.35  
    2.36          1. ``for i = 1, ..., d do [f_i] = rand(), [g_i] = rand()``
    2.37  
    2.38 @@ -705,7 +697,7 @@
    2.39              f.append(self.random_share(field))
    2.40              g.append(self.random_share(field))
    2.41  
    2.42 -        def compute_polynomials(t):
    2.43 +        def compute_polynomials(t, M):
    2.44              x, y = t[0]
    2.45              f = []
    2.46              g = []
    2.47 @@ -754,10 +746,13 @@
    2.48                      C_Gji *= Cw
    2.49                  Fj = OrlandiShare(self, field, Fji, (rho1_Fji, rho2_Fji), C_Fji)
    2.50                  Gj = OrlandiShare(self, field, Gji, (rho1_Gji, rho2_Gji), C_Gji)
    2.51 -                a, b, c = M.pop(0)
    2.52 +                triple = M.pop(0)
    2.53  
    2.54                  # [H_j] = Mul([F_j], [G_j], [a_j], [b_j], [c_j])
    2.55 -                Hj = self._basic_multiplication(Fj, Gj, a, b, c)
    2.56 +                Hj = self._basic_multiplication(Fj, Gj,
    2.57 +                                                triple.a,
    2.58 +                                                triple.b,
    2.59 +                                                triple.c)
    2.60                  dj = self._cmul(field(deltas[j - 1]), Hj, field)
    2.61                  H0 = H0 + dj
    2.62              # 5) output [z] = [H_0]
    2.63 @@ -768,7 +763,7 @@
    2.64              ls.append(gather_shares(f))
    2.65              ls.append(gather_shares(g))
    2.66          result = gather_shares(ls)
    2.67 -        self.schedule_callback(result, compute_polynomials)
    2.68 +        self.schedule_callback(result, compute_polynomials, M)
    2.69          result.addErrback(self.error_handler)
    2.70  
    2.71          # do actual communication
    2.72 @@ -777,7 +772,7 @@
    2.73          return result
    2.74  
    2.75      def triple_gen(self, field):
    2.76 -        """Generate a triple ``a, b, c`` s.t. ``c = a * b``.
    2.77 +        """Generate a triple ``Tripel(a, b, c)`` s.t. ``c = a * b``.
    2.78  
    2.79          1. Every party ``P_i`` chooses random values ``a_i, r_i in Z_p
    2.80             X (Z_p)^2``, compute ``alpha_i = Enc_eki(a_i)`` and ``Ai =
    2.81 @@ -836,7 +831,7 @@
    2.82              a = OrlandiShare(self, field, ai, r, A)
    2.83              b = OrlandiShare(self, field, bi, s, B)
    2.84              c = OrlandiShare(self, field, ci, t, C)
    2.85 -            return (a, b, c, (alphas, alpha_randomness, gammas, dijs))
    2.86 +            return (Triple(a, b, c), (alphas, alpha_randomness, gammas, dijs))
    2.87  
    2.88          def decrypt_gammas(ls):
    2.89              """Decrypt all the elements of the list *ls*."""
    2.90 @@ -969,18 +964,18 @@
    2.91          triple2 = self.triple_gen(field)
    2.92          r = self.open(self.random_share(field))
    2.93  
    2.94 -        def check(v, a, b, c, ec):
    2.95 +        def check(v, triple, ec):
    2.96              if v.value != 0:
    2.97                  raise OrlandiException("TripleTest failed - The two triples were inconsistent.")
    2.98 -            return (a, b, c, ec)
    2.99 +            return (triple, ec)
   2.100  
   2.101 -        def compute_value(((a, b, c, ec), (x, y, z, _), r)):
   2.102 -            l = self._cmul(r, x, field)
   2.103 -            m = self._cmul(r, y, field)
   2.104 -            n = self._cmul(r*r, z, field)
   2.105 -            d = c - self._basic_multiplication(a, b, l, m, n)
   2.106 +        def compute_value(((t1, ec), (t2, _), r)):
   2.107 +            l = self._cmul(r, t2.a, field)
   2.108 +            m = self._cmul(r, t2.b, field)
   2.109 +            n = self._cmul(r*r, t2.c, field)
   2.110 +            d = t1.c - self._basic_multiplication(t1.a, t1.b, l, m, n)
   2.111              r = self.open(d)
   2.112 -            r.addCallbacks(check, self.error_handler, callbackArgs=(a, b, c, ec))
   2.113 +            r.addCallbacks(check, self.error_handler, callbackArgs=(t1, ec))
   2.114              return r
   2.115  
   2.116          result = gatherResults([triple1, triple2, r])
   2.117 @@ -993,9 +988,9 @@
   2.118          return result
   2.119  
   2.120      def random_triple(self, field, quantity=1):
   2.121 -        """Generate a list of triples ``(a, b, c)`` where ``c = a * b``.
   2.122 +        """Generate a list of triples ``Triple(a, b, c)`` where ``c = a * b``.
   2.123  
   2.124 -        The triple ``(a, b, c)`` is secure in the Fcrs-hybrid model.
   2.125 +        The triple ``Triple(a, b, c)`` is secure in the Fcrs-hybrid model.
   2.126  
   2.127          """
   2.128          self.increment_pc()
   2.129 @@ -1160,7 +1155,10 @@
   2.130                  return True
   2.131  
   2.132              dls_all = []
   2.133 -            for (a, b, c, (alphas, alpha_randomness, gammas, dijs)) in T:
   2.134 +            for (triple, (alphas, alpha_randomness, gammas, dijs)) in T:
   2.135 +                a = triple.a
   2.136 +                b = triple.b
   2.137 +                c = triple.c
   2.138                  ds_a = [None] * len(self.players)
   2.139                  ds_b = [None] * len(self.players)
   2.140                  ds_c = [None] * len(self.players)
   2.141 @@ -1201,8 +1199,8 @@
   2.142  
   2.143              def result(x):
   2.144                  ls = []
   2.145 -                for a, b, c, _ in M_without_test_set:
   2.146 -                    ls.append((a, b, c))
   2.147 +                for triple, _ in M_without_test_set:
   2.148 +                    ls.append(triple)
   2.149                  return ls
   2.150  
   2.151              dls_all = gatherResults(dls_all)
   2.152 @@ -1252,7 +1250,7 @@
   2.153                  c = self.leak_tolerant_mul(a, b, Mi)
   2.154                  d = self.open(c + r)
   2.155                  def return_abc(x, a, b, c, result):
   2.156 -                    gatherResults([a, b, c]).chainDeferred(result)
   2.157 +                    result.callback(Triple(a, b, c))
   2.158                  d.addCallbacks(return_abc, self.error_handler, callbackArgs=(a, b, c, result))
   2.159  
   2.160          result = gatherResults(M)
   2.161 @@ -1304,3 +1302,4 @@
   2.162          self.s = 1
   2.163          self.d = 0
   2.164          self.s_lambda = 1
   2.165 +        self.triples = []
     3.1 --- a/viff/simplearithmetic.py	Mon Jul 26 11:11:05 2010 +0200
     3.2 +++ b/viff/simplearithmetic.py	Mon Jul 26 14:46:15 2010 +0200
     3.3 @@ -92,11 +92,12 @@
     3.4  
     3.5          field = getattr(share_x, "field", getattr(share_y, "field", None))
     3.6  
     3.7 -        triple, prep = self._get_triple(field)
     3.8 -        if prep:
     3.9 -            # The data from the pool must be wrapped in Shares.
    3.10 -            triple = [Share(self, field, i) for i in triple]
    3.11 -        return self._basic_multiplication(share_x, share_y, *triple)
    3.12 +        triple = self.triples.pop()
    3.13 +        return self._basic_multiplication(share_x,
    3.14 +                                          share_y,
    3.15 +                                          triple.a,
    3.16 +                                          triple.b,
    3.17 +                                          triple.c)
    3.18  
    3.19      def _cmul(self, share_x, share_y, field):
    3.20          """Multiplication of a share with a constant.
     4.1 --- a/viff/test/test_bedoza_runtime.py	Mon Jul 26 11:11:05 2010 +0200
     4.2 +++ b/viff/test/test_bedoza_runtime.py	Mon Jul 26 14:46:15 2010 +0200
     4.3 @@ -382,34 +382,38 @@
     4.4          runtime.schedule_callback(triple, do_stuff, alpha)
     4.5          return triple
     4.6  
     4.7 -    # @protocol
     4.8 -    # def test_mul_mul(self, runtime):
     4.9 -    #     """Test multiplication of two numbers."""
    4.10 +    @protocol
    4.11 +    def test_mul_mul(self, runtime):
    4.12 +        """Test multiplication of two numbers."""
    4.13  
    4.14 -    #     x1 = 6
    4.15 -    #     y1 = 6
    4.16 +        x1 = 6
    4.17 +        y1 = 6
    4.18  
    4.19 -    #     def check(v):
    4.20 -    #         self.assertEquals(v, self.Zp(x1 * y1))
    4.21 +        def check(v):
    4.22 +            self.assertEquals(v, self.Zp(x1 * y1))
    4.23  
    4.24 -    #     gen = TripleGenerator(runtime, self.Zp.modulus, Random(3423993))
    4.25 -    #     alpha = gen.alpha
    4.26 -    #     runtime.triples = gen.generate_triples(1)
    4.27 +        gen = TripleGenerator(runtime, self.Zp.modulus, Random(3423993))
    4.28 +        alpha = gen.alpha
    4.29 +        triples = gen.generate_triples(1)
    4.30          
    4.31 -
    4.32 -    #     random = Random(3423993)
    4.33 -    #     share_random = Random(random.getrandbits(128))
    4.34 -    #     paillier = ModifiedPaillier(runtime, Random(random.getrandbits(128)))          
    4.35 -    #     gen = ShareGenerator(self.Zp, runtime, share_random,
    4.36 -    #                          paillier, self.u_bound, self.alpha)
    4.37 +        def do_mult(triples, alpha):
    4.38 +            runtime.triples = triples
    4.39 +            random = Random(3423993)
    4.40 +            share_random = Random(random.getrandbits(128))
    4.41 +            paillier = ModifiedPaillier(runtime, Random(random.getrandbits(128)))          
    4.42 +            gen = ShareGenerator(self.Zp, runtime, share_random,
    4.43 +                                 paillier, self.u_bound, alpha)
    4.44          
    4.45 -    #     x2 = gen.generate_share(x1)
    4.46 -    #     y2 = gen.generate_share(y1)
    4.47 +            x2 = gen.generate_share(x1)
    4.48 +            y2 = gen.generate_share(y1)
    4.49          
    4.50 -    #     z2 = x2 * y2
    4.51 -    #     d = runtime.open(z2)
    4.52 -    #     d.addCallback(check)
    4.53 -    #     return d
    4.54 +            z2 = x2 * y2
    4.55 +            d = runtime.open(z2)
    4.56 +            d.addCallback(check)
    4.57 +            return d
    4.58 +        r = gatherResults(triples)
    4.59 +        runtime.schedule_callback(r, do_mult, alpha)
    4.60 +        return r
    4.61      
    4.62      @protocol
    4.63      def test_basic_multiply_constant_right(self, runtime):
     5.1 --- a/viff/test/test_orlandi_runtime.py	Mon Jul 26 11:11:05 2010 +0200
     5.2 +++ b/viff/test/test_orlandi_runtime.py	Mon Jul 26 14:46:15 2010 +0200
     5.3 @@ -492,13 +492,20 @@
     5.4          def check(v):
     5.5              self.assertEquals(v, x1 * y1)
     5.6  
     5.7 -        x2 = runtime.shift([2], self.Zp, x1)
     5.8 -        y2 = runtime.shift([3], self.Zp, y1)
     5.9 +        triples = runtime.random_triple(self.Zp, 1)
    5.10 +        
    5.11 +        def do_mult(triples):
    5.12 +            runtime.triples = triples
    5.13 +            x2 = runtime.shift([2], self.Zp, x1)
    5.14 +            y2 = runtime.shift([3], self.Zp, y1)
    5.15  
    5.16 -        z2 = x2 * y2
    5.17 -        d = runtime.open(z2)
    5.18 -        d.addCallback(check)
    5.19 -        return d
    5.20 +            z2 = x2 * y2
    5.21 +            d = runtime.open(z2)
    5.22 +            d.addCallback(check)
    5.23 +            return d
    5.24 +        r = gatherResults(triples)
    5.25 +        runtime.schedule_callback(r, do_mult)
    5.26 +        return r
    5.27  
    5.28      @protocol
    5.29      def test_basic_multiply_constant_right(self, runtime):
    5.30 @@ -667,20 +674,16 @@
    5.31          x2 = runtime.shift([1], self.Zp, x1)
    5.32          y2 = runtime.shift([2], self.Zp, y1)
    5.33  
    5.34 -        sls = gatherResults(runtime.random_triple(self.Zp, 2*runtime.d + 1))
    5.35 +        triples = runtime.random_triple(self.Zp, 2*runtime.d + 1)
    5.36  
    5.37 -        def cont(M):
    5.38 -            M = [[Share(self, self.Zp, j) for j in i] for i in M]
    5.39 -            z2 = runtime.leak_tolerant_mul(x2, y2, M)
    5.40 +        def cont(triples):
    5.41 +            z2 = runtime.leak_tolerant_mul(x2, y2, triples)
    5.42              d = runtime.open(z2)
    5.43              d.addCallback(check)
    5.44              return d
    5.45 -        sls.addCallbacks(cont, runtime.error_handler)
    5.46 -        return sls
    5.47 -
    5.48 -        z2 = runtime._cmul(y2, x2, self.Zp)
    5.49 -        self.assertEquals(z2, None)
    5.50 -        return z2
    5.51 +        r = gatherResults(triples)
    5.52 +        runtime.schedule_callback(r, cont)
    5.53 +        return r
    5.54  
    5.55      @protocol
    5.56      def test_leak_mul1(self, runtime):
    5.57 @@ -705,20 +708,17 @@
    5.58          x2 = runtime.shift([1], self.Zp, x1)
    5.59          y2 = runtime.shift([2], self.Zp, y1)
    5.60  
    5.61 -        sls = gatherResults(runtime.random_triple(self.Zp, 2*runtime.d + 1))
    5.62 +        triples = runtime.random_triple(self.Zp, 2*runtime.d + 1)
    5.63  
    5.64 -        def cont(M):
    5.65 -            M = [[Share(self, self.Zp, j) for j in i] for i in M]
    5.66 -            z2 = runtime.leak_tolerant_mul(x2, y2, M)
    5.67 +        def cont(triples):
    5.68 +            z2 = runtime.leak_tolerant_mul(x2, y2, triples)
    5.69              d = runtime.open(z2)
    5.70              d.addCallback(check)
    5.71              return d
    5.72 -        sls.addCallbacks(cont, runtime.error_handler)
    5.73 -        return sls
    5.74 +        r = gatherResults(triples)
    5.75 +        runtime.schedule_callback(r, cont)
    5.76 +        return r
    5.77  
    5.78 -        z2 = runtime._cmul(y2, x2, self.Zp)
    5.79 -        self.assertEquals(z2, None)
    5.80 -        return z2
    5.81  
    5.82  class TripleGenTest(RuntimeTestCase):
    5.83      """Test for generation of triples."""
    5.84 @@ -728,7 +728,7 @@
    5.85  
    5.86      runtime_class = OrlandiRuntime
    5.87  
    5.88 -    timeout = 1600
    5.89 +    timeout = 10
    5.90  
    5.91      def generate_configs(self, *args):
    5.92          global keys
    5.93 @@ -749,10 +749,10 @@
    5.94          def check((a, b, c)):
    5.95              self.assertEquals(c, a * b)
    5.96  
    5.97 -        def open((a, b, c, _)):
    5.98 -            d1 = runtime.open(a)
    5.99 -            d2 = runtime.open(b)
   5.100 -            d3 = runtime.open(c)
   5.101 +        def open((triple, _)):
   5.102 +            d1 = runtime.open(triple.a)
   5.103 +            d2 = runtime.open(triple.b)
   5.104 +            d3 = runtime.open(triple.c)
   5.105              d = gatherResults([d1, d2, d3])
   5.106              d.addCallback(check)
   5.107              return d
   5.108 @@ -770,13 +770,13 @@
   5.109              self.assertEquals(c, a * b)
   5.110              self.assertEquals(dz, dx * dy)
   5.111  
   5.112 -        def open(((a, b, c, control), (x, y, z, _))):
   5.113 -            d1 = runtime.open(a)
   5.114 -            d2 = runtime.open(b)
   5.115 -            d3 = runtime.open(c)
   5.116 -            dx = runtime.open(x)
   5.117 -            dy = runtime.open(y)
   5.118 -            dz = runtime.open(z)
   5.119 +        def open(((t1, control), (t2, _))):
   5.120 +            d1 = runtime.open(t1.a)
   5.121 +            d2 = runtime.open(t1.b)
   5.122 +            d3 = runtime.open(t1.c)
   5.123 +            dx = runtime.open(t2.a)
   5.124 +            dy = runtime.open(t2.b)
   5.125 +            dz = runtime.open(t2.c)
   5.126              d = gatherResults([d1, d2, d3, dx, dy, dz])
   5.127              d.addCallback(check)
   5.128              return d
   5.129 @@ -795,10 +795,10 @@
   5.130          def check((a, b, c)):
   5.131              self.assertEquals(c, a * b)
   5.132  
   5.133 -        def open((a, b, c, _)):
   5.134 -            d1 = runtime.open(a)
   5.135 -            d2 = runtime.open(b)
   5.136 -            d3 = runtime.open(c)
   5.137 +        def open((triple, _)):
   5.138 +            d1 = runtime.open(triple.a)
   5.139 +            d2 = runtime.open(triple.b)
   5.140 +            d3 = runtime.open(triple.c)
   5.141              d = gatherResults([d1, d2, d3])
   5.142              d.addCallback(check)
   5.143              return d
   5.144 @@ -819,15 +819,15 @@
   5.145                  c = ls[x * 3 + 2]
   5.146                  self.assertEquals(c, a * b)
   5.147  
   5.148 -        def open(ls):
   5.149 +        def open(triples):
   5.150 +            triple = triples[0]
   5.151              ds = []
   5.152 -            for (a, b, c) in ls:
   5.153 -                d1 = runtime.open(Share(self, self.Zp, a))
   5.154 -                d2 = runtime.open(Share(self, self.Zp, b))
   5.155 -                d3 = runtime.open(Share(self, self.Zp, c))
   5.156 -                ds.append(d1)
   5.157 -                ds.append(d2)
   5.158 -                ds.append(d3)
   5.159 +            d1 = runtime.open(triple.a)
   5.160 +            d2 = runtime.open(triple.b)
   5.161 +            d3 = runtime.open(triple.c)
   5.162 +            ds.append(d1)
   5.163 +            ds.append(d2)
   5.164 +            ds.append(d3)
   5.165  
   5.166              d = gatherResults(ds)
   5.167              d.addCallback(check)
   5.168 @@ -851,10 +851,10 @@
   5.169  
   5.170          def open(ls):
   5.171              ds = []
   5.172 -            for [(a, b, c)] in ls:
   5.173 -                d1 = runtime.open(Share(self, self.Zp, a))
   5.174 -                d2 = runtime.open(Share(self, self.Zp, b))
   5.175 -                d3 = runtime.open(Share(self, self.Zp, c))
   5.176 +            for [triple] in ls:
   5.177 +                d1 = runtime.open(triple.a)
   5.178 +                d2 = runtime.open(triple.b)
   5.179 +                d3 = runtime.open(triple.c)
   5.180                  ds.append(d1)
   5.181                  ds.append(d2)
   5.182                  ds.append(d3)
   5.183 @@ -869,61 +869,6 @@
   5.184          d.addCallbacks(open, runtime.error_handler)
   5.185          return d
   5.186  
   5.187 -    @protocol
   5.188 -    def test_random_triple_parallel(self, runtime):
   5.189 -        """Test the triple_combiner command."""
   5.190 -
   5.191 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   5.192 -
   5.193 -        def check(ls):
   5.194 -            for x in xrange(len(ls) // 3):
   5.195 -                a = ls[x * 3]
   5.196 -                b = ls[x * 3 + 1]
   5.197 -                c = ls[x * 3 + 2]
   5.198 -                self.assertEquals(c, a * b)
   5.199 -
   5.200 -        def open(ls):
   5.201 -            ds = []
   5.202 -            for [(a, b, c)] in ls:
   5.203 -                d1 = runtime.open(a)
   5.204 -                d2 = runtime.open(b)
   5.205 -                d3 = runtime.open(c)
   5.206 -                ds.append(d1)
   5.207 -                ds.append(d2)
   5.208 -                ds.append(d3)
   5.209 -
   5.210 -            d = gatherResults(ds)
   5.211 -            d.addCallback(check)
   5.212 -            return d
   5.213 -
   5.214 -        a_shares = []
   5.215 -        b_shares = []
   5.216 -        c_shares = []
   5.217 -
   5.218 -        def cont(x):
   5.219 -            while a_shares and b_shares:
   5.220 -                a = a_shares.pop()
   5.221 -                b = b_shares.pop()
   5.222 -                c_shares.append(runtime.mul(a, b))
   5.223 -            done = gather_shares(c_shares)
   5.224 -            return done
   5.225 -
   5.226 -        count = 5
   5.227 -
   5.228 -        for i in range(count):
   5.229 -            inputter = (i % len(runtime.players)) + 1
   5.230 -            if inputter == runtime.id:
   5.231 -                a = rand.randint(0, self.Zp.modulus)
   5.232 -                b = rand.randint(0, self.Zp.modulus)
   5.233 -            else:
   5.234 -                a, b = None, None
   5.235 -            a_shares.append(runtime.input([inputter], self.Zp, a))
   5.236 -            b_shares.append(runtime.input([inputter], self.Zp, b))
   5.237 -        shares_ready = gather_shares(a_shares + b_shares)
   5.238 -
   5.239 -        runtime.schedule_callback(shares_ready, cont)
   5.240 -        return shares_ready
   5.241 -
   5.242  
   5.243  def skip_tests(module_name):
   5.244      OrlandiAdvancedCommandsTest.skip = "Skipped due to missing " + module_name + " module."