Home > Cryptography, thep > Guide to HElib (#3)

Guide to HElib (#3)

To demonstrate HElib and to be able to better play with some of the settings, I’ve written a simple application which implements a RPN calculator. You can grab a copy of it on the thep downloads page. You’ll have to modify Makefile to point the HElib variable to the proper directory. Compile by typing make and run it by typing ./HEcalc. You’ll then be able to do things like:





at which point it should return 12.

This is a very preliminary version of HEcalc. I haven’t done anything with ciphertext packing, etc. The purpose of this code is to demonstrate how to add, subtract, and multiply encrypted numbers (along with how to encrypt, decrypt, etc). Play with it some. You’ll notice that by changing the value of L you’ll be able to do more multiplications without the error becoming too great to properly decrypt. You can do as many additions as you want (basically) as the error grows very slowly with additions. Another thing you’ll see when playing with this is that when you decrypt a value, you actually get a number of copies of that value. This is due to ciphertext packing (i.e., storing many values in the same ciphertext). This allows you to do SIMD operations. I hope to detail ciphertext packing and SIMD in the next post. Until then, feel free to use the comments to ask questions about HEcalc and I’ll answer as best as I can.

  1. ram
    June 27, 2013 at 2:14 am

    Dear Pwnhome,
    A lot of thanks for this program.I am working with this.But my doubt is that ,will this program works for negative numbers also or not. Because when I give 2 and 3 for subtraction (2-3) I am not getting correct results.
    Thanks in advance

  2. GNZL
    June 28, 2013 at 4:53 am

    Hi ram,

    This program is working with plaintext space Z_101, so the result will be in the range [0,100]. If you do the subtraction (2 – 3) the result will be 100 = -1 mod 101. You can modify the program to give you results in the range [-51,50], instead of p.print(cout) you can do the following:

    vector vl;
    long result = vl[0];
    if (result > 50) result -= 101;
    cout << result << endl;

    Hope it helps.

  3. October 24, 2013 at 7:28 am

    Dear Pwnhome,

    I’m working on homomorphic encryption and your code is being a great help. Anyway, I need some explanations on SIMD operations and why you get a number of copies of the result, as I would like to store just one copy. When do you plan to write your next post?

    Kind regards

    • pwnhome
      October 24, 2013 at 7:46 am

      Glad you are finding the code useful. I’ve been pretty busy which is why I haven’t done any additional posts. I hope to eventually. SIMD basically means you can hold say 5 different plaintexts in a single ciphertext then operate on all of the plaintexts at the same time. Thus if I want to compute a function f on 5 different values, I pack the 5 values into a single ciphertext and run f once. I then unpack to get the 5 answers. HElib I believe always does SIMD. I don’t think there is a way to disable that (at least not one I am aware of ATM).

  4. December 4, 2013 at 11:10 pm

    Dear Mike, is it possible to talk to you about some crypto via email or Skype or IM. I was looking at your Stack Exchange solution and I wanted to ask why are you proposing to divide mi / 2 or any other number to increase the probability of encryption.

  5. January 10, 2014 at 6:18 am

    Hi again,

    Is there any way to send the ciphertext via socket? I’d like to try serialization, but I’m not sure how it works.

    Thank you!

  6. GNZL
    January 10, 2014 at 6:31 am

    Hello Serch,

    Ctxt class implements operators for outputting the ciphertext in text format and for reading it from text format. You could use the operator << to output the content of a ciphertext to an ostringstring, and the obtain a char* using the methods .str().c_str(), then write this to the socket, in the other side you could rebuild the Ctxt doing the reverse procedure. This surely will have some issues with encodings so another approach would be to implements methods toBinary() and fromBinary that let you write/read the content from/to the Ctxt to/from a char* or ostream/istream.

  7. January 10, 2014 at 7:37 am

    Hi GNZL,

    Thank you for your quick answer. I’m quite new in C++, so I haven’t fully understood your comment. Could you put an example code, please?

    Thank you!

  8. GNZL
    January 10, 2014 at 9:46 am

    You could do something like this.

    Ctxt myctxt(pubKey);
    //Do something wi myctxt, e.g. encrypt some value
    ostringstring oss;
    oss <> receivedctxt;

    //now you should be able to operate with the ctxt

    You will need to have the same pubKey in both ends of the socket in order to make this work.

    Ask me if you need anything else.

  9. January 13, 2014 at 2:37 am

    Hi again, GNZL:

    I can’t exactly understand what you mean. For the moment the client sends the data, but I’m not capable of receiving it. Is this code more or less what you suggest?

    This is the client code:

    EncryptedArray ea(*context, G);
    Ctxt& c = *(new Ctxt(*publicKey));
    PlaintextArray p_encrypt(ea);
    ea.encrypt(c, *publicKey, p_encrypt);

    std::ostringstream oss;
    oss <> cipher; //This doesn’t work

    Once again, thank you for your help!

  10. GNZL
    January 13, 2014 at 4:26 am

    Hi Serch,

    There was a typo in my code, it should be:

    std::ostringstream oss;
    oss << cipher;

    • January 13, 2014 at 4:42 am

      Ok, it seems that my message was not posted completedly. What I was saying is that I have the client part working (oss <>cipher didn’t work for me). I attach my code so far:

      This is the client part:

      EncryptedArray ea(*context, G);
      Ctxt& c = *(new Ctxt(*publicKey));
      PlaintextArray p_encrypt(ea);
      cout<<"Encriptando valor."<<endl;
      ea.encrypt(c, *publicKey, p_encrypt);

      std::ostringstream oss;
      if(send(sock, oss.str().c_str(), oss.str().size(), 0) >cipher; //This line doesn’t work

      Is this code correct?

      Thank you again

      • January 13, 2014 at 4:43 am

        This thing is not posting my comments properly. Another try:

        Client part:

        EncryptedArray ea(*context, G);
        Ctxt& c = *(new Ctxt(*publicKey));
        PlaintextArray p_encrypt(ea);
        cout<<"Encriptando valor."<<endl;
        ea.encrypt(c, *publicKey, p_encrypt);

        std::ostringstream oss;
        if(send(sock, oss.str().c_str(), oss.str().size(), 0) < 0){
        puts("\nSend failed");
        return 1;
        return 0;

  11. January 13, 2014 at 4:44 am

    And server part:

    puts(“Connection accepted”);
    std::ostringstream oss;
    recv(client_sock , oss, oss.srt().size(), 0);
    Ctxt& cipher = *(new Ctxt(*publicKey)); //I’m not sure how to initialize Ctxt
    oss>>cipher; //This line doesn’t work

    Is this code correct?

    Thank you again and sorry for all the messages

  12. GNZL
    January 13, 2014 at 5:04 am

    In the server code i would do something like this:

    int buffer_size = 100000;//Maybe a higher or lower value
    char* buffer = new char[buffer_size];
    int bytes_read = recv(client_sock, buffer, buffer_size. 0);
    string sBuffer((const char*) buffer, bytes_read);
    delete buffer;
    std::istringstream iss;
    Ctxt cipher(*publicKey);//If you don’t send the public key to the server you have to initialize it there with the same parameters of the client.
    iss >> cipher;

    Try this and tell if it works.

    • January 13, 2014 at 7:49 am

      I think that code should work, but I’m having a “bad vector input” error in the line “iss >> cipher”. However, I’m not sure if it’s because of the server code or the client code. I’m comparing the size in both sides and it’s different; I don’t know if this is relevant.

      • January 13, 2014 at 9:54 am

        Ok, I correct myself. The code worked, I just changed the Ctxt declaration to Ctxt& cipher = *(new Ctxt(*publicKey)); and I put the socket reading clause in a while. The problem was that I wasn’t reading all the data.

        Thank you very much!!!

      • r
        June 28, 2015 at 11:41 am

        Hey Serch
        I’m currently working on creating a client/server working with the HElib,
        I want to ask you if it’s possible for you to send me a code/source files example so i can count on them as a reference,
        it’d be so much appreciated if you can do it
        Thanks a lot in advance !


      • June 30, 2015 at 10:58 am

        I worked a little bit on a client-server implementation.
        It’s very basic, but it can give you an idea.
        You can have a look at it in my repo https://github.com/antoniosv/homomorphic-counter

      • r
        June 30, 2015 at 12:01 pm

        thanks a lot :) !!!

  13. GNZL
    January 13, 2014 at 10:28 am

    Hi Serch,

    just remember that if you create the Ctxt object with the operator new, you will have to remove it later with “delete” or you will have memory leaks.

    • Urvi
      March 12, 2014 at 4:45 am

      Hi GNZL, I am working on a client server implemetation using the HELib library.
      Its a distributed environment wherein a server would set up the HElib( generating the public private keys) Now i wish to send the public key to all the participating parties so that they can encrypt there data using the public keys and perform some homomorphic operations over it.. I am unable to figure out how can i share/send the public keys to the parties.
      Any input would be a great help..


  14. waat
    January 16, 2014 at 3:17 am

    Hi everyone, I am not very familiar with c++ in Linux Ubuntu, however I was able to install the library HElib and also to run the HEcalc example. Now, I am using eclipse as IDE to play with the code, but I am not able to build or run from eclipse. Can anyone give any ideas or advice if I am using the correct IDE or I missed steps to compile and run from eclipse?

    • January 16, 2014 at 4:00 am

      I think I can reply this. I am also running HElib with Eclipse (in Windows, though). This are the steps I have followed: New C++ Project / Empty project / CygwinGCC (That’s my case, I suppose it won’t make big difference if you choose a different compiler). Then, I have included all the NTL and HElib header files into the project folder as well as the libraries (libntl.a and libfhe.a). Then, right click in the project properties, C/C++ Build / Settings / Cygwin C++ Compiler / Includes, and add the path to the header files above, and the header files below (this is pretty intuitive). After this, Cygwin C++ Linker, and do the same for the libraries (when adding the libraries above, remember that libntl.a becomes ntl). I think that’s all, in my case, and as I’m also new to Eclipse I also changed the settings in C/C++ General, Paths and Symbols, but I’m not sure if this is needed.

      If you need further assistance, I’ll try to help as far as I’m able.

      • waat
        January 17, 2014 at 8:25 am

        Hi Serch,

        I added the path of the folders (HElib and NTL) into the then ew project as you mentioned; just for testing, I was trying to build the example “HEcalc” from eclipse, but it showed me many errors. Also, I installed eclipse and Cygwin GCC in a Windows machine, I included the same folders, but still I got errors. I was looking for the files (libntl.a and libfhe.a) and I did not find them, how can I get those files? I apreciate any help.

        Thanks in advance.

  15. January 20, 2014 at 2:01 am

    Hi waat,

    To play with HElib, you need to compile the libraries by yourself in order to get the *.a files. I did it with some help, so I’m not sure how it’s exactly done, but I think that you have an example in this guide to HElib (I think it was in the second part). Anyway, I think it’s as easy as to change some paths in the Makefiles.

    First you need to compile NTL in order to get libntl.a, and then you have to use that library to get fhe.a, which you’ll have to rename to libfhe.a

    Anyway, I can recall exactly how I did it, so I hope anyone here can help you better than me. Hope my information helps.

  16. February 5, 2014 at 5:39 am

    Hi, it’s me again,

    Does anybody know if HElib can import secret keys? I’d like to work with my own Certification Authority and all this stuff, and I’ve seen that HElib includes an option to import a secret key, but I don’t know if it’s compatible.

    Thank you for your help.

  17. waat
    February 6, 2014 at 1:29 am

    Hi everyone, I just wanted to know if someone has tried to encrypt a file (eg. txt, doc, xls) by using the HElib, that is because in the examples, there are just working with numbers. Thanks for your attention.

    • pwnhome
      February 11, 2014 at 6:42 pm

      waat, sure you can encrypt a file with HElib, but remember. The entire point of HElib is to compute on encrypted data. Do you want to compute on the encrypted text?

  18. February 11, 2014 at 8:17 am

    I modify my last question: Can I create a X509 Certificate with the keys HElib generates? If so, how can I create it?

    By the way, I haven’t tried encrypting a file, for the moment only numbers are important for me.

    • pwnhome
      February 11, 2014 at 6:41 pm

      Serch, no you cannot create an X509 cert with HElib. Homomorphic encryption has not been standardized.

      • Serch
        February 12, 2014 at 7:12 am

        But can I create a certificate even if it’s not standard? Or import a private key? I’d like to work with certificates but I’m quite new in this.

        Thank you.

  19. pwnhome
    February 12, 2014 at 7:14 am

    Serch :

    But can I create a certificate even if it’s not standard? Or import a private key? I’d like to work with certificates but I’m quite new in this.

    Thank you.

    I’m not familiar with X509 enough to know. If it will let you store an arbitrary key, then probably.

  20. eleftheria
    February 18, 2014 at 7:50 am

    Hey all,

    FYI, I am a newbie in HElib and haven’t coded in C++ for quite some time.

    Anyway, what I am experiencing is a segmentation fault, a couple of seconds after running ./HEcalc (regardless of whether I type anything or not, after getting the greeding messages). From my understanding, there must be something wrong with the setupHELib(), but I haven’t changed anything in the source. Any ideas on what it could be and/or how could I solve it?

    Thank you in advance!

    • pwnhome
      February 20, 2014 at 10:15 am

      I haven’t noticed that. What kind of system are you on (OS, compiler, etc)? Can you attach a debugger and point out what line it crashes on?

      • eleftheria
        March 6, 2014 at 4:43 pm

        I was late in responding, as I was trying to debug it myself and report properly. gdb was pointing me (eventually) to a c++ file (hashtable.h) and thus driving me crazy… I didn’t manage to debug it, but I updated to the latest HElib version and now everything works.

  21. Serch
    February 26, 2014 at 2:53 am

    Hi everyone:

    Does HElib support divisions? Can I divide two numbers? Or can I operate with float variables?

    • pwnhome
      February 26, 2014 at 6:20 am

      I don’t think it supports division or floats. Using the functionality it provides, you could build that capability, but it does not support it out of the box.

  22. Urvi
    March 11, 2014 at 12:59 am

    Dear Sir/Mam,
    I am trying to use the HElib library in my implemntation.. I had a look at the HEcalc code provided by you.. Thanks for posting it, it’s a great help… I had some queries in it:

    1. While setting up Helib , you have assigned the secret key to the public key.
    secretKey = new FHESecKey(*context);
    publicKey = secretKey;
    I could not at all understand this step.

    2. We have to encode our plaintext , so that it replicates the same value in all the n slots.
    what should we do if we want different values in each slot so that we can perform the same operation simultaneoulsy on multiple values…

    Thanks in Advance,
    Waiting for your reply,

    Urvi N

    • XYZ
      April 10, 2014 at 5:31 am

      Hello EveryOne,
      I am big time stuck in my code with a very basic doubt… I tried to print the public key and each time it turned out to be same… Is it that Helib generates the same public key every time for a set of parameters???? Please it’s really urgent.. Can someone please throw some light on this… B’coz if this is true, then the security of Helib is in question…
      Thanks in advance…

      • pwnhome
        April 10, 2014 at 5:34 am

        Can you post your code or a link to it?

      • XYZ
        April 10, 2014 at 5:37 am

        void setUpHelib()
        cout<<"Inside helib setup"<<endl;
        long r=1;
        long L=8;
        long c=2;
        long k=80;
        long s=0;
        long d=0;
        long w=64;
        long m = FindM(k, L, c, p, d, s, 0);

        cout<<"Setting up the HElib…"<alMod.getFactorsOverZZ()[0];

        secretKey = new FHESecKey(*context);
        publicKey = secretKey;

        ostringstream oss;
        writeContextBase(oss, *context);
        ostringstream oss_pubKey;
        oss_pubKey << *publicKey;
        cout<<"pub key="<<publicKeyStr<<endl<<flush; /// it always turns out to be the same public key…
        cout<<"HElib set-up completed successfully"<<endl;

        Let me know if you need anything more….

      • GNZL
        April 10, 2014 at 5:41 am

        You have to seed de PRNG of C and NTL with srand48() and SetSeed() functions.

      • XYZ
        April 10, 2014 at 5:54 am

        Hello GNZL,
        Can you please elaborate a bit. I am unable to figure out where do i need to use the srand48() function. We need just the m, p, r params to generate the Context and this context is used to generate the public key rit?? Now since m,p,r stay constant, the same public key gets generated every time…


      • GNZL
        April 10, 2014 at 7:55 am

        XYZ :
        Hello GNZL,
        Can you please elaborate a bit. I am unable to figure out where do i need to use the srand48() function. We need just the m, p, r params to generate the Context and this context is used to generate the public key rit?? Now since m,p,r stay constant, the same public key gets generated every time…

        Dear XYZ,

        before the line:


        do something like this:

        ZZ zzSeed;
        zzSeed = conv(time(0));

        You can use any value different from time(0) for the seed.

      • XYZ
        April 11, 2014 at 4:04 am

        Hello GNZL,
        Thanks a lot for your input…. it worked….
        Thanks again….

      • Q.
        July 23, 2015 at 4:04 pm

        Hi, I don’t really understand why the public key has length of 43284440?

        ostringstream oss;
        writeContextBase(oss, *context);
        ostringstream oss_pubKey;
        oss_pubKey << *publicKey;
        cout<<"pub size= "<<oss_pubKey.str().length()<<endl;

        Does it relate to any parameters?
        long p=101;
        long r=1;
        long L=8;
        long c=2;
        long k=80;
        long s=0;
        long d=0;
        long w=64;
        long m = FindM(k, L, c, p, d, s, 0);

  23. fed
    April 5, 2014 at 5:50 pm

    Hello thank you for the post it is truly helpful for people who wants to implements HE schem, but i need to ask one question.i implement in steps the helib library and then compiled and executed ./hcacl as it is shown below, but the problem is that i don”t know yet how to encrypt or decrypt the data? the only thing that i can do is do operations on numbers?

  24. fed
    April 12, 2014 at 5:44 pm

    hello how can i make a debugging in order to point in all the modules on the HELIB library?

  25. Serch
    May 21, 2014 at 7:22 am

    Hi again!

    I keep working with HElib. Now I have a new problem: I am trying to write and read the public key from a file. Everything fine when I write it, I just convert it to ostringstream and it works fine. But I cannot convert it back to its own format (FHEPubKey). Can anybody help me? This is my code:

    std::ifstream file(“myFile.txt”);

    std::stringstream aux;
    aux <>(*publicKey);

    Thanks in advance.

    • fed
      June 6, 2014 at 5:38 am


      How can we do function such as ( search in database, count function, and other queries) with only the and and xor gates of fully homomorphic encryption?

      I would really appreciate if you explain to me this i need to understand it.

      Thank you

    • cqulpj
      April 5, 2016 at 9:45 pm

      Hello, I have the same problem that how can reconstruct the pubkey,do you solve it, and plz give me some ideas or tips, Thank you very much..

  26. Abhi007
    May 22, 2014 at 8:35 pm

    I am doing a Finger print authentication process. Th Feature extraction using minutiae has been done and i get an N x 4 matrix, where the 4 columns are {x,y, theta, crossing number}

    The first two are (x,y) co-ordinates of the ith minutiae point detected. The theta determines orientation of the ith minutiae and crossing number detects the type of minutiae(ridge=1,bifurcation=3).

    I want to encrypt this matrix. Perform matching in the encrypted domain and send the result back in encrypted form.(using HElib). Is there idea for doing this. Please help.

  27. Tram Truong-Huu
    August 28, 2014 at 3:10 am


    I am quite new with HElib. I am trying to compare two ciiphertext values to check if their corresponding plaintext values are equal or not (without decryption). However, what i have tried does not give the expected result. Given c1 and c2 are ciphertexts of two values p1=p2 =1, instruction c1==c2 or c1.equalsTo(c2) always give false.

    Did anyone of you work on that problem?
    Could you please give me a hint?


    • GNZL
      August 28, 2014 at 3:14 am

      The encryption used by HElib is not deterministic, so every time you encrypt a plaintext it will produce a different randomized ciphertext. This is the reason the method equalsTo() always returns false.

      • Tram Truong-Huu
        August 28, 2014 at 3:20 am

        Thanks, GNZL.

        I know that HElib is a probabilistic scheme. But is there exist a way to compare two ciphertext value to know if their plaintext values are equal, with HElib?

      • GNZL
        August 28, 2014 at 3:24 am

        As far as I know that is not possible. You could do some kind of processing like subtract one ciphertext to the other, but you would still need the decryption key to check if the result is zero.

  28. Tram Truong-Huu
    August 28, 2014 at 3:30 am

    Thank you, that is also my guess. But, I wrote a message to Shai Halevi and Victor Shoup to check the situation.

    • Gil
      April 30, 2016 at 7:58 am

      i’m also going through this problem. Do you receive any suggestion from Shai Halevi or Victor Shoup?

  29. SpiriLiao
    November 27, 2014 at 8:20 pm

    It seems that all computations in Test_XYZ routines are modulo p. For example, when p=257, all results are modulo 257. But how can I get the ‘real’ results, rather than the results modulo p.set a bigger modulo seems works,but is there other natural methods?

    • pwnhome
      November 29, 2014 at 6:37 pm

      You’ll always be working modulo some prime.

      • SpiriLiao
        November 30, 2014 at 5:38 am

        Alright, thanks.

  30. SpiriLiao
    December 3, 2014 at 5:52 am

    Hello again
    I was confused that everytime i call the secretKey.GenSecKey(),it returns the same secretKey,and so the publicKey is.as you know,the key is very long,so if you are interested in this question you can contact me and i will email you the secretKey and publicKey.

  31. January 29, 2015 at 4:01 pm

    Hello GNZL,
    As many others here, I’m getting started on doing stuff with HELib, and I would be very thankful if you could confirm if it supports comparisons between two ciphertexts, out of the box. Say, ciphertext a greater than ciphertext b.
    I saw this function in the API, but I’m unsure what it does:
    long argmax (vector &v, bool(*moreThan)(long, long))
    A variant with a specialized comparison function (*moreThan)(a,b) returns the comparison a>b.

    If it’s not implemented out of the box, do you have any advice as in how I could do it myself?

    Thanks in advance!

    • GNZL
      January 30, 2015 at 2:47 am

      Hi emyr404,

      The function “argmax” returns the element with maximum value from a vector, but is doesn’t work with encrypted values.

      The only way I can think for comparing two encrypted values is subtract one from the other, after that decrypt the result, if the result is great than zero then the first ciphertext is bigger, if it equals to zero both ciphertext are equal, and if it’s less than zero then the second ciphertext is bigger. The problem is that the result you obtain after decrypting belongs to Zp (being p some modulus), so for checking if the result is less than zero you should check if the decrypted value you obtained is great than p/2.

      I hope this can solve your question.

      • February 4, 2015 at 8:24 pm

        Thank you for your response. It helped me realize that doing something like this on homomorphic encryption would lead to a security violation. I wouldn’t want anyone to decrypt that result, because I was trying to apply it in a vickrey auction… so it doesn’t work out as I would have hoped.

        I’ll try another approach. Thanks again. :)

  32. May 7, 2015 at 5:14 am

    Hello GNZL!

    I have a question. Is there a way to reconstruct the public key object (FHEPubKey) from a file or istringstream object? I looked at the docs, but I’m still not finding a clue on how to do that.

    Thanks for your time.

    • cqulpj
      April 5, 2016 at 9:41 pm

      Hello, I have the same problem that how can reconstruct the pubkey,do you solve it, and plz give me some ideas or tips, Thank you very much..

      • GNZL
        April 6, 2016 at 4:17 am

        If you have an initialized “FHEPubKey pk” you can save it to a file in the following way:

        ofstream pkFile(“pk.txt”);
        if (pkFile.good())
        pkFile <> otherPK;

        Now you should have recovered the public key in otherPK.

        I would like to mention that the method used for HElib to store/recover its data objects to/from files is not efficient in storage space nor is in execution time.


      • GNZL
        April 6, 2016 at 4:19 am

        Part of my last comment wasn’t stored well so I copied it again and pasted it in this link http://pastebin.com/Ma88TpQ1

  33. October 8, 2015 at 8:08 pm

    Hello everyone,

    Is there anyone who found a way to perform operations on two scalar values or two vectors with only one entry? Thank you in advance.

    • January 28, 2016 at 9:14 am

      if you have vectors containing a single entry, you can just push zeroes onto it until it is the necessary size.

      • January 28, 2016 at 10:06 am

        I think there is a misconception. I want to get rid of “multiple data” part of the “single instruction multiple data” feature in the implementation. For example, when I want to compute 5 + 4 it returns many 9s in a vector. The size of this vector depends on the parameters in the code, but it is too complicated to adjust it. What I want is to obtain only one 9 when I want to compute 5 + 4.

  34. March 10, 2016 at 6:12 am

    I installed HElib but it has PlaintextArray changed by NewPlaintextArray, I am newbie I tried to replace, but NewPlaintextArray do not have encode function. please help :)

  35. March 14, 2016 at 6:47 am

    Solved, the issue changed every PlaintextArray to NewPlaintextArray and p.encode() function to encode(ea, p, atoi(token.data())). Working fine, thanks for wonderful code & explainations :)

    • Wyn
      March 19, 2016 at 12:40 pm

      Yes, the recent HElib changed a little bit. Your solution works like charm. Thanks.

  36. waleed
    November 9, 2016 at 6:55 am

    I wish to know if the value of ciphertext a is greater than ciphertext b. Would I have to implement such a function? And if so, could I have any hints?

  37. waleed
    November 9, 2016 at 7:26 am

    Through homomorphic encription library I wish to know if the value of ciphertext a is greater than ciphertext b. Would I have to implement such a function? And if so, could I have any hints?

  38. EspeHope
    April 29, 2018 at 2:09 am

    Hello everyone,

    could you help me, please? I’m a newbie with c++ and HELib… I’m trying tu follow that guide and when I try to run “make” over HEcalc, I get this error:

    usuario@debian-9:~/Descargas/HEcalc$ make
    HEcalc g++ -g -O2 -Wfatal-errors -Wshadow -Wall -I/usr/local/include -o HEcalc -I/home/usuario/Descargas/HElib-master/src HEcalc.cpp -L/usr/local/lib /home/usuario/Descargas/HElib-master/src/fhe.a -lntl -lgmp -lm /usr/local/lib/libntl.a(ZZ_pX1.o): En la función NTL::ZZ* NTL::details_pthread::key_wrapper::set(NTL::ZZ*)’:
    /home/usuario/Descargas/ntl-11.0.0/ntl-11.0.0/src/../include/NTL/tools.h:664: referencia apthread_setspecific’ sin definir /home/usuario/Descargas/ntl-11.0.0/ntl-11.0.0/src/../include/NTL/tools.h:664: referencia a pthread_setspecific’ sin definir
    /home/usuario/Descargas/ntl-11.0.0/ntl-11.0.0/src/../include/NTL/tools.h:664: referencia apthread_setspecific’ sin definir /usr/local/lib/libntl.a(ZZ_pX1.o): En la función NTL::details_pthread::key_wrapper::key_wrapper(void (*)(void*))’:
    /home/usuario/Descargas/ntl-11.0.0/ntl-11.0.0/src/../include/NTL/tools.h:656: referencia apthread_key_create’ sin definir /usr/local/lib/libntl.a(ZZ_pX1.o): En la función NTL::ZZ* NTL::details_pthread::key_wrapper::set(NTL::ZZ*)’:
    /home/usuario/Descargas/ntl-11.0.0/ntl-11.0.0/src/../include/NTL/tools.h:664: referencia apthread_setspecific’ sin definir
    And lots of traces like these.

    I’ve corrected the error with PlaintextArray/NewPlaintextArray, also I’ve modified the Makefile to put the correct path for HEdir, but I must be doing something wrong… I’m going crazy, I’ve searched and asked for that error in forums but I didn’t found any solution…

    Thanks in advanced!!

    • Esperanza Zamora
      May 1, 2018 at 1:47 pm

      It was a stupid error, I only have to add -pthread!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: