SFDL Specification - Version 2.0

Similar documents
Systems Novelties Seminar (2/24/10)

Lexical Considerations

1 Lexical Considerations

The SPL Programming Language Reference Manual

(Not Quite) Minijava

The PCAT Programming Language Reference Manual

VENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

Lexical Considerations

Values and Variables 1 / 30

SMURF Language Reference Manual Serial MUsic Represented as Functions

Type Checking. Chapter 6, Section 6.3, 6.5

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof.

BoredGames Language Reference Manual A Language for Board Games. Brandon Kessler (bpk2107) and Kristen Wise (kew2132)

CA4003 Compiler Construction Assignment Language Definition

Angela Z: A Language that facilitate the Matrix wise operations Language Reference Manual

Typescript on LLVM Language Reference Manual

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

MR Language Reference Manual. Siyang Dai (sd2694) Jinxiong Tan (jt2649) Zhi Zhang (zz2219) Zeyang Yu (zy2156) Shuai Yuan (sy2420)

A simple syntax-directed

COMP 202 Java in one week

COS 126 General Computer Science Spring Written Exam 1

M/s. Managing distributed workloads. Language Reference Manual. Miranda Li (mjl2206) Benjamin Hanser (bwh2124) Mengdi Lin (ml3567)

CHAD Language Reference Manual

SSOL Language Reference Manual

Language Reference Manual simplicity

ARG! Language Reference Manual

The Warhol Language Reference Manual

Java Primer 1: Types, Classes and Operators

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

The pixelman Language Reference Manual. Anthony Chan, Teresa Choe, Gabriel Kramer-Garcia, Brian Tsau

IC Language Specification

Professor Peter Cheung EEE, Imperial College

VLC : Language Reference Manual

IPCoreL. Phillip Duane Douglas, Jr. 11/3/2010

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and

The Arithmetic Operators

Fundamentals of Programming

Simple Java Reference

Computers Programming Course 6. Iulian Năstac

Object-Oriented Programming

Computational Expression

Sprite an animation manipulation language Language Reference Manual

ASML Language Reference Manual

Fundamental of Programming (C)

CS4120/4121/5120/5121 Spring 2016 Xi Language Specification Cornell University Version of May 11, 2016

Chapter 3: Operators, Expressions and Type Conversion

d-file Language Reference Manual

GraphQuil Language Reference Manual COMS W4115

egrapher Language Reference Manual

Cellular Automata Language (CAL) Language Reference Manual

CS /534 Compiler Construction University of Massachusetts Lowell. NOTHING: A Language for Practice Implementation

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

GBL Language Reference Manual

Programming for Engineers Introduction to C

Static Semantics. Lecture 15. (Notes by P. N. Hilfinger and R. Bodik) 2/29/08 Prof. Hilfinger, CS164 Lecture 15 1

CS313D: ADVANCED PROGRAMMING LANGUAGE

22c:111 Programming Language Concepts. Fall Types I

EXPRESSIONS AND ASSIGNMENT CITS1001

Java Bytecode (binary file)

9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C

COMPUTER APPLICATION

Review of the C Programming Language

CS242 COMPUTER PROGRAMMING

BASIC ELEMENTS OF A COMPUTER PROGRAM

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

Syntax and Variables

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

The C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science)

Mirage. Language Reference Manual. Image drawn using Mirage 1.1. Columbia University COMS W4115 Programming Languages and Translators Fall 2006

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

SMPL - A Simplified Modeling Language for Mathematical Programming

SFPL Reference Manual

Array. Prepared By - Rifat Shahriyar

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Review Chapter 6 in Bravaco. Short Answers 1. This type of method does not return a value. a. null b. void c. empty d. anonymous

2 nd Week Lecture Notes

LCSL Reference Manual

A Fast Review of C Essentials Part I

GAWK Language Reference Manual

YOLOP Language Reference Manual

GBIL: Generic Binary Instrumentation Language. Language Reference Manual. By: Andrew Calvano. COMS W4115 Fall 2015 CVN

LOON. Language Reference Manual THE LANGUAGE OF OBJECT NOTATION. Kyle Hughes, Jack Ricci, Chelci Houston-Borroughs, Niles Christensen, Habin Lee

