[viff-devel] [PATCH 02 of 12] Implemented secret sharing command

Martin Geisler mg at lazybytes.net
Fri Jun 19 08:44:25 PDT 2009


Janus Dam Nielsen <janus.nielsen at alexandra.dk> writes:

> # HG changeset patch
> # User Janus Dam Nielsen <janus.nielsen at alexandra.dk>
> # Date 1245394849 -7200
> # Node ID f780a9ea514acb7de9d70022a8845938599696c8
> # Parent  15c0283f7cb6dad3d7a41e9095bb4fd18a30d909
> Implemented secret sharing command.
>
> diff --git a/viff/orlandi.py b/viff/orlandi.py
> --- a/viff/orlandi.py
> +++ b/viff/orlandi.py
> @@ -67,3 +67,112 @@
>          """Initialize runtime."""
>          Runtime.__init__(self, player, threshold, options)
>          self.threshold = self.num_players - 1
> +
> +    def _Com(self, x, rho):

This name is bad Python Python style, could we please call it _commit
instead? I'm sure it's called Com in the paper, but still.

> +        return self.open(share, receivers, threshold)
> +
> +    def _send_orlandi_share(self, other_id, pc, xi, rhoi, Cx):
> +        """Send the share xim, rhoi, and the commitment Cx to party other_id."""

The arguments should be as such (and xim looks like a typo):

 +        """Send the share *xi*, *rhoi*, and the commitment *Cx* to party *other_id*."""

> +    def _expect_orlandi_share(self, peer_id, field):
> +        """Waits for a number x, rho, and the commitment for x. """
> +        xi = self._expect_share(peer_id, field)
> +        rhoi1 = self._expect_share(peer_id, field)
> +        rhoi2 = self._expect_share(peer_id, field)
> +        Cx = self._expect_share(peer_id, field)
> +        sls = ShareList([xi, rhoi1, rhoi2, Cx])
> +        def combine(ls):
> +            if len(ls) is not 4:
> +                raise OrlandiException("Cannot share number, trying to create share," + \
> +                                           " but there are too few or too many components.")

Please don't use backslashes to continue statements when they are inside
parenthesis. Also, adjacent strings are merged just like in C, so it
should be:

 +                raise OrlandiException("Cannot share number, trying to create share, "
 +                                       "but there are too few or too many components.")

Also, there will always be 4 elements in the list.

> +            s1, xi = ls[0]
> +            s2, rhoi1 = ls[1]
> +            s3, rhoi2 = ls[2]
> +            s4, Cx = ls[3]
> +            if not (s1 and s2 and s3 and s4):
> +                raise OrlandiException("Cannot share number, trying to create share," + \
> +                                           " but a component did arrive properly.")

Same problem as above with the backslashes. Also, I think we talked
about this, but it looks like gather_shares would be better than
ShareList since you must have all four shares anyway.

> +    @increment_pc
> +    def secret_share(self, inputters, field, number=None, threshold=None):
> +        """Share the value, number, among all the parties using additive shareing.
> +
> +        To share an element x in Z_{p}, choose random x_{1}, ..., x_{n-1} in Z_{p}, 
> +        define x_{n} = x - SUM_{i=1}^{n-1} x_{i} mod p.
> +        Choose random values rho_{x,1}, ..., rho_{x,n} in (Z_{p})^2, define 
> +        rho_x = SUM_{i=1}^{n} rho_{x,i} and C_{x} = Com_{ck}(x, p_{x}).

Docstrings should use a blank like to separate paragraphs -- or be
wordwrapped correctly. Ad-hoc newlines like these wont be preserved.

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.viff.dk/pipermail/viff-devel-viff.dk/attachments/20090619/e4c9f15e/attachment.pgp>


More information about the viff-devel mailing list