Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference between .so and .pyd file? #126

Open
mebner98 opened this issue Nov 14, 2024 · 3 comments
Open

Difference between .so and .pyd file? #126

mebner98 opened this issue Nov 14, 2024 · 3 comments
Labels
question Further information is requested

Comments

@mebner98
Copy link

mebner98 commented Nov 14, 2024

I am using your seal-python wrapper successfully for my application in combination with https://github.com/s0l0ist/node-seal for my angular frontend. If i start everything locally on my windows machine both versions work together fine. But now I am trying to deploy my architecture into docker and therefor build your seal-wrapper for linux instead of the .pyd file. The problem is, that SEAL gives me the error RuntimeError: loaded SEALHeader is invalid now when i load a cipher (which got created in the frontend) into SEAL in python. Do you know why that could happen? Are there version differences between the linux and windows build?

cipher = Ciphertext()
    # create temp file to load cipher text into seal
    with tempfile.NamedTemporaryFile(delete=False) as temp_file:
        temp_file.write(cipher_bytes)
        temp_file_path = temp_file.name

    cipher.load(context, temp_file_path)
    os.remove(temp_file_path)
    return cipher

error gets thrown at cipher.load

Dockerfile:

FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /app

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    cmake \
    python3-dev \
    && rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/Huelse/SEAL-Python.git

WORKDIR /app/SEAL-Python

RUN pip install numpy pybind11

RUN git submodule update --init --recursive

RUN cd SEAL && \
    cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF && \
    cmake --build build && \
    cd ..

RUN python3 setup.py build_ext -i

RUN cp seal.*.so /app/

WORKDIR /app

COPY . .

EXPOSE 5000

CMD ["python", "server.py"]

As i said locally everything works fine but dockerization creates that problem

@mebner98 mebner98 added the question Further information is requested label Nov 14, 2024
@Huelse
Copy link
Owner

Huelse commented Nov 14, 2024

The .so is for linux, .pyd is for windows.

@mebner98
Copy link
Author

yes i know! So when i am running the python flask application on my windows pc locally i use the .pyd file and it works. But as soon i put the python flask application in a linux docker container (and therefor use the .so file as seen in the posted dockerfile) i get the error with the invalid seal header. If i run everything in docker except for the flask application locally on my pc (--> .pyd file) than it works too.

It seems like the compability problems are a result of the .so file usage in the docker container but i have to use it

@mebner98
Copy link
Author

I solved it - the problem was a result of the difference in the compression modes.
In your build specification you build the windows file without -DSEAL_USE_ZSTD=OFF but for linux it is stated.
I removed it for the linux build and now it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants