viff

changeset 1443:d4732f3eea69

BeDOZa: Added an initial stub for the BeDOZa runtime.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Fri, 02 Jul 2010 09:53:50 +0200
parents be4d2a98411d
children 0ca61834e8f8
files viff/bedoza.py
diffstat 1 files changed, 69 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/viff/bedoza.py	Fri Jul 02 09:53:50 2010 +0200
     1.3 @@ -0,0 +1,69 @@
     1.4 +# Copyright 2010 VIFF Development Team.
     1.5 +#
     1.6 +# This file is part of VIFF, the Virtual Ideal Functionality Framework.
     1.7 +#
     1.8 +# VIFF is free software: you can redistribute it and/or modify it
     1.9 +# under the terms of the GNU Lesser General Public License (LGPL) as
    1.10 +# published by the Free Software Foundation, either version 3 of the
    1.11 +# License, or (at your option) any later version.
    1.12 +#
    1.13 +# VIFF is distributed in the hope that it will be useful, but WITHOUT
    1.14 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    1.15 +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
    1.16 +# Public License for more details.
    1.17 +#
    1.18 +# You should have received a copy of the GNU Lesser General Public
    1.19 +# License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
    1.20 +
    1.21 +"""Full threshold actively secure runtime."""
    1.22 +
    1.23 +class BeDOZaShare(Share):
    1.24 +    """A share in the BeDOZa runtime.
    1.25 +
    1.26 +    A share in the BeDOZa runtime is a pair ``(x_i, Ks)`` of:
    1.27 +
    1.28 +    - A share of a number, ``x_i``
    1.29 +    - A n-tuple of keys, ``Ks``
    1.30 +
    1.31 +    The :class:`Runtime` operates on shares, represented by this class.
    1.32 +    Shares are asynchronous in the sense that they promise to attain a
    1.33 +    value at some point in the future.
    1.34 +
    1.35 +    Shares overload the arithmetic operations so that ``x = a + b``
    1.36 +    will create a new share *x*, which will eventually contain the
    1.37 +    sum of *a* and *b*. Each share is associated with a
    1.38 +    :class:`Runtime` and the arithmetic operations simply call back to
    1.39 +    that runtime.
    1.40 +    """
    1.41 +
    1.42 +    def __init__(self, runtime, field, value=None, rho=None, commitment=None):
    1.43 +        self.share = value
    1.44 +        self.rho = rho
    1.45 +        self.commitment = commitment
    1.46 +        Share.__init__(self, runtime, field, (value, rho, commitment))
    1.47 +
    1.48 +
    1.49 +class BeDOZaRuntime(Runtime, HashBroadcastMixin):
    1.50 +    """The BeDOZa runtime.
    1.51 +
    1.52 +    The runtime is used for sharing values (:meth:`secret_share` or
    1.53 +    :meth:`shift`) into :class:`BeDOZaShare` object and opening such
    1.54 +    shares (:meth:`open`) again. Calculations on shares is normally
    1.55 +    done through overloaded arithmetic operations, but it is also
    1.56 +    possible to call :meth:`add`, :meth:`mul`, etc. directly if one
    1.57 +    prefers.
    1.58 +
    1.59 +    Each player in the protocol uses a :class:`~viff.runtime.Runtime`
    1.60 +    object. To create an instance and connect it correctly with the
    1.61 +    other players, please use the :func:`~viff.runtime.create_runtime`
    1.62 +    function instead of instantiating a Runtime directly. The
    1.63 +    :func:`~viff.runtime.create_runtime` function will take care of
    1.64 +    setting up network connections and return a :class:`Deferred`
    1.65 +    which triggers with the :class:`~viff.runtime.Runtime` object when
    1.66 +    it is ready.
    1.67 +    """
    1.68 +
    1.69 +    def __init__(self, player, threshold=None, options=None):
    1.70 +        """Initialize runtime."""
    1.71 +        Runtime.__init__(self, player, threshold, options)
    1.72 +        self.threshold = self.num_players - 1