data61 / MP-SPDZ

Versatile framework for multi-party computation
Other
946 stars 280 forks source link

What happens during the compiling for simple arithmetic and comparison operation and how does the lower interface deal with them? #1330

Closed ttsdmmn closed 7 months ago

ttsdmmn commented 8 months ago

comparison-comparison-0.txt I'm a mpc beginner. I'd like to know what the byte code does when I write some simple codes such as secret value addition or comparison in python. I decompile the byte code using ./compile.py -a comparison comparison.mpc. The result file contains hundreds of codes , even though the code in python is simple. Could you explain them for me ? And I'd also like to know what lower interfaces are used to execute the byte codes in protocol such as MASCOT, especially which interface it uses to realize comparison. Thanks ! The python code :

a0=sint.get_input_from(0)
a1=sint.get_input_from(1)
print_ln('%s', (a0>a1).reveal())

The byte code:

# comparison-0--0
inputmixed 6, 0, s97, 0, 0, s49, 1 # 0
subs s0, s49, s97 # 1
bit s49 # 2
adds s97, s49, s49 # 3
bit s49 # 4
adds s2, s97, s49 # 5
adds s97, s2, s2 # 6
bit s2 # 7
adds s49, s97, s2 # 8
adds s97, s49, s49 # 9
bit s49 # 10
adds s2, s97, s49 # 11
adds s97, s2, s2 # 12
bit s2 # 13
adds s49, s97, s2 # 14
adds s97, s49, s49 # 15
bit s49 # 16
adds s2, s97, s49 # 17
adds s97, s2, s2 # 18
bit s2 # 19
......
......
mkskeller commented 8 months ago

Your question touches on a range of research papers, but the most important ones are these: