This project implements a secure multi-party computation (MPC) library for C++, featuring a custom integer type (NetInt) and agent/server communication for secure arithmetic and comparison operations.
- Secure integer arithmetic (
NetInt) with support for addition, subtraction, multiplication, and comparisons - Agent/server protocol using sockets and IP whitelisting
- Easy-to-use C++ interface for secure computation that works for most programs
- Example program implementations: matrix multiplication, Dijkstra's algorithm, etc.
To build the agent and sample programs:
makeNote: The order of these steps is important. Hiding messages and adding a whitelist must be done before establishing a port.
- Move
NetInt.hand accompanyingopenssl\folder to your project directory. - Import the library with
#include "NetInt.h". - Optional: Suppress non-error messages with
hideMessages(true); - Optional: Create an IP address whitelist with
setWhitelist({"IP1", "IP2", ...}); - Open a port for agent communication with
establishPort("8081");before defining anyNetIntvariables.
- Run the primary script (e.g.
./sample) - Connect three agents to the primary script by running the agent programs with:
If agents are on the same machine as the primary script, run:
./agent <primary script ip> <port>
./agent 127.0.0.1 <port>
NetInt.h— Secure integer type and MPC contextagent.c— Agent communication logicsample.cpp,sample2.cpp,sample3.cpp— Example applicationsMakefile— Build instructionsLocal Standalone\— Contains object oriented cryptographic function implementations with descriptive commenting.Networked Standalone\— Contains Networked Code in a Server-like configuration, much easier to test.
-
Cryptologically secure random number generation:
Replace rand with a suitable, preferably cross-platform alternative. -
Improvements to negative number calculations, returns, and comparisons:
Enhance support for negative values in secure arithmetic and comparisons.
Observe sample3 -
Addition of division:
Implement secure division operations for NetInt. -
Addition of modulo:
Add secure modulo operations for NetInt. -
Store values as arrays of shares rather than raw values:
Adds more security to the primary script by storing encrypted values rather than raw data.
Also saves the library from having to split and reconstruct as often.
Drawback of having to reconstruct before returning a raw value, but calculations will be faster.
- It may be easier to work on the code by testing ideas in the Non-Networked, C version. That is included alongside a networked standalone version. Working with these is much easier than directly tackling the library code.
- The development line of Non-Networked >> Standalone >> Library makes it easier to find early implementation issues.
-
Sample code uses algorithms and code snippets from GeeksforGeeks and Programiz
-
Credit to Rajais2 for foundational code