I want to design an encryption and decryption circuit.
If I want to implement a malicious LowMC circuit in SPDZ, could you guide me on how to design it? (I already have the LowMC.cpp file.)
MP-SPDZ doesn't support compiling C++ code to secure computation. Other than that, I would appreciate a more concrete question like what have you tried and how did it fail.
MP-SPDZ doesn't support compiling C++ code to secure computation. Other than that, I would appreciate a more concrete question like what have you tried and how did it fail.
I have a LowMC.cpp code that includes encryption and decryption operations. I want to make it run in SPDZ while ensuring security against malicious adversaries.
Specific scenario:
P0 holds the plaintext.
P1 holds the key.
P1 uses the encryption algorithm from LowMC.cpp to encrypt P0’s plaintext.
The circuit should ultimately send the ciphertext to P0.
Can you guide me on how to modify the code to achieve this?
It looks like it has already been implemented: https://github.com/Archistar/archistar4mpc-cipher
OK,thank you! When I compile this code(lowmc.mpc), I find a problem, The program kept compiling and didn't finish. It has already been two hours. Could you please help me figure out why this is happening?
Thank you for raising this. You should find that 3454f0f9cdd fixes it.
Thank you for your guidance. I have another question. If I want to execute this code in a two-party malicious scenario where Party P0 has the plaintext and Party P1 has the key pair to encrypt Party P0's plaintext, which execution file should I choose to make it faster?
Do you mean which protocol? Two-party malicious computation only has a limited choice, and the main trade-off is probably between Mascot (less computation, more communication) and LowGear (the other way around).
Thank you very much!
I have come across data of the cgf2n type. Now I want to generate a two-dimensional array. How should I assign values to it? For example, there is a two-dimensional array b[2][5] whose type is cgf2n. How can I assign values to it?
You should be able to use b[i][j] = x.
I tried to use multithreading to optimize a for loop, but the execution time is the same whether I set the number of threads to 1 or 4. How can I solve this problem? m=1024 @for_range_parallel(4, m) def _(i): plaintext = Array.create_from([ sgf2n(i) for _ in range(blocksize) ]) ciphertexts = encrypt(plaintext, roundkeys, linmatrices, roundconstants)
for_range_parallel doesn't use multi-threading: https://mp-spdz.readthedocs.io/en/latest/Compiler.html#Compiler.library.for_range_parallel
If I want to use multithreading to speed up this for loop, could you recommend a way to do it?
m=1024 @for_range_parallel(4, m) def _(i): plaintext = Array.create_from([ sgf2n(i) for _ in range(blocksize) ]) ciphertexts = encrypt(plaintext, roundkeys, linmatrices, roundconstants)
You can use @for_range_opt_multithread: https://mp-spdz.readthedocs.io/en/latest/Compiler.html#Compiler.library.for_range_opt_multithread
Thank you very much !
I noticed that the statement @for_range_opt_multithread can only process the shared value, that is, data of the sgf2n type. However, when I try to process data of the cgf2n type, an error will occur. Can you help me to solve this problem?
This is my code : for r in range(rounds): @for_range_opt_multithread(32, blocksize) def _(x): linmatrices[r][x].assign(cgf2n(linmatrices0[r][x]).bit_decompose(blocksize))
This is the error message: File "/home/wmt/MP-SPDZ/Compiler/library.py", line 820, in _ state = reducer(tuplify(loop_body(j)), state) File "/home/wmt/MP-SPDZ/Compiler/library.py", line 1031, in f return loop_body(base + i) File "Programs/Source/AAlowmc_test.mpc", line 156, in _ linmatrices[r][x].assign(cgf2n(linmatrices0[r][x]).bit_decompose(blocksize)) TypeError: list indices must be integers or slices, not regint
You need to use Array or MultiArray instead of Python lists.
I used MultiArray during the initialization, but I still got this error message.
This is my initialization code : def initialize(): linmatrices = MultiArray([rounds, blocksize, blocksize], cgf2n)
Here is the code for assigning values to the array: for r in range(rounds): @for_range_opt_multithread(32, blocksize) def _(x): linmatrices[r][x].assign(cgf2n(linmatrices0[r][x]).bit_decompose(blocksize))
This is error message: File "/home/wmt/MP-SPDZ/Compiler/library.py", line 820, in _ state = reducer(tuplify(loop_body(j)), state) File "/home/wmt/MP-SPDZ/Compiler/library.py", line 1031, in f return loop_body(base + i) File "Programs/Source/AAlowmc_test.mpc", line 157, in _ linmatrices[r][x].assign(cgf2n(linmatrices0[r][x]).bit_decompose(blocksize)) TypeError: list indices must be integers or slices, not regint
When I use multithreading for a function, it always gives me the following error message:
File "/home/wmt/MP-SPDZ/Compiler/instructions_base.py", line 310, in maybe_vectorized_instruction
return instruction(*args, **kwargs)
File "/home/wmt/MP-SPDZ/Compiler/instructions_base.py", line 830, in init
self.check_args()
File "/home/wmt/MP-SPDZ/Compiler/instructions_base.py", line 871, in check_args
raise CompilerError('Invalid argument %d "%s" to instruction: %s'
Compiler.exceptions.CompilerError: Invalid argument 1 "ci567" to instruction: addint ci7, ci567, ci6
Register from other tape, trace:
I've tried many methods but still can't solve this problem. Here is my code:
def encrypt(m, roundkeys, linmatrices, roundconstants):
@for_range(rounds)
def _(r):
m0 = m.get_range(0, blocksize)
m0 = substitute(m0)
@for_range_opt_multithread(4, blocksize)
def _(k):
m0[k] = dot2(linmatrices[r][k], m0)
Can you help me resolve this error?
What is the full error trace?
My program needs to call the encryption function first: enc = encrypt(inp, roundkeys, linmatrices, roundconstants)
Then the encryption process is executed. I used multithreading during the encryption, and the program gave me this error:
You need to convert r to a MemValue.
Ok, I try to convert r to a MemValue. This is my code:
This is my error message:
The same holds for m0. Maybe use an array for that one.
I have tried many methods to modify it, but none of them were successful. Could you please help me solve this problem?
What have you tried and what was the result?
I try to convert m0 to a MemValue.
But there an error message:
Try converting it to an Array.
Thank you. My program was compiled successfully, but there was an error when it was executed.
This is an out-of-bounds error, trying to access the 13-th row of an 12x128 array. Output indices before access to find out where.