New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does SPDZ support real numbers? #7

xiaolixiaoyi opened this Issue Apr 1, 2017 · 5 comments


None yet
3 participants

xiaolixiaoyi commented Apr 1, 2017

I want to test the performance of addition and multiplication of real numbers in SPDZ.
Is there built-in types for fixed-point or floating-point numbers in SPDZ?
Does SPDZ support right shift or left shift operations for sharings?


This comment has been minimized.


rdragos commented Apr 2, 2017

Yes, it has fixed point and floating point operations. See here the definitions for floating point:

There is also a tutorial with fixed point arithmetic here:

As for right right or left shift, I suppose you are referring to bitwise operations. In that case, take a look at this: Either way it is as simple as:

a = sint(8);
b = a >> 3 // now b = sint(1).


This comment has been minimized.

xiaolixiaoyi commented Apr 5, 2017

Thank you!
Another question is: How can I record the time consumed by each operation such as multiplication, addition and comparison? I tried 'print time.time()' using the time module in Python, but it did not work.


This comment has been minimized.


rdragos commented Apr 5, 2017

If you want to start different timers you can use the functions start_timer and stop_timer.

# instructions

You should see the timers after you run the online phase of your protocol.


This comment has been minimized.

xiaolixiaoyi commented Apr 6, 2017

I met two more problems when I run the test:

  1. I tried to perform operations such as +/*/> between arrays, but I found that the array type did not support these operations. If I perform such operations using a for-loop, will the performance benefit from the vectorization?

  2. I want to get fake offline data of 256-bit prime. But when I run the command:
    linux@xxx: Scripts/ 2 256 40
    I got:

Setting up parameters
m = 32768
	 p = 57896044624266469032429686755131815517604980759976795324963608525438406557697  u = 6332666226001739776  :   256 <= 256
Writing to file in Player-Data/2-256-40/
terminate called after throwing an instance of 'max_mod_sz_too_small'
  what():  MAX_MOD_SZ too small for desired bit length of p, must be at least ceil(len(p)/len(word))+1, in this case: 5
Scripts/ line 33:  2446 Aborted                 (core dumped) $SPDZROOT/Fake-Offline.x ${players} -lgp ${bits} -lg2 ${g} --default ${default}

This comment has been minimized.


mkskeller commented Apr 7, 2017

You need to add the following to CONFIG.mine:


@mkskeller mkskeller closed this Jul 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment