SCAPI in C++ (Beta)

Until recently SCAPI was a java-only library that in some cases wrapped native elements using JNI. SCAPI is now supported and maintained in C++ version as well. Roughly speacking, Java-SCAPI is great for fast development of application and for POCing cryptographic protocols. However, when performance is a main concern, a c++ implementation might be more suitable.

This is still “work in progress” and should be considered as beta. There are few modules that exist in the java version but were still not ported to the C++ version. The SCAPI team is working these days on expending the c++ implementation further.

Installing SCAPI - Linux

The following explains how to install libscapi (SCAPI c++) on Ubuntu. For other Linux variants it should work as well with the appropriate adjustments.


Update and install git, gcc, gmp, and open ssl. On Ubuntu environment is should look like:

$ sudo apt-get update
$ sudo apt-get install -y git build-essential
$ sudo apt-get install -y libssl-ocaml-dev libssl-dev
$ sudo apt-get install -y libgmp3-dev

Download and install boost (the last step might take some time. patience):

$ wget -O boost_1_60_0.tar.bz2
$ tar --bzip2 -xf boost_1_60_0.tar.bz2
$ cd boost_1_60_0
$  ./
$  ./b2

More details about boost here:

Building libscapi and publishing libs

Download and build libscapi:

$ cd ~
$ git clone
$ cd libscapi
$ make

Publish new libs:

$ sudo ldconfig ~/boost_1_60_0/stage/lib/ ~/libscapi/install/lib/

Building and Running the Tests

In order to build and run tests:

$ cd ~/libscapi/test
$ make
$ ./tests.exe


Build and run the samples program:

$ cd ~/libscapi/samples
$ make

In order to see all available samples:

$ ./libscapi_example.exe

In order to run simple examples (dlog or sha1):

$ ./libscapi_example.exe dlog
$ ./libscapi_example.exe sha1

You should get some print outs if everything works well.

In order to run the CommExample. Open two terminals. In the first run:

$ ./libscapi_example.exe comm 1 Comm/CommConfig.txt

And in the other run:

$ ./libscapi_example.exe comm 2 Comm/CommConfig.txt

In order to run Semi-honset YAO, run in the first terminal:

$ ./libscapi_example.exe yao 1 Yao/YaoConfig.txt

And in the second:

$ ./libscapi_example.exe yao 2 Yao/YaoConfig.txt

Finally in order to run the Sigma example - in the first terminal run:

$ ./libscapi_example.exe sigma 1 SigmaPrototocls/SigmaConfig.txt

And in the second terminal:

$ ./libscapi_example.exe sigma 1 SigmaPrototocls/SigmaConfig.txt

You can edit the config file in order to play with the different params in all examples.

Installing SCAPI - Windows

Installing scapi on windows will require git client and Visual Studio IDE. We tested it with VS2015.


  1. Download and install open ssl for windows: (choose 64bit not light)
  2. Download and install boost binaries for windos: choose 64 bit version 14

The windows solutions assume that boost is installed at C:\local\boost_1_60_0 and that OpenSSL at: C:\OpenSSL-Win64

Pull libscapi from GitHub. For convenient we will assume that libscapi is located at: c:\code\scapi\libscapi`. If it is located somewhere eles then the following paths should be adjusted accrodingly.

  1. Build Miracl for windows 64:
    1. Open solution MiraclWin64.sln at: C:\code\libscapi\lib\MiraclCompilation
    2. Build the solution once for debug and once for release
  2. Build OTExtension for window 64:
    1. Open solution OTExtension.sln at C:\code\libscapi\lib\OTExtension\Win64-sln
    2. Build solution once for debug and once for release
  3. Build GarbledCircuit project
    1. Open solution ScGarbledCircuitWin64.sln at C:\code\libscapi\lib\ScGarbledCircuit\ScGarbledCircuitWin64
    2. Build solution once for debug and once for release
  4. Build the NTL solution:
    1. Open solution NTL-WIN64.sln at C:\code\libscapi\lib\NTL\windows\NTL-WIN64
    2. Build solution once for debug and once for release
  5. Build Scapi Solution including examples and test:
    1. Open solution ScapiCpp.sln at C:\code\libscapi\windows-solutions\scapi-sln
    2. Build solution once for debug and once for release - (as needed)
  6. Run tests.
    1. Go to C:\code\libscapi\windows-solutions\scapi-sln\x64\debug
    2. run ./scapi_tests.exe and make sure all is green
  7. Run example:
    1. open two terminals
    2. in both of them go to: C:\code\libscapi\windows-solutions\scapi-sln\x64\debug
    3. To see available samples run libscapi_examples.exe
    4. Follow instruction of how to run the different samples as exaplained in the linux section
    5. You can edit the different config file to play with the paramaters

Further Reading

For further reading - refer to the extensive Java documentation. The c++ implementation usally follows the same concept except when language specific need required some change.