cryptobiu / libscapi

Comprehensive Open Source Library for Secure Multiparty Computation
MIT License
180 stars 66 forks source link

Compare two strings #7

Closed prvsousa closed 7 years ago

prvsousa commented 7 years ago

Hi,

Can you give me some guidance about how can I do comparison of two strings securely and privately using this library?

Thanks

moriyaw commented 7 years ago

Hi,

If you want a two-party protocol, use the yao protocol (semi honest or malicious). If you want a multi-party protocol, use the gmw protocol.

For both protocols you need to provide a circuit that gets the strings and compare them.

You can find the protocols at https://github.com/cryptobiu/libscapi/tree/dev/protocols.

prvsousa commented 7 years ago

Could you give me more hints about the comparison of strings? in GMW

prvsousa commented 7 years ago

When I'm trying to make "make" on the YaoSingleExecution I got:

[ 25%] Building CXX object CMakeFiles/yaosingleexecution.dir/YaoSEParty.cpp.o
In file included from /home/patriciarvsousa/libscapi/protocols/YaoSingleExecution/YaoSEParty.cpp:5:0:
/home/patriciarvsousa/libscapi/protocols/YaoSingleExecution/YaoSEParty.h:8:53: fatal error: libscapi/include/CryptoInfra/Protocol.hpp: No such file or directory
compilation terminated.
CMakeFiles/yaosingleexecution.dir/build.make:62: recipe for target 'CMakeFiles/yaosingleexecution.dir/YaoSEParty.cpp.o' failed
make[2]: *** [CMakeFiles/yaosingleexecution.dir/YaoSEParty.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/yaosingleexecution.dir/all' failed
make[1]: *** [CMakeFiles/yaosingleexecution.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
moriyaw commented 7 years ago

Regrading the comparison, you should create a circuit file that does that. The circuit file should follow the following format:

  1. gates

  2. parties

for each party:

  1. party id (starting from 1 to #parties)
  2. inputs for this party

  3. list of input wires indices of this party.

for each party:

  1. party id (starting from 1 to #parties)
  2. outputs for this party

  3. List of output wires indices of this party.

for each gate:

  1. input wires of this gate

  2. output wires of this gate

  3. list of input wires indices of this gate
  4. list of output wires indices for this gate
  5. truth table of this gate.

For example:

1 //One gate 2 //two parties 1 1 1 2 1 2 1 1 3 2 1 3 2 1 1 2 3 0001

You can take a look at the AES circuit (at https://github.com/cryptobiu/libscapi/blob/dev/protocols/GMW/NigelAes3Parties.txt) as an example.

After you have the circuit file, you can pass it to the GMW protocol. See README file (at https://github.com/cryptobiu/libscapi/blob/dev/protocols/GMW/README) to detailed explanaitions on the execution.

liorko87 commented 7 years ago

Hi,

I tried to reproduce your bug, but the code compiles fine. Please try to do git pull, build libscapi, and then build the protocol again.

Let me know what is the output.

prvsousa commented 7 years ago

The error stills the same and the output is the same error.

Regarding the comparison @moriyaw , thank's for the help. I'm trying to make something similar to milionaire's problem, but I'm not certain if I should use this one, because it requires a lot of information to the circuit . What is the simplest way to make this? We can think in millionaire's problem

You have some "samples" such as MaliciousOT or something... What is the difference to the "protocols"?

2017-03-05 6:51 GMT+00:00 liorbiu notifications@github.com:

Hi,

I tried to reproduce your bug, but the code compiles fine. Please try to do git pull, build libscapi, and then build the protocol again.

Let me know what is the output.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/cryptobiu/libscapi/issues/7#issuecomment-284209780, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ8WEgaetOQSIfD_Eo-IRflVZ5vfGOhbks5rilt8gaJpZM4L5UPq .

-- Patrícia Sousa

PhD Student Member: Competence Centre for Cyber Security and Privacy (C3P) Researcher: INESC-TEC / CRACS Phone: +351 220 402 985 <+351%2022%20040%202929> R.Campo Alegre,1021/1055 4169 - 007 Porto - Portugal

prvsousa commented 7 years ago

You use any tool to generate the AES circuit (at https://github.com/cryptobiu/libscapi/blob/dev/protocols/GMW/NigelAes3Parties.txt, for example) ?

moriyaw commented 7 years ago
  1. Regarding the compilation error - check your paths, maybe they are not as should be. Use the makefile to see what should the paths be.
  2. I don't know how your circuit should work. It's depends on the protocol you are running and other special needs. Maybe there are some known circuits that you can use in order to do this (compare circuit, for example). We don't have a generic tool that creates a circuit file.
prvsousa commented 7 years ago
  1. I change the paths according to my situation but the error presists. There are some problem in the CMakeLists.txt I think.

  2. In this case, I want to use GMW. But, where I can find more information about circuits? If I found a comparison circuit I need to provide the strings and I don't know how can I modify the circuits. I liked using this lib, it sounds good but I needed some support in this part. As I understand, I only have to provide to the circuits the input strings and the comparison... But now you say that depends of the protocol and "toher special needs"... @moriyaw

liorko87 commented 7 years ago

Can you please attach a screenshot of the commands you are doing in order to compile? At my machine it's compiling without any problems.

gmw_compilation

prvsousa commented 7 years ago

@liorbiu my problem is in YaoSingleExecution and not in GMW. I can sent you a print if you don't get any error in YaoSingleExecution too.

liorko87 commented 7 years ago

@patricia93sousa YaoSingleExecution compiles without any problems too.

yaoprtscr

prvsousa commented 7 years ago

image

Here is my screenshot. @liorbiu Really, I don't need YaoSingleExecution, only need GMW but i'm reporting to you be able to correct if there are any errors.


@moriyaw , If you can help me with the the doubt of the circuits, i would be grateful.

liorko87 commented 7 years ago

libscapi needs to be installed at the home directory. If you will open YaoSingleExecution CMakeLists.txt you will see that in theINCLUDE_DIRECTORIES function. Since you installed libscapi underwork/MPCFrameworks, you need to add this line to INCLUDE_DIRECTORIES function: $ENV{HOME}/work/MPCFrameworks/

prvsousa commented 7 years ago

I include this. I can show you the CMakeLists.txt.

cmake_minimum_required(VERSION 3.5) project(YaoSingleExecution) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -maes -mpclmul -msse4.1 -fPIC -Wall -march=native -O3") SET (BOOST_ROOT $ENV{HOME}/work/MPCFrameworks/boost_1_60_0/) SET (BOOST_INCLUDEDIR $ENV{HOME}/work/MPCFrameworks/boost_1_60_0/) SET (BOOST_LIBRARYDIR $ENV{HOME}/work/MPCFrameworks/boost_1_60_0/stage/lib) find_package(Boost COMPONENTS system thread REQUIRED)

INCLUDE_DIRECTORIES($ENV{HOME} ${BOOST_INCLUDEDIR} $ENV{HOME}/work/MPCFrameworks/libscapi/lib/OTExtensionBristol $ENV{HOME}/libscapi/lib/ $ENV{HOME}/work/MPCFrameworks/libscapi/build/EMP /usr/local/include/emp-tool/ /usr/local/include/emp-ot/) link_directories(/usr/ssl/lib/ /usr/local/lib $ENV{HOME}/work/MPCFrameworks/libscapi/install/lib ${BOOST_LIBRARYDIR}) set(SOURCE_FILES YaoSEParty.cpp ) add_executable(YaoSingleExecution ${SOURCE_FILES}) TARGET_LINK_LIBRARIES(YaoSingleExecution $ENV{HOME}/work/MPCFrameworks/libscapi/scapi.a boost_system boost_thread pthread crypto dl ssl z relic gmp emp-tool)

2017-03-13 11:40 GMT+00:00 liorbiu notifications@github.com:

libscapi needs to be installed at the home directory. If you will open YaoSingleExecution CMakeLists.txt https://github.com/cryptobiu/libscapi/blob/master/protocols/YaoSingleExecution/CMakeLists.txt you will see that in theINCLUDE_DIRECTORIES function. Since you installed libscapi underwork/MPCFrameworks, you need to add this line to INCLUDE_DIRECTORIES function: $ENV{HOME}/work/MPCFrameworks/

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cryptobiu/libscapi/issues/7#issuecomment-286084343, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ8WEpj3U5Mbr4cbftoKHAgMqisLnulSks5rlStHgaJpZM4L5UPq .

-- Patrícia Sousa

PhD Student Member: Competence Centre for Cyber Security and Privacy (C3P) Researcher: INESC-TEC / CRACS Phone: +351 220 402 985 <+351%2022%20040%202929> R.Campo Alegre,1021/1055 4169 - 007 Porto - Portugal

liorko87 commented 7 years ago

in the INCLUDE_DIRECTORIES you are not including the MPCFrameworks directory.

moriyaw commented 7 years ago

Hi,

You should create a compare circuit. It is not hard, just follow the format I gave you in a previous comment. In order to build that circuit you should think how to insert two strings as input to the circuit and which gates you need to do the compare.

We will be able to build the circuit for you, but we are full of work until May. In may we will have time to build the circuit, let me know if it will help you.

Good Luck!

prvsousa commented 7 years ago

I already understand how to make the circuits, I think! Thank you so much.

prvsousa commented 7 years ago

I've already been able to do that. Thank you for your help.

In the problem that I report, @liorbiu, stills the same even correcting this error. Maybe you want that I create another issue? In order to not mix matters and we close this issue?

prvsousa commented 7 years ago

Your GMW protocol in this library is securely against malicious adversaries?