Today's Topics. CISC 458 Winter J.R. Cordy

Creating a C++ Program

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

Review of the C Programming Language for Principles of Operating Systems

Introduction to C# Applications

L-System Fractal Generator: Language Reference Manual

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

CSCE 110 PROGRAMMING FUNDAMENTALS

Final CSE 131B Spring 2004

Chapter 2 Elementary Programming

UNIT- 3 Introduction to C++

Types, Operators and Expressions

Transcription:

SFDL Specification - Version 2.0 September 4, 2008 Programs in Secure Function Definition Language (SFDL) instruct a virtual trusted party what to do. The SFDL compiler compiles the program into a low level language that can be read by secure function evaluation peer to peer software. When the multi-party, secure function evaluation, peer to peer software run the compiled form of the program, they implement correctly and securely the fictional trusted party. This document specifies version 2.0 of the SFDL language which is intended for multiparty computation. Version 1.0 was intended for two-party computation and was described in Fairplay: a secure two-party computation system, by Malkhi, Nisan, Pinkas, and Sella, Usenix security symposium 2004. The SFDL2.0 compiler is available on the FairplayMP project web site at: http://www.cs.huji.ac.il/project/fairplay. 1 Example / P e r f o r m s a 2 nd p r i c e a u c t i o n b e t w e e n 4 b i d d e r s. At t h e e n d o n l y t h e w i n n i n g b i d d e r a n d t h e s e l l e r k n o w t h e i d e n t i t y o f t h e w i n n e r E v e r y o n e k n o w s t h e 2 nd h i g h e s t p r i c e, N o t h i n g e l s e i s k n o w n t o a n y o n e. / program S e c o n d P r i c e A u c t i o n { const n B i d d e r s = 4 ; type Bid = Int <4>; / / e n o u g h b i t s t o r e p r e s e n t a s m a l l b i d. type WinningBidder = Int <3>; / / e n o u g h b i t s t o r e p r e s e n t a w i n n e r ( n B i t t e r s b i t s ). type S e l l e r O u t p u t = s t r u c t { WinningBidder winner, Bid winningprice ; type S e l l e r = s t r u c t { S e l l e r O u t p u t output ; / / S e l l e r h a s no i n p u t type BidderOutput = s t r u c t {Boolean win, Bid winningprice ; type B i d d e r = struct { Bid input, BidderOutput output ; function void main ( S e l l e r s e l l e r, B i d d e r [ n B i d d e r s ] b i d d e r ){ var Bid high ; var Bid second ; var WinningBidder winner ; w i n n e r = 0 ; h i g h = b i d d e r [ 0 ]. input ; s e c o n d = 0 ; / / M a k i n g t h e a u c t i o n. f o r ( i =1 to nbidders 1){ i f ( b i d d e r [ i ]. input > h i g h ){ w i n n e r = i ; second = high ; h i g h = b i d d e r [ i ]. input ; e l s e { i f ( b i d d e r [ i ]. input > s e c o n d ) s e c o n d = b i d d e r [ i ]. input ; 1

/ / S e t t i n g t h e r e s u l t. s e l l e r. output. w i n n e r = w i n n e r ; s e l l e r. output. w i n n i n g P r i c e = s e c o n d ; f o r ( i =0 to nbidders 1){ b i d d e r [ i ]. output. win = ( w i n n e r == i ) ; b i d d e r [ i ]. output. w i n n i n g P r i c e = s e c o n d ; 2 General In this document all the keywords of the languge are in Boldface notation. 2.1 Lexical Issues Identifiers have unlimited length, can contain letters, digits, and the underscore characters. They must start with a letter or an underscore and are case sensitive. Identifiers are separated by any amount of whitespace: space, newline, and comments. The comment formats recognized are: / / c o m m e n t s t o e n d o f l i n e / c o m m e n t t o c l o s i n g / 2.2 Program Structure program name { header d e c l a r a t i o n s function d e f i n i t i o n s In the header, the programmer defines the constants, data types, and global variables that he will use. Beyond the usual usage of types, types defining the input and output of each player must be defined. In the function definitions, the programmer defines a sequence of functions. The main functionality of the program is the evaluation of the last function defined. This function must be called main and receives as its parameters the list of players. 3 Program Header 3.1 Constants Constant definitions may appear in the header. The syntax is simple, e.g., const numberofbits = 1 6 ; The right hand side may be any expression involving only compile-time constants. 2

3.2 Types Data types can be defined using the type command. Here are the supported data types: 1. Boolean: false or true. 2. Integer types of any fixed number of bits. Every integer declaration needs a <L>, where L is the length of the integer in bits. Signed 2s complement integers are always used, thus for example 5-bit integers, defined as Int<5>, can hold the range (-16.. +15). 3. Structures. 4. Arrays: single dimensional, indices always start at 0. Thus an array defined as Boolean[4] has 4 Boolean entries, indexed 0.. 3. New data types can be defined using the type statement, and variables can be defined to be of any type. Here are examples of type declarations: type S h o r t = Int <16>; type Byte = Boolean [ 8 ] ; type C o l o r = Int <8. b i t S i z e >; / / e n o u g h b i t s t o h o l d 8 c o l o r s i n 2 s c o m p l e m e n t ( 5 b i t s ). type P i x e l = s t r u c t { Color color, Int <10>[2] c o o r d i n a t e s ; 3.3 Player Types The type declarations must define for each player involved in the computation exactly its input and output. This is done by defining for each player a type that holds its input and output fields. The type is defined as a struct that contains at least one of the fields input and output, of the appropriate type for the player. E.g. if a voter in some protocol needs to input his choice of candidate (in the range 0..5) and gets as output the number of votes of each candidate (which, for every candidate, fit in 10 bits, say), then one would define: const n = 6 ; type Voter = struct { Int<n. bitsize> input ; Int <10>[n ] output ; Such declared types can then used in the header of the main function of the program: function void main ( Voter v o t e r s [ 8 0 ] ) {... 3.4 Global Variables Static variables with global scope can be declared after the type declarations. The format is standard: var type var name ; For example: var Boolean win ; var Int <10> xcoord ; var Int <10> ycoord ; var C o l o r [ 8 ] p a l e t t e ; All variables are initialized to 0. Declarations of integer bit-size and array size must specify a compile-time constant as the size. 3

4 Function Declarations After the global variable declarations comes a sequence of function declarations. Each function has the following structure: function return type function name ( type arg name, type arg name,... ){ type d e c l a r a t i o n s l o c a l v a r i a b l e d e c l a r a t i o n s function body In function headers, the types of parameters may be generic allowing integer types or array types of any length. E.g.: function Boolean m a j o r i t y ( Boolean [ ] v o t e s ) { Int<votes. length. b i t S i z e > yes ; Int<v o t e s. l e n g t h. b i t S i z e > no ; f o r ( j = 0 to v o t e s. length 1) { i f ( v o t e s [ j ] ) y e s = y e s + 1 ; e l s e no = no + 1 ; m a j o r i t y = ( yes>no ) ; The return type may be void denoting that no value is returned. The return type may also be specified as generic - see below for exact syntax and semantics. 4.1 Header The function header defines the number of parameters of the function, their types, and the return data type. After the header come type declaration and local variable declarations which are similar to their definition above (for the general program). All parameters are passed by value, including arrays. 4.2 Commands 1. Assignment: lvalue = expression ; The lvalue can be a variable, a field of a struct (using x.y notation) or an array entry (using x[exp] notation, where exp is an arbitrary expression). The expression on the RHS must be of the same type as the lvalue (Boolean can be treated also as 1 bit integer). In case of a struct or an array a shallow copy will be made. If the length in bits of the RHS is longer than the lvalue only the first lvalue length bits (starting from the lsb) will be copied. If the length in bits of the RHS is shorter than the lvalue zero padding and sign-extension will be used for widening. 2. If (if/else): i f ( Boolean e x p r e s s i o n ) statement or 4

i f ( Boolean e x p r e s s i o n ) statement e l s e s t a t e m e n t 3. For: f o r ( index=l o w v a l e x p r e s s i o n to h i g h v a l e x p r e s s i o n ) statement The index of the for loop is a variable which must not have been previously defined. The low and high ranges of the for loop must be compiletime constants. 4. block: { s t a t e m e n t ;... ; s t a t e m e n t 5. Calling a previously defined void function. No recursion is allowed. 6. There is no return command. Function values are returned Pascal-style, by assigning a value to a variable with the function s name. E.g.: function int <8> t r i p l e ( Int<8> x ) { t r i p l e = x + x + x ; 4.3 Expressions Expressions are used for computing values. They are used in assignment statements, to denote conditions, to send arguments to functions, etc. Expressions are built from atomic values using operations. 4.3.1 Atomic Values The following are the atomic values allowed: 1. A Boolean constant: false, true. 2. An integer constant: e.g. 34,-56, 0, 123456789123456789. 3. A (global or local) previously defined variable name or constant name in scope: e.g. i, price. 4. A field in a struct using x.y notation. (Here x is a struct, and y is a name of a field defined in that struct.) 5. An array entry using a[i] notation. (Here a is an array and i is an integer expression.) 6. Length of an array using a.length notation. 7. Size (in bits) of any integer using i.bitsize notation. Note: the index in an array entry or a bit of an integer need not be a compile time constant but rather may be an arbitrary expression. Note however that there is an enormous difference in efficiency between these two cases: access to an index that is a compile-time constant incurs no cost at all, while access to an index that is a run-time expression incurs cost that is linear in the total size of the array or integer. 5

4.3.2 Operators The following operators are defined: 1. +,- : Addition and subtraction (in 2 s complement). Accepts k-bit long integers and return a k-bit long result. 2. &&,,! : Logical and, or, not. Accept k-bit long arguments and return k-bit results. 3. <, >, ==, >=, <=,! = : 2 s complement comparison operators. Accept k-bit long arguments and return a 1-bit result. 4. Function call: e.g. f(x, y), where f is a previously defined function and x, y,.. are arbitrary expressions. 5. *, / : Multiplication and division. Multiplication takes operands of lengths k1 and k2 and returns a result of length k1+k2; division returns a result of length k1 (the numerator size). Note: Narrow and wide operands may be combined in an operation, and the narrower value is always widened using sign-extension. 4.3.3 Compile-time constants An expression is a compile time constant if it does not use any variables. Indexes of for loops are compile time constants, as are x.bitsize and y.length. Compiletime constants must be used as the range in for loops, and as the integer-size and array-length in declarations. In all cases they are pre-evaluated and are more efficient than general expressions. 4.4 Generic functions In some cases we want that the return value of a function will be depend on the function parameters. For example we would like to write a function that shifts any int, regardless of its size. This means that the return value is depended on the given input (for int<4> it should return int<4> and for int<8> it should return int<8>). In order to allow such declaration of return values using the bit size or the length of the function parameters, one may use a variable-like place holder for the size or length instead of the return type. In this case the keyword generic is used as the type, and the type itself is given in Pascal-style after the function name and parameters. function g e n e r i c s h i f t R i g h t ( Int<> v ) : Int<v. b i t S i z e > { f o r ( i = 0 t o v. bitsize 2) s h i f t R i g h t [ i ] = v [ i + 1 ] ; s h i f t R i g h t [ v. bitsize 1] = 0 ; 6

5 More examples / P e r f o r m s a v o t i n g b e t w e e n t w o c a n d i d a t e s. At t h e e n d a l l t h e v o t e r s k n o w who won. N o t h i n g e l s e i s k n o w n t o a n y o n e. / program v o t i n g { const n V o t e r s = 5 ; type VotesCount = Int <4>; / / E n o u g h b i t s t o v o u n t u p t o 5 v o t e r s. / / Two c a n d i d a t e s ( i n t w o s c o m p l i m e n t ). type Vote = Int <2>; type Voter = struct { Vote input, Vote output ; function void main ( Voter [ nvoters ] v o t e r s ){ var VotesCount [ 2 ] vc ; var Vote win ; / / M a k i n g t h e v o t i n g. f o r ( i =0 to nvoters 1){ i f ( v o t e r s [ i ]. input == 0 ) vc [ 0 ] = vc [ 0 ] + 1 ; e l s e vc [ 1 ] = vc [ 1 ] + 1 ; i f ( vc [ 1 ] > vc [ 0 ] ) win = 1 ; / / S e t t i n g t h e r e s u l t. f o r ( i =0 t o nvoters 1) v o t e r s [ i ]. output = win ; More examples can be found in the Fairplay project web site. 7