Giter VIP home page Giter VIP logo

openfhe-wasm's People

Contributors

iquah1 avatar mctriplett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

openfhe-wasm's Issues

Regarding the openfhe wasm compilation and testing issues.

  1. After compiling wasm, the UT for ckks or bgv cannot pass. The program will throw an exception here, causing UT failure. After analysis, it is this code snippet that throws the exception:
    IntType FirstPrime(uint32_t nBits, uint32_t m) {
    std::cout << "FirstPrime() enter" << std::endl;
    if constexpr (std::is_same_v<IntType, NativeInteger>) {
    if (nBits > MAX_MODULUS_SIZE)
    OPENFHE_THROW(config_error, std::string(func) + ": Requested bit length " + std::to_string(nBits) +
    " exceeds maximum allowed length " + std::to_string(MAX_MODULUS_SIZE));
    }
    The reason is that HAVE_INT128 is not defined in emmake, so the value of MAX_MODULUS_SIZE is 57. Therefore, the condition nBits (59) > MAX_MODULUS_SIZE holds true, leading to an exception being thrown.
    2.Modifying the original code:
    #if defined(HAVE_INT128)
    #define MAX_MODULUS_SIZE 60
    using BasicInteger = uint64_t;
    using DoubleNativeInt = unsigned __int128;
    using uint128_t = unsigned __int128;
    using int128_t = __int128;
    #else
    #define MAX_MODULUS_SIZE 57 ---- modify to 60
    using BasicInteger = uint64_t;
    using DoubleNativeInt = uint64_t;
    using uint128_t = uint64_t;
    using int128_t = int64_t;
    #endif
    Although no longer throwing an exception, will cause the function WitnessFunction(RNG(p - THREE).ModAdd(TWO, p), d, s, p) to always return True, preventing the exit from the FirstPrime function.
    3.Restore #define MAX_MODULUS_SIZE 57, then add a line of code to /openfhe-development/embuild/src/core/config_core.h, recompile wasm, and the UT can pass. However, there may be risks, as follows: wasm does not support 128 bits, // Note that FLEXIBLEAUTO is not supported for 128-bit CKKS In the CMakeLists.txt file at line 278 in the openfhe-development directory, it clearly states: NATIVE_SIZE == 128 is not supported for EMSCRIPTEN.
    if( "${NATIVE_SIZE}" EQUAL 128 )
    if ( EMSCRIPTEN )
    message(SEND_ERROR "NATIVE_SIZE == 128 is not supported for EMSCRIPTEN")
    endif()
    if( ${HAVE_INT128} )
    set( NATIVEINT 128 )
    message (STATUS "NATIVEINT is set to " ${NATIVEINT})
    else()
    message(SEND_ERROR "Cannot support NATIVE_SIZE == 128")

In conclusion, my question is, is it feasible to compile wasm by defining HAVE_INT128 as TRUE? If not, what risks might be involved?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.