SMC: Secure Multiparty Computation Language

by Silaghi, Marius-Călin

SMC is a declarative programming language for Secure Multiparty Computations. First let us give some definitions.

Definitions
About
Tutorial

Definition
Cryptography is the science of hiding information.

A Cryptographic Protocol is a protocol that has as one of its goals the hiding of information.

A Secure Multiparty Computation is a cryptographic protocol among a set of participants, where some of the inputs needed for the interaction have to be hidden from participants other than the initial owner.

A Declarative Programming Language (as compared with an imperative programming language) is a paradigm within which the programmer describes his problem without needing to know any detail about the algorithms used to solve it. Once the problem is described, an interpreter or a compiler chooses an algorithm (hopefully the best one), and solves it.

Older examples of declarative programming language are PROLOG and Constraint Programming:
A declarative program looks more like a configuration file or a database, than like an imperative program.

About
Secure Multiparty Computations are non-trivial to design, particularly because not any composition of such protocols remains secure. Given the difficulty of choosing the right algorithms, I considered it important to propose a declarative language based on constraint programming and able to solve most secure multiparty computation problems. The contribution of this language and of the provided interpreter should be considered in the light of the fact that no other support for secure computations was present at the moment when this was written (no imperative languages and even no software libraries).
Note: The first  version of our interpretor was made available on-line (and presented at AAMAS in July 2004). A language and a compiler for 2-party secure function evaluation (called FairPlay) was made available and was presented at USENIX (in August 2004), nevertheless FairPlay does not address multiparty computation (i.e., more than 2 participants).
A set of applets that use the engine of this interpreter was written with help from students Vaihav Rajeshirke, Amit Abhyankar, and Julia Hamilton.

Tutorial

The arithmetic circuit syntax
The public program
The secret data
The current constraint solver

To solve a problem, first a description of its public components has to be written in the SMC language, and will be called: the public program. If the description contains declarative sections (based on constraints or first order logic), then the interpreter usees its current constraint solver. The programmer is allowed in SMC to change the current constraint solveror even to write new ones, also by using the SMC language.

The public program and the current constraint solver are distributed among participants. Each participant runs the interpreter with these files on his own machine (considered secure), connected to the Internet. Each participant will also input his own secrets in a separate file called the secret data. The applet interfaces offer graphical (limited) ways to input the secret data. The interpreter assembles a set of algorithms, based on these files. Each participant has a name (n.a., number in the current version). A simple example of how the participant 5 in this computation would launch the interpreter is:

java mcs.apps.SMC -A Version4.smc -P public.smc -S secret.smc -K secret-key-file -i 5

After this is called, the interpreter starts to contact the other participants, (verifies their identity and exchange session keys -- part not yet fully developed in version 1.3). Then each interpreter starts to solve the problem and at the end the solution is printed. The interpreter interprets the public program in file "public.smc" and the secret data in file "secret.smc", by using the constraint solver Version4, for the user with ID 5.

The arithmetic circuit syntax
The programs can contain descriptions of arithmetic circuits. These are described using a functional programming style. Later we may write more friendly preprocessors :):

The public program
The public program specifies the knowledge that every participant should know:
Example:
################################
# file "public.smc"
#
# Year 2004
# a meeting-scheduling application
# 3 participants choose from 2 places. If both places could work, the solution is picked randomly
# a file of type:
################################
GENERIC_DISWCSP_V1

# use modulus 13 for arithmetic circuits (the minimum one is chosen automatically)
MODULUS      13

# THRESHOLD-SCHEME n / 2 # default is n/2, in version 1.3 the user is not yet allowed to change it

# number of participants
PARTICIPANTS 3

# n-g for Paillier keys. Real users will want bigger safe values and surely different for participants :)
# you can generate these numbers with the Paillier generator applet at http://cs.fit.edu/~msilaghi/
PUBLIC-KEYS
# n-g for 1st participant
2257    158
# n-g for 2nd participant
2257    158
# n-g for 2nd participant
2257    158

# the IP addresses for participants
ADDRESSES
# IP PORT for 1st participant
127.0.0.1     2001
# IP PORT for 2nd participant
127.0.0.1     2002
# IP PORT for 3rd participant
127.0.0.1     2003

INPUTS
# T-table, V-vector, I-integer, B-boolean 0/1
1                         # inputs for participant 1
ic1    V 2             # a vector with two elements
label c11 c12        # the labels for the elements are shown here
Boolean                 # the type of the inputs is Boolean
1                     # 1 input for the 2nd participant
ic2    V 2         # a vector with two elements
label c21 c22     # the labels for the elements are shown here
Boolean                 # the type of the inputs is Boolean
1                     # 1 input for the 3rd participant
ic3    V 2
label c31 c32
Boolean

INTERMEDIARY-INPUTS 2
r1=*(*(ic1(0),ic2(0)),ic3(0))
r2=*(*(ic1(1),ic2(1)),ic3(1))
# r(x)=ARRAY(r,x,r1,r2) # these can be set in an array
# the elements become r(0) for r1 and r(1) for r2

# CONSTRAINT-PROBLEM
VARIABLES    1 # a single variable
place 2 # it is called "place" and has 2 values

INDUCED-CONSTRAINTS 1
C # name for this constraint
1 # nb of variables involved in this constraint
place
{ r1 r2 } # the constraint is here computed separately for each place

OUTPUTS
1 # 1 input for participant 1
place    place # output the value of variable place with label "place"
1 # 1 input for participant 2
place    place
1 # 1 input for participant 3
place    place
EOF
#

The secret data
Specifies the secret input of the user is specified.

Example:
############################
# file "secret.smc"
#
# Year 2004
# A file of type
############################
GENERIC_DISWCSP_V2
1 # nb of inputs
ic3 # name of the input -- was declared vector of size 2 in the file "public.smc"
1 1 # elements of the vector


The constraint solver version
Specifies the secure distributed constraint solving technique to be used. If constraints are used, the following variables become usable in programs:
The solver is described by a set of functions whose entry point is the function "main". The chosen assignment to variables are to be saved in the array "_x".

EXAMPLE:
##########################
# file "Version4.smc"
# SMC solver for distributed constraint satisfaction program
# implements the algorithm MPC-DisCSP4
# but uses Generate and Test instead of a powerful backtracker
#
# Year 2004
##########################
p(t)=PROD(i,0,-(C,1),CONSTRAINT(i,t))
makeS=FOR(t,0,-(TuplesNb,1),
    _S, p(t),
    0)
selectS(length)=FOR(j,0,-(length,1),
    _k,IF(j,*(_k(-(j,1)),-(1,_S(-(j,1)))),1),
    _S2,*(_S(j),_k(j)),
    0)
main=SEQUENCE(
    makeS,
    SETLOCAL(length,CONDENSE(_S,TuplesNb,_permutation)),
    SHUFFLE(_S,length),
    selectS(length),
    UNSHUFFLE(_S2,length),
    UNCONDENSE(_S2,length,_permutation,_S,TuplesNb),
    FOR(i,0,-(M,1),
        _x,f(i),
        0))
f(i)=SUM(t,0,-(TuplesNb,1),*(PROJ(t,i),_S(t)))
#

Create Nov. 25, 2004 by Silaghi, Marius-Călin.