Cause of "Requested bit length 60 exceeds maximum allowed length 57"

Hi all,

I’m supporting the development of the openfhe-julia wrapper. However, when executing our tests locally, I get the following error message:

parameters = MyOpenFHE.CCParams{MyOpenFHE.CryptoContextCKKSRNS}() = MyOpenFHE.CCParamsAllocated{MyOpenFHE.CryptoContextCKKSRNS}(Ptr{Nothing} @0x0000613a9014b020)
MyOpenFHE: Error During Test at /home/max/src/uni.d/openfhe-julia/test/test.jl:4
  Got exception outside of a @test
  /home/max/src/uni.d/openfhe-development/src/core/include/math/nbtheory-impl.h:l.353:LastPrime<intnat::NativeIntegerT<long unsigned int> >(): LastPrime: Requested bit length 60 exceeds maximum allowed length 57
  Stacktrace:
   [1] GenCryptoContext(arg1::MyOpenFHE.CCParamsAllocated{MyOpenFHE.CryptoContextCKKSRNS})
     @ MyOpenFHE ~/.julia/packages/CxxWrap/I0P2E/src/CxxWrap.jl:676
   [2] macro expansion
     @ show.jl:1232 [inlined]
   [3] macro expansion
     @ ~/src/uni.d/openfhe-julia/test/test.jl:6 [inlined]
   [4] macro expansion
     @ /usr/share/julia/stdlib/v1.11/Test/src/Test.jl:1709 [inlined]
   [5] top-level scope
     @ ~/src/uni.d/openfhe-julia/test/test.jl:5
Test Summary: | Error  Total  Time
MyOpenFHE     |     1      1  1.3s
ERROR: LoadError: Some tests did not pass: 0 passed, 0 failed, 1 errored, 0 broken.
in expression starting at /home/max/src/uni.d/openfhe-julia/test/test.jl:4

What’s so strange is that this error only occurs on my machine (and not our CI!) and with both version 1.2.3 and 1.4.0. I’m assuming the root cause is the options I used to compile openfhe-development. I probably set some options wrong and this is now causing me to only be able to use 57 bits instead of the full 60. The following options were used to compile openfhe-development:

cmake .. -DCMAKE_INSTALL_PREFIX=../install \
    -DBUILD_BENCHMARKS=OFF -DBUILD_UNITTESTS=OFF \
    -DCMAKE_CXX_FLAGS="-include cstdint" \
    -DLIBINSTALL="$(dirname $(pwd))/install/lib"

I also tried adding -DWITH_BE2=ON -DWITH_BE4=ON, but that did not help either.

I’m hoping that someone can help me identify the root cause for this issue. Any documentation featuring the compilation options would also be greatly appreciated, as I haven’t found anything on my own.

Thanks a lot already!

It sounds like the underlying compiler on the local machine does not support __int128, which the 64-bit backend uses for storing the results of multiplications of two 64-bit numbers. Typically both gcc and clang support it. Here is the related CMake line: openfhe-development/CMakeLists.txt at v1.4.0 · openfheorg/openfhe-development · GitHub

If this is the case (no support for __int128), then 57 bits is the current maximum modulus size that is currently supported for such build configuration. Most compiler configurations typically support __int128.

1 Like

That helped a lot, thanks! It does indeed look like my compiler/machine does not support __int128. The related CMake line helped a lot, I got it to work on a different machine.

Thanks a lot for your quick support!