Janus Dam Nielsen <janus.niel...@alexandra.dk> writes:

> # HG changeset patch
> # User Janus Dam Nielsen <janus.niel...@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/.

Attachment: pgp9FvHRwXFFW.pgp
Description: PGP signature

_______________________________________________
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk

Reply via email to