nucypher / nufhe

NuCypher fully homomorphic encryption (NuFHE) library implemented in Python
https://nufhe.readthedocs.io/en/latest/
GNU General Public License v3.0
441 stars 53 forks source link

need webgl support #13

Open mccoysc opened 5 years ago

mccoysc commented 5 years ago

cuda/opencl are all needing 3rd-party plugins to installed,only webgl is work natively(no plugins needed) in browser like env:browser,electron and so on. why not add support for webgl? @fjarri

tuxxy commented 5 years ago

I'm not sure this would be that useful. I'd imagine that WebGL is far slower than what OpenCL or CUDA can achieve.

mccoysc commented 5 years ago

I'm not sure this would be that useful. I'd imagine that WebGL is far slower than what OpenCL or CUDA can achieve.

but if supported,the code can be compiled to wasm by emscripten and run in mobile phoen. 1, as my tested data,the GPU in mobile is powerful enough for computing. 2,usually,no much data needed to be handled in one phone for phone is a private device and only handle some little private data.

mccoysc commented 5 years ago

some times,the mobile phone GPU is more powerful than some PC's

tuxxy commented 5 years ago

So, the reason to add WebGL will allow us to compile to WASM? Can we not just do this with extensions to, say, Rust instead of having to add support for another backend?

mccoysc commented 5 years ago

main reason is to support running in browser and mobile env

mccoysc commented 5 years ago

and then many apps can use this feature

mccoysc commented 5 years ago

only server/pc env usage is so limited and more and more private data is in mobile phone. many people have no server to service self and also they may not have an trusted service provider

tuxxy commented 5 years ago

What use cases are you envisioning for mobile-based FHE applications?

mccoysc commented 5 years ago

FHE is to protect privacy. for modern people,the most privacy is stored and used in mobile phone. if FHE can not be used in mobile phone, the people should maintain a server to do that? or people should trust a 3rd-party organize to maintain a server to do that ?

tuxxy commented 5 years ago

Right, that's great -- we definitely need more privacy in our devices/applications/etc.

What I want to understand is what exactly you're hoping to accomplish with WebGL here. Is there something you'd like to build on a mobile variant? If so, what is it?

mccoysc commented 5 years ago

I would like to do a job-find and recruit platform. The platform make matching based on AI using encrypted data and return encrypted result to requestor and requestor share the result though the platform

mccoysc commented 5 years ago

Many people find job on phone and many company find employee on phone

michwill commented 5 years ago

Actually, you don't need to process encrypted data on the phone. You will certainly need to encrypt and decrypt on the phone (I believe, should be possible to do, yes), but the difficult part is happening on a server without the server knowing anything (and that is the whole point)

mccoysc commented 5 years ago

yes,i don't "PROCESS" it,but i need encrypt/decrypt it using homomorphic encryption

fjarri commented 5 years ago

Ok, sorry for taking so long to reply, here's my five cents.

  1. "cuda/opencl are all needing 3rd-party plugins to installed" - that's true (if you stretch the definition of "plugin"), but so does webgl - it requires a browser, and some kind of an interface from Python to it. I do not know much about mobile platforms and the current state of running arbitrary code in the browser (e.g. whether it can be accessed from Python, or the other way around).

  2. I am not sure how well WebGL is suited for general purpose computations and not specifically for graphics. If it's anything like OpenGL, as its name suggests, it will be quite hard to do GPGPU on it.

  3. Apparently, OpenCL does support mobile GPUs. Whether it will be faster than using the CPU (for this particular purpose) is uncertain, but will be interesting to test. It also seems to be a more straightforward way to use the GPU (and will require less new code).

Now I just want to ascertain what your goal is, that is, what you want to be able to do, without going into implementation details. If you want to encrypt/decrypt without a GPU, that is quite easy to do: these are just simple inner products that numpy can handle fast enough. If you want to do that in a browser, that may require writing a JS library, which will be more time-consuming (although if it's just encryption and decryption, still pretty straightforward).