node-seal is a homomorphic encryption library in JavaScript.
- Web Assembly: Fastest web implementation of the C++ Microsoft SEAL library
- Zero dependencies: Very lean, only contains a low level API which is very close to the C++ calls from Microsoft SEAL.
- Node.js or the browser: Install once, work in any server/client configuration.
Now supporting Microsoft SEAL 3.4.5
node-seal can be installed with your favorite package manager:
npm install node-seal
yarn add node-seal
Go to morfix.io/sandbox
This sandbox was built for users to experiment and learn how to use Microsoft SEAL featuring node-seal.
- Encryption Parameters: experiment with many settings to prototype a context.
- Keys: Create, download, upload Secret/Public Keys - even for Relinearization and Galois Keys.
- Variables: Create, download, upload PlainTexts or CipherTexts
- Functions: Create a list of HE functions to execute!
- Code Generation: After your experimentation is complete, generate working code to use!
Checkout the basics
View the latest docs here
Check out the Sandbox to run HE functions and even generate working code!
If you'd rather read an example, take a look here.
For more exhaustive examples, view the tests here.
For changes in this library, take a look here.
For changes in Microsoft SEAL, take a look at their list of changes.
Conversion from C++ to Web Assembly has some limitations:
-
±2^53 bit numbers: JavaScript uses 2^53 numbers (not true 64 bit). Values higher than these will typically result in inaccuracies.
BFV
users will inherently adhere to these limitations due to the Int32/UInt32 TypedArrays.CKKS
users will need to keep this in mind. -
Memory: Generating large keys and saving them in the browser could be problematic. We can control NodeJS heap size, but not inside a user's browser.
Saving keys is very memory intensive especially for
polyModulusDegrees
s above16384
. This is because there's currently no way (that we have found) to use io streams across JS and Web Assembly code, so the strings have to be buffered completely in RAM and they can be very, very large. This holds especially true forGaloisKeys
where you may hit JS max string limits (256MB). -
Garbage Collection: Unfortunately, the typical way of cleaning up dereferenced JS objects will leave behind a the Web Assembly (C++) object in memory. There is no way to automatically call the destructors on C++ objects. JavaScript code must explicitly delete any C++ object handles it has received, or the heap will grow indefinitely.
<instance>.delete()
The main purpose of this library is to continue to evolve and promote the adoption of homomorphic encryption (using Microsoft SEAL) in modern web applications today. Development of node-seal happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements.
See CONTRIBUTING.md.
node-seal is MIT licensed.