Skip to content
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

Divide two MemValue objects? #1538

Open
imtiyazuddin opened this issue Nov 22, 2024 · 19 comments
Open

Divide two MemValue objects? #1538

imtiyazuddin opened this issue Nov 22, 2024 · 19 comments

Comments

@imtiyazuddin
Copy link

How can I divide two MemValue objects? if not can I convert them to some other objects? what options would I need when compiling?

@mkskeller
Copy link
Member

You should be to use operators just like for basic types. Futhermore, calling read() on a MemValue object returns the object "inside".

@imtiyazuddin
Copy link
Author

I tried but I got following error :
File "/home/imtiyazuddin/Ubuntu/MP-SPDZ-master/Compiler/instructions.py", line 1226, in init
raise CompilerError('random inverse in ring not implemented')
Compiler.exceptions.CompilerError: random inverse in ring not implemented

I compiled with ./compile.py fairness -M -CDR 64 -l -X .

I tried to do compile without -R 64, it gets compiled and exectued but the result is not a floating point number?

@mkskeller
Copy link
Member

This is because you're calling field division. What version are you using? The behaviour has changed in version 0.3.8 to be more intuitive: https://github.com/data61/MP-SPDZ/releases/tag/v0.3.8
In any case, you can convert to sfix or sfloat before the division to get the desired result.

@imtiyazuddin
Copy link
Author

I am testing in 0.3.7, will try with 0.3.8, thanks!

@imtiyazuddin
Copy link
Author

getting some error when trying to install 0.3.8 version:

In file included from /usr/include/openssl/conf.h:19:
/usr/include/openssl/macros.h:155:4: error: "OPENSSL_API_COMPAT expresses an impossible API compatibility level"

error "OPENSSL_API_COMPAT expresses an impossible API compatibility level"

^
1 error generated.
make: *** [Makefile:83: Processor/Program.o] Error 1

I have openssl 1.1.1h and in your documentation it says OpenSSL, tested against 1.1.1, so it should have worked right?

@mkskeller
Copy link
Member

What system are you using, and what version of boost in particular? MP-SPDZ itself doesn't touch the variable that causes this error message?

@imtiyazuddin
Copy link
Author

ubuntu 22.04 with boost 1.80

@mkskeller
Copy link
Member

Ubuntu 22.04 doesn't come with boost 1.80. Maybe try removing it. MP-SPDZ installs boost when running make setup.

@imtiyazuddin
Copy link
Author

how can I convet MemValue to sfix or sfloat ?

@mkskeller
Copy link
Member

By construction, i.e., sfix(a) where = a = MemValue(...).

@imtiyazuddin
Copy link
Author

getting same error
File "/home/imtiyazuddin/Ubuntu/mpspdz-0.3.7/MP-SPDZ-master/Compiler/instructions.py", line 1298, in init
raise CompilerError('random inverse in ring not implemented')
Compiler.exceptions.CompilerError: random inverse in ring not implemented

does this also only work in 0.3.8? (having some issues installing it)

@mkskeller
Copy link
Member

Can you post the full trace?

@imtiyazuddin
Copy link
Author

Default bit length for compilation: 63
Default security parameter for compilation: 40
Compiling file Programs/Source/fairness.mpc
Traceback (most recent call last):
File "./compile.py", line 41, in
main(compiler)
File "./compile.py", line 36, in main
compilation(compiler)
File "./compile.py", line 19, in compilation
prog = compiler.compile_file()
File "/home/imtiyazuddin/Ubuntu/mpspdz-0.3.7/MP-SPDZ-master/Compiler/compilerLib.py", line 411, in compile_file
exec(compile(infile.read(), infile.name, "exec"), self.VARS)
File "/tmp/tmpp96rasg2", line 94, in
w_p_unfav = (nunfav * np) / (n * npunfav)
File "/home/imtiyazuddin/Ubuntu/mpspdz-0.3.7/MP-SPDZ-master/Compiler/types.py", line 141, in vectorized_operation
res = operation(self, *args, **kwargs)
File "/home/imtiyazuddin/Ubuntu/mpspdz-0.3.7/MP-SPDZ-master/Compiler/types.py", line 2244, in rtruediv
a,b = self.get_random_inverse()
File "/home/imtiyazuddin/Ubuntu/mpspdz-0.3.7/MP-SPDZ-master/Compiler/types.py", line 177, in vectorized_function
res = function(cls, *args, **kwargs)
File "/home/imtiyazuddin/Ubuntu/mpspdz-0.3.7/MP-SPDZ-master/Compiler/types.py", line 209, in instruction_typed_operation
res = operation(self, *args, **kwargs)
File "/home/imtiyazuddin/Ubuntu/mpspdz-0.3.7/MP-SPDZ-master/Compiler/types.py", line 2035, in get_random_inverse
inverse(*res)
File "/home/imtiyazuddin/Ubuntu/mpspdz-0.3.7/MP-SPDZ-master/Compiler/instructions_base.py", line 406, in maybe_gf2n_instruction
return instruction(*args, **kwargs)
File "/home/imtiyazuddin/Ubuntu/mpspdz-0.3.7/MP-SPDZ-master/Compiler/instructions_base.py", line 313, in maybe_vectorized_instruction
return instruction(*args, **kwargs)
File "/home/imtiyazuddin/Ubuntu/mpspdz-0.3.7/MP-SPDZ-master/Compiler/instructions.py", line 1298, in init
raise CompilerError('random inverse in ring not implemented')
Compiler.exceptions.CompilerError: random inverse in ring not implemented

@mkskeller
Copy link
Member

What are the types of the variables in (nunfav * np) / (n * npunfav)?

@imtiyazuddin
Copy link
Author

n is sint and remaining all MemValue()

@mkskeller
Copy link
Member

MemValue is just a container type, so how have they been initialized?

@imtiyazuddin
Copy link
Author

I am using them as counters for certain triggers
so they will have some int values

@mkskeller
Copy link
Member

I see. If you want to make this work in the older version, you will need to convert any of them to sfix or sfloat manually.

@imtiyazuddin
Copy link
Author

thanks!! will give it a shot!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants