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 wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/viff/bedoza.py	Fri Jul 02 09:53:50 2010 +0200
@@ -0,0 +1,69 @@
+# Copyright 2010 VIFF Development Team.
+#
+# This file is part of VIFF, the Virtual Ideal Functionality Framework.
+#
+# VIFF is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License (LGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VIFF is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
+
+"""Full threshold actively secure runtime."""
+
+class BeDOZaShare(Share):
+    """A share in the BeDOZa runtime.
+
+    A share in the BeDOZa runtime is a pair ``(x_i, Ks)`` of:
+
+    - A share of a number, ``x_i``
+    - A n-tuple of keys, ``Ks``
+
+    The :class:`Runtime` operates on shares, represented by this class.
+    Shares are asynchronous in the sense that they promise to attain a
+    value at some point in the future.
+
+    Shares overload the arithmetic operations so that ``x = a + b``
+    will create a new share *x*, which will eventually contain the
+    sum of *a* and *b*. Each share is associated with a
+    :class:`Runtime` and the arithmetic operations simply call back to
+    that runtime.
+    """
+
+    def __init__(self, runtime, field, value=None, rho=None, commitment=None):
+        self.share = value
+        self.rho = rho
+        self.commitment = commitment
+        Share.__init__(self, runtime, field, (value, rho, commitment))
+
+
+class BeDOZaRuntime(Runtime, HashBroadcastMixin):
+    """The BeDOZa runtime.
+
+    The runtime is used for sharing values (:meth:`secret_share` or
+    :meth:`shift`) into :class:`BeDOZaShare` object and opening such
+    shares (:meth:`open`) again. Calculations on shares is normally
+    done through overloaded arithmetic operations, but it is also
+    possible to call :meth:`add`, :meth:`mul`, etc. directly if one
+    prefers.
+
+    Each player in the protocol uses a :class:`~viff.runtime.Runtime`
+    object. To create an instance and connect it correctly with the
+    other players, please use the :func:`~viff.runtime.create_runtime`
+    function instead of instantiating a Runtime directly. The
+    :func:`~viff.runtime.create_runtime` function will take care of
+    setting up network connections and return a :class:`Deferred`
+    which triggers with the :class:`~viff.runtime.Runtime` object when
+    it is ready.
+    """
+
+    def __init__(self, player, threshold=None, options=None):
+        """Initialize runtime."""
+        Runtime.__init__(self, player, threshold, options)
+        self.threshold = self.num_players - 1