Skip to content

Idiomatic method for delivering an individualized private output to each party #1744

@csasmith

Description

@csasmith

Many of the functionalities I am implementing with the python interface require a different output to be delivered to each party. I am currently calling reveal_to() on each output to create a personal value, and then using the client interface to write back the value to each party. But the only way I have figured out how to make this work is to cast the underlying ._v value of the personal type to a cint, and then using cint.write_to_socket. My two concerns are:
(1) Is this even safe? By casting to a cint am I revealing the value for everyone to see?
(2) What is the idiomatic way of doing this?

For a minimal working example of what I have currently been doing:

import os, sys
# add MP-SPDZ/ to path so we can import from Compiler
sys.path.insert(0, os.path.dirname(sys.argv[0]) + '/../..') 
from Compiler.types import cint, sgf2n
from Compiler.library import listen_for_clients, accept_client_connection, if_
from Compiler.compilerLib import Compiler

usage = "usage: %prog [options] [args]"
compiler = Compiler(usage=usage)
compiler.parser.add_option("--num-parties", dest="n")

@compiler.register_function('foo')
def foo():
    n = int(compiler.options.n)
    # set up external client connections
    PORT_BASE = 15000
    listen_for_clients(PORT_BASE)
    socket = accept_client_connection(PORT_BASE)
    
    # each output is of type personal
    outputs = [sgf2n(i).reveal_to(i) for i in range(n)]
    
    # write personal outputs back to corresponding parties
    for party in range(n):
        @if_(party == socket)
        def _():
            cint.write_to_socket(socket, cint(outputs[party]._v))

if __name__ == "__main__":
    compiler.compile_func()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions