Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Improve/fix using IPCL installation #16

@skmono

Description

@skmono

Some issues have been found when trying to compile with the Intel Paillier Cryptosystem Library, after installing it in /usr/local.

test code

#include <climits>
#include <iostream>
#include <vector>
#include <random>

#include "ipcl/ciphertext.hpp"
#include "ipcl/keygen.hpp"
#include "ipcl/plaintext.hpp"

int main(){
  const uint32_t num_values = 9;

  ipcl::keyPair key = ipcl::generateKeypair(2048, true);

  std::vector<uint32_t> exp_value(num_values);
  ipcl::PlainText pt;
  ipcl::CipherText ct;
  ipcl::PlainText dt;

  std::random_device dev;
  std::mt19937 rng(dev());
  std::uniform_int_distribution<std::mt19937::result_type> dist(0, UINT_MAX);

  for (int i = 0; i < num_values; i++) {
    exp_value[i] = dist(rng);
  }

  pt = ipcl::PlainText(exp_value);
  ct = key.pub_key->encrypt(pt);
  dt = key.priv_key->decrypt(ct);

  for (int i = 0; i < num_values; i++) {
    std::vector<uint32_t> v = dt.getElementVec(i);
    bool chk = v[0]==exp_value[i];
    std::cout<<(chk?"pass":"fail")<<std::endl;
  }

  delete key.pub_key;
  delete key.priv_key;
}

Trying to compile the code fails as follows:

$ g++ test.cpp -o test -lipcl -fopenmp -lnuma
/usr/bin/ld: /usr/local/lib/libipcl.a(ifma_cvt52.c.o): in function `ifma_BN_to_mb8':
ifma_cvt52.c:(.text+0x71): undefined reference to `BN_num_bits'
/usr/bin/ld: ifma_cvt52.c:(.text+0xa0): undefined reference to `BN_bn2lebinpad'
/usr/bin/ld: /usr/local/lib/libipcl.a(ifma_cvt52.c.o): in function `ifma_BN_transpose_copy':
ifma_cvt52.c:(.text+0x229c): undefined reference to `BN_bn2lebinpad'
collect2: error: ld returned 1 exit status

ifma_BN_to_mb8 is a function found in libcrypto_mb and it is correctly included in the static library libipcl.a, but somehow compiler still complains that it is not linked.

As an additional note, we can also improve including the library. Currently more than 1 headers need to be included, as seen in the source code above. We could use a single public header, such as ipcl/ipcl.h which contains all the necessary information.

After taking care of these issues, we also need to add documentation of how to use the library after installation for both cases (using direct linkage and using CMake).
(Related to #13)

Metadata

Metadata

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions