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

Updated Cerebro Documentation #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 52 additions & 24 deletions source/setup/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@ Prerequisite Libraries:
* Crypto ++ (tested with version 7.0)



Setup Steps for SCALE-MAMBA
*****************************
* After installing the libraries, go to CONFIG.mine and change the entry corresponding with ``ROOT`` to point to the current path of where the SCALE-MAMBA directory is. Also, change the entry corresponding with ``OSSL`` to have it point to the installed OpenSSL directory.
* Run ``make progs`` and SCALE-MAMBA should compile.
* Create a config file with all the servers participating in the multiparty computation. Line i should have the IP address of the i'th server.
* Go to mc2/Config and run the script gen_cert.py and pass in the previously made config file along with the number of parties participating.
* Additionally, run ``python mc2/Config/make_config.py`` which sets up the Network configuration for SCALE-MAMBA to use.
* Then in mc2/SCALE-MAMBA, run the command: ``echo '2 1 p' > ./Setup.x`` where p is the length of the prime in terms of number of bits used in the secure computation.


EMP-AGMPC
################
Prerequisite Libraries:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should probably be kept as well.

Expand All @@ -47,24 +36,63 @@ Prerequisite Libraries:
* cd into emp-tool and run ``cmake . && make && sudo make install``.
* emp-ot: Installation instructions are here: https://github.com/emp-toolkit/emp-ot
* After installing emp-toolkit, just cd into emp-ot and run ``cmake . && make && sudo make install``.

Setup Steps for EMP-AGMPC
***************************
* The make_config.py script should have set up all the network parameters inside emp-agmpc/emp-agmpc/cmpc_config.h, but if not, you'll have to manually input the IP's of each server.
* IP[i] will hold the IP address of the ith server.
* Note that everything here is 1-indexed so the first server goes into IP[1].
* Run ``cmake . && make``


Alternatives
***************************
* Alternatively, you can pull the docker image from here: ``docker pull rdeng2614/cerebro:initial_image`` which has all the dependencies installed. Then, you can clone the cerebro repository and directly start setting up from there.
Alternatively, we provide a Dockerfile that installs Cerebro as well as its dependencies.


Docker Setup
**************
* In the Cerebro repository, under ``Docker/`` are two files: `Dockerfile` and `requirements.txt`
* Place the two files in the same directory.
* In that directory, run ``docker build -t name_of_image``.

Testing
***************************
* Included with Cerebro are a set of tests for both SCALE-MAMBA and emp-agmpc.
After creating the image, run it. You should be in ``/root``, the directory Cerebro was installed in.

Complete the setup steps for your desired backend.

Setup Steps for SCALE-MAMBA
*****************************
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these setup instructions, it would be good to put the instructions in code blocks, instead of in text. This way, a user can just copy and paste the commands into shell and run them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want text/explanations at all? I can remove the text section if you don't want it. I will add a section that has purely shell commands which will set everything up if copy pasted into the shell. Some commands might be a bit cryptic though.

* Go to ``cerebro/crypto_backend/SCALE-MAMBA``.
* Copy ``CONFIG`` into ``CONFIG.mine`` (i.e ``cp CONFIG CONFIG.mine``).
* Go to ``CONFIG.mine`` and change the entry corresponding with ``ROOT`` to point to the current path of where the SCALE-MAMBA directory is (most likely ``/root/cerebro/crypto_backend/SCALE-MAMBA``). Also, change the entry corresponding with ``OSSL`` to have it point to the installed OpenSSL directory (most likely ``/usr/lib/ssl``)
* Run ``make progs`` and SCALE-MAMBA should compile.
* Go to ``cerebro``. Then do ``python Config/gen_cert.py n`` where ``n`` is the number of parties you want to compute with. For the tests (described below) to work, we require ``n`` to be ``2``.
* This will generate certificates for the root and the ``n`` parties. The first certificate is the the root's certificate. The following certificates are for the parties. For simplicity, make sure to set the ``Common Name`` of the root as ``RootCA``. Set the ``Common Name`` of the ``i``th party to ``Player(i-1)`` (e.g. ``Player0`` for the first party).
* Go to ``cerebro/crypto_backend/SCALE-MAMBA`` and run ``./Setup.x``.
* First, let's setup ``Certs`` (i.e enter ``1``).
* For the root, enter the name you gave your root (e.g. ``RootCA``). For the number of players, enter ``n`` (e.g. ``2``). Then, for each player, input an IP address (for testing, input ``127.0.0.1``). For the name of certificate, use the common name you gave your parties appended with ``.crt`` (e.g. ``Player0.crt`` and ``Player1.crt``). This should produce ``NetworkData.txt`` under ``Data``.
* Next, run ``./Setup.x``, and setup secret sharing. Choose full threshold. Let it find the prime for LSSS. For the modulus, for simplicity, enter 128. You can choose a different number if you want. The number you can choose is limited by ``MAX_MOD`` in ``CONFIG.mine``; you can't use more than 2 to the ``MAX_MOD`` bits. You can configure ``MAX_MOD`` if you want.
* Finally, run ``./Setup.x``, and setup the convversion circuit.

