# OpenFHE Build Issues

**URL:** https://openfhe.discourse.group/t/openfhe-build-issues/1983
**Category:** Library Questions
**Tags:** openfhe-help, bugs
**Created:** [April 8, 2025, 9:59pm UTC](https://openfhe.discourse.group/t/openfhe-build-issues/1983 "2025-04-08T21:59:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Pavanranganath](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@Pavanranganath](https://openfhe.discourse.group/u/Pavanranganath)
#### Post date: [April 8, 2025, 9:59pm UTC](https://openfhe.discourse.group/t/openfhe-build-issues/1983/1 "2025-04-08T21:59:35Z")

</div>

I’m attempting to build OpenFHE for WebAssembly using `emcmake` and encountered a couple of issues. Since `openfhe-wasm` is still a work in progress, I analyzed and tried to fix them. Would appreciate feedback on whether my solutions are appropriate or if there are better alternatives.

### **Issue 1: MAX\_MODULUS\_SIZE vs. AUXMODSIZE Mismatch**

In `src/pke/lib/scheme/ckksrns/ckksrns-parametergeneration.cpp`, `AUXMODSIZE` is set to `60` for non-128-bit platforms, but Emscripten fails in `FirstPrime` when `nBits > MAX_MODULUS_SIZE` (which is `57`).

**Proposed Fix:**  
Modified the condition to handle Emscripten separately:

```cpp
#if NATIVEINT == 128 && !defined( __EMSCRIPTEN__ )
    const size_t AUXMODSIZE = 119;
#else
    #ifdef __EMSCRIPTEN__
        const size_t AUXMODSIZE = 57;
    #else
        const size_t AUXMODSIZE = 60;
    #endif
#endif

```

### **Issue 2: `blake2xb` Compilation Error**

The error occurs due to an incompatible iterator type:

```plaintext
error: no matching function for call to 'blake2xb'  
note: candidate function not viable: no known conversion from 'iterator' to 'void *'  

```

**Proposed Fix:**  
Replaced `.begin()` with `.data()` for raw pointer access:

```cpp
if (blake2xb(m_buffer.data(), m_buffer.size() * sizeof(PRNG::result_type), 
             &m_counter, sizeof(m_counter),
             m_seed.data(), m_seed.size() * sizeof(PRNG::result_type)) != 0) {
    OPENFHE_THROW("PRNG: blake2xb failed");
}

```

### **Questions:**

1. Are these fixes correct, or is there a more robust way to handle them?
2. Are there any known workarounds or ongoing efforts to improve Emscripten compatibility?

Thanks in advance for your help!

---

<div class="post-metadata">

### Author: ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)
#### Post date: [April 11, 2025, 6:28pm UTC](https://openfhe.discourse.group/t/openfhe-build-issues/1983/2 "2025-04-11T18:28:01Z")

</div>

Thank you for reaching out. We are planning to re-add support for Emscripten to OpenFHE (we will try to do it as part of v1.3, the next significant version). We will get back to you once we get a chance to experiment with the compilation of the latest OpenFHE version (by the end of this month).
