Package viff :: Module orlandi :: Class OrlandiRuntime
[hide private]
[frames] | no frames]

Class OrlandiRuntime

source code


The Orlandi runtime.

The runtime is used for sharing values (:meth:`secret_share` or :meth:`shift`) into :class:`OrlandiShare` 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:`Runtime` object. To create an instance and connect it correctly with the other players, please use the :func:`create_runtime` function instead of instantiating a Runtime directly. The :func:`create_runtime` function will take care of setting up network connections and return a :class:`Deferred` which triggers with the :class:`Runtime` object when it is ready.

Instance Methods [hide private]
 
__init__(self, player, threshold=None, options=None)
Initialize runtime.
source code
 
compute_delta(self, d) source code
 
output(self, share, receivers=None, threshold=None)
Open share to receivers (defaults to all players).
source code
 
_send_orlandi_share(self, other_id, pc, xi, rhoi, Cx)
Send the share *xi*, *rhoi*, and the commitment *Cx* to party *other_id*.
source code
 
_expect_orlandi_share(self, peer_id, field)
Waits for a number ``x``, ``rho``, and the commitment for ``x``.
source code
 
_expect_orlandi_share_xi_rhoi(self, peer_id, field) source code
 
secret_share(self, inputters, field, number=None, threshold=None)
Share the value *number* among all the parties using additive sharing.
source code
 
open(self, share, receivers=None, threshold=None)
Share reconstruction.
source code
 
random_share(self, field)
Generate a random share in the field, field.
source code
 
add(self, share_a, share_b)
Addition of shares.
source code
 
sub(self, share_a, share_b)
Subtraction of shares.
source code
 
input(self, inputters, field, number=None, threshold=None)
Input *number* to the computation.
source code
 
shift(self, inputters, field, number=None)
Shift of a share.
source code
 
mul(self, share_x, share_y)
Multiplication of shares.
source code
 
_additive_constant(self, zero, field_element)
Greate an additive constant.
source code
 
_plus(self, x, y)
Addition of share-tuples *x* and *y*.
source code
 
_minus(self, x, y)
Subtraction of share-tuples *x* and *y*.
source code
 
_cmul(self, share_x, share_y, field)
Multiplication of a share with a constant.
source code
 
_const_mul(self, c, x)
Multiplication of a share-tuple with a constant c.
source code
 
_get_share(self, field, value) source code
 
_get_triple(self, field) source code
 
_basic_multiplication(self, share_x, share_y, triple_a, triple_b, triple_c)
Multiplication of shares give a triple.
source code
 
sum_poly(self, j, ls) source code
 
leak_tolerant_mul(self, share_x, share_y, M)
Leak tolerant multiplication of shares.
source code
 
triple_gen(self, field)
Generate a triple ``a, b, c`` s.t.
source code
 
triple_test(self, field)
Generate a triple ``(a, b, c)`` where ``c = a * b``.
source code
 
random_triple(self, field, quantity=1)
Generate a list of triples ``(a, b, c)`` where ``c = a * b``.
source code
 
error_handler(self, ex) source code
 
set_args(self, args)
args is a dictionary.
source code

Inherited from runtime.Runtime: abort, activate_reactor, add_player, fork_pc, handle_deferred_data, increment_pc, preprocess, print_transferred_data, process_deferred_queue, process_queue, schedule_callback, schedule_complex_callback, shutdown, synchronize, unfork_pc, wait_for

Inherited from hash_broadcast.HashBroadcastMixin: broadcast, list_str

Static Methods [hide private]

Inherited from runtime.Runtime: add_options

Instance Variables [hide private]

Inherited from runtime.Runtime: activation_counter, deferred_queue, depth_counter, depth_limit, id, num_players, players, program_counter, protocols, threshold, using_viff_reactor

Inherited from runtime.Runtime (private): _needed_data, _pool

Method Details [hide private]

__init__(self, player, threshold=None, options=None)
(Constructor)

source code 

Initialize runtime.

Overrides: runtime.Runtime.__init__

output(self, share, receivers=None, threshold=None)

source code 

Open share to receivers (defaults to all players).

Returns a Share to players with IDs in receivers and None to the remaining players.

Overrides: runtime.Runtime.output
(inherited documentation)

secret_share(self, inputters, field, number=None, threshold=None)

source code 

Share the value *number* among all the parties using additive sharing.

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_x1, ..., rho_xn in (Z_p)^2``, define ``rho_x = SUM_i=1^n rho_x,i`` and ``C_x = Com_ck(x, p_x)``.

Send ``[x]_i = (x_i, rho_xi, C_x)`` to party ``P_i``.

open(self, share, receivers=None, threshold=None)

source code 

Share reconstruction.

Every partyi broadcasts a share pair ``(x_i', rho_x,i')``.

The parties compute the sums ``x'``, ``rho_x'`` and check ``Com_ck(x',rho_x' = C_x``.

If yes, return ``x = x'``, else else return :const:`None`.

random_share(self, field)

source code 

Generate a random share in the field, field.

To generate a share of a random element ``r in Z_p``, party ``P_i`` chooses at random ``r_i, rho_ri in Z_p X (Z_p)^2`` and broadcast ``C_r^i = Com_ck(r_i, rho_ri)``.

Every party computes ``C_r = PRODUCT_i=1^n C_r^i = Com_ck(r, rho_r)``, where ``r_i = SUM_i=1^n r_i and rho_r = SUM_i=1^n rho_ri``.

Party ``P_i sets [r]_i = (r_i, rho_ri, C_r)``.

add(self, share_a, share_b)

source code 

Addition of shares.

Communication cost: none.

Each party ``P_i`` computes:

 [z]_i = [x]_i + [y]_i
       = (x_i + y_i mod p, rho_xi + rho_yi mod p, C_x * C_y)
Overrides: runtime.Runtime.add

sub(self, share_a, share_b)

source code 

Subtraction of shares.

Communication cost: none.

Each party ``P_i`` computes:

 [z]_i = [x]_i - [y]_i
       = (x_i - y_i mod p, rho_x,i - rho_y,i mod p, C_x * C_y)

input(self, inputters, field, number=None, threshold=None)

source code 

Input *number* to the computation.

The input is shared using the :meth:`shift` method.

Overrides: runtime.Runtime.input

shift(self, inputters, field, number=None)

source code 
Shift of a share.

Useful for input.

Communication cost: ???.

Assume the parties are given a random share ``[r]`` by a
trusted dealer. Then we denote the following protocol but
``[x] = Shift(P_i, x, [r])``.

1. ``r = OpenTo(P_i, [r]``

2. ``P_i broadcasts Delta = r - x``

3. ``[x] = [r] - Delta``

mul(self, share_x, share_y)

source code 

Multiplication of shares.

Communication cost: ???.

Overrides: runtime.Runtime.mul

_additive_constant(self, zero, field_element)

source code 

Greate an additive constant.

Any additive constant can be interpreted as: ``[c]_1 = (c, 0, Com_ck(c,0))`` and ``[c]_i = (0, 0, Com_ck(c,0)) for i != 1``.

_plus(self, x, y)

source code 
Addition of share-tuples *x* and *y*.

Each party ``P_i`` computes:
``[x]_i = (x_i, rho_xi, C_x)``
``[y]_i = (y_i, rho_yi, C_y)``
``[z]_i = [x]_i + [y]_i
        = (x_i + y_i mod p, rho_xi + rho_yi mod p, C_x * C_y)``.

_minus(self, x, y)

source code 
Subtraction of share-tuples *x* and *y*.

Each party ``P_i`` computes:
``[x]_i = (x_i, rho_x,i, C_x)``
``[y]_i = (y_i, rho_y,i, C_y)``
``[z]_i = [x]_i - [y]_i
        = (x_i - y_i mod p, rho_x,i - rho_y,i mod p, C_x / C_y)``.

_cmul(self, share_x, share_y, field)

source code 

Multiplication of a share with a constant.

Either share_x or share_y must be an OrlandiShare but not both. Returns None if both share_x and share_y are OrlandiShares.

_get_triple(self, field)

source code 
Decorators:
  • @preprocess("random_triple")

_basic_multiplication(self, share_x, share_y, triple_a, triple_b, triple_c)

source code 

Multiplication of shares give a triple.

Communication cost: ???.

``d = Open([x] - [a])`` ``e = Open([y] - [b])`` ``[z] = e[x] + d[y] - [de] + [c]``

leak_tolerant_mul(self, share_x, share_y, M)

source code 
Leak tolerant multiplication of shares.

Communication cost: ???.

Assuming a set of multiplicative triples:
``M = ([a_i], [b_i], [c_i]) for 1 <= i <= 2d + 1``.

1. ``for i = 1, ..., d do [f_i] = rand(), [g_i] = rand()``

2. Compute::

     for j = 1, ..., 2d+1 do
     [F_j] = [x] + SUM_i=1^d [f_i]*j^i
     and
     [G_j] = [y] + SUM_i=1^d [g_i]*j^i

3. ``for j = 1, ..., 2d+1 do [H_j] = Mul([F_j], [G_j], [a_j],
   [b_j], [c_j])``

4. compute ``[H_0] = SUM_j=1^2d+1 delta_j[H_j]`` where
   ``delta_j = PRODUCT_k=1, k!=j^2d+1 k/(k-j)``

5. output ``[z] = [H_0]``

triple_gen(self, field)

source code 
Generate a triple ``a, b, c`` s.t. ``c = a * b``.

1. Every party ``P_i`` chooses random values ``a_i, r_i in Z_p
   X (Z_p)^2``, compute ``alpha_i = Enc_eki(a_i)`` and ``Ai =
   Com_ck(a_i, r_i)``, and broadcast them.

2. Every party ``P_j`` does:

   a. choose random ``b_j, s_j in Z_p X (Z_p)^2``.

   b. compute ``B_j = ``Com_ck(b_j, s_j)`` and broadcast it.

   c. ``P_j`` do towards every other party:

        i. choose random ``d_ij in Z_p^3``

        ii. compute and send
            ``gamma_ij = alpha_i^b_j Enc_ek_i(1;1)^d_ij`` to ``P_i``.


3. Every party ``P_i`` does:

   a. compute ``c_i = SUM_j Dec_sk_i(gamma_ij) - SUM_j d_ij mod p``

   b. pick random ``t_i in (Z_p)^2``, compute and
      broadcast ``C_i = Com_ck(c_i, t_i)``

4. Everyone computes:
   ``(A, B, C) = (PRODUCT_i A_i, PRODUCT_i B_i, PRODUCT_i C_i)``

5. Every party ``P_i`` outputs shares ``[a_i] = (a_i, r_i, A)``,
   ``[b_i] = (b_i, s_i, B)``, and ``[c_i] = (c_i, t_i, C)``.

triple_test(self, field)

source code 

Generate a triple ``(a, b, c)`` where ``c = a * b``.

The triple ``(a, b, c)`` is checked against the triple ``(x, y, z)`` and a random value ``r``.

random_triple(self, field, quantity=1)

source code 

Generate a list of triples ``(a, b, c)`` where ``c = a * b``.

The triple ``(a, b, c)`` is secure in the Fcrs-hybrid model.

error_handler(self, ex)

source code 
Overrides: hash_broadcast.HashBroadcastMixin.error_handler