Testing for SCALE-MAMBA
*************************
* To run the tests with SCALE-MAMBA, run ``cd mc2/crypto_backend/SCALE-MAMBA`` and then run ``python test_scripts/test_scale_mamba.py``.
* Troubleshooting
* Try editing ``test_scripts/test_scale_mamba.py`` such that in ``run_online`` when running ``./Player.x 0 ...`` and ``./Player.x 1 ..``, you add a flag ``-max 5000,5000,5000``. This limits the numbers of triples that can be generated to 5000.
* Edit ``Data/NetworkData.txt`` such that the last two lines (which should be zeros) are ones. This uses a fake online phase so it sacrifices security for speed. However, for testing purposes, this is okay.

Resources
**********
* SCALE-MAMBA repository


EMP-AGMPC
################

Setup Steps for EMP-AGMPC
***************************
* Navigate to ``cerebro/crypto_backend/emp-toolkit/emp-agmpc/emp-agmpc``. Edit the file ``cmpc_config.h``. You can set ``NUM_PARTY_FOR_RUNNING`` to configure the number of parties in your computation. Then, edit ``IP`` such that the ``i``th index holds the IP address of the ``i``th party. For example, ``IP[1]`` holds the IP address for party 1, ``IP[2]`` holds the IP address for party 2, etc. Also, make sure that the 0th index and the last index of ``IP`` contains ``""``. So if ``NUM_PARTY_FOR_RUNNING`` is 3, for example, ``IP[0]`` and ``IP[4]`` hold ``""``.
* For the tests, we require ``NUM_PARTY_FOR_RUNNING`` to be 2 and every party's IP address to be ``127.0.0.1``.
* Run ``cmake . && make``

Testing for EMP-AGMPC
***********************
* To run the tests with emp-agmpc, run ``cd mc2/crypto_backend/emp-toolkit/emp-agmpc`` and then run ``python test_scripts/test_gc.py``.

Resources
***********
* emp-agmpc repository
* emp-tool repository
* emp-ot repository

5 changes: 3 additions & 2 deletions source/setup/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Boolean: EMP_AGMPC
* circuit_file_folder is the directory that contains the circuit file: "agmpc.txt" and the input format file "agmpc.txt.input".

* After the computation is run, the output file "agmpc.output" will be stored in the specified output_file_folder.
* You can parse ``agmpc.output`` using the script ``agmpc_output_parser.py`` in ``Output_Data``



Expand All @@ -39,9 +40,9 @@ Side Note: Input Data
Arithmetic and Boolean circuits are able to read in user data. Currently, Cerebro has it set up such that the input data comes from a directory called Input_Data. In there, there is a script called ``gen_data.py`` which will convert data generated from another python file to input_data recognizable by Cerebro.

To have a user provide input data do the following:
* In another file (for example hello.py), run the program that generates the user data.
* In another file (for example hello.py), write the program that generates the user data.
* At the very end of the program, set the variable ``data`` equal to the array of the user's input data. For example, if my input data is 1,2,3, then at the very end of the program we have the line: ``data = [1, 2, 3]``
* Call ``python gen_data.py [file_name]`` where file_name is the python file containing the data.
* Call ``python gen_data.py . [file_name]`` where file_name is the python file containing the data. For example, if our data is generated in ``hello.py``, then call ``python gen_data.py . hello``
* The script generates a file f0 and input.txt. The former is used for arithmetic circuits and can be left alone while the latter text file can be moved depending on your needs. (More is explained above in the EMP_AGMPC section).

Limitations: Currently the way the script is written, the input size is at most 64 bits in length.
Expand Down