node-seal is an ESM-first, WebAssembly-powered wrapper around the C++ Microsoft SEAL homomorphic encryption library, for TypeScript and JavaScript.
v7.0.0 is a breaking release. The custom JS wrapper layer was removed — the package now exposes the Emscripten-generated bindings directly. That makes the package ~96% smaller and faster, but it also means some imports and helper methods changed.
- WebAssembly: Fast, direct bindings to Microsoft SEAL
- ESM-first: Modern module layout, no bundling
- Node.js + browser + edge (CF Workers): Everything you need (JS glue, .wasm, and typings) is in the package, so you can run it anywhere WASM is allowed.
- Low-level, close to C++: Method names and types now map much more directly to SEAL
Currently aligned with Microsoft SEAL 4.1.2.
- Installation
- Quick Start
- What Changed in v7
- Environment Notes
- Demo
- Usage
- Documentation
- Examples
- Benchmarking
- Caveats
- Contributing
- License
Install from npm:
npm install node-seal
# or
yarn add node-seal
# or
pnpm add node-sealBecause v7 is ESM-first and publishes the .wasm alongside the JS glue and
TypeScript definitions, most modern bundlers can import it directly without
extra configuration.
In v7, the default import gives you a factory; call it to get the SEAL runtime:
import SEAL from 'node-seal'
const seal = await SEAL()Variants:
// recommended and default: throws on transparent ciphertexts
import SEAL from 'node-seal/throws'
const seal = await SEAL()
// allow transparent ciphertexts (only if you know you need this)
import SEAL from 'node-seal/allows'
const seal = await SEAL()See here.
You could use something like the react-native-webassembly lib, but this has not been tested.
Go to the 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 SEALContext.
- 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!
Note: the sandbox targets an earlier version of
node-seal, so generated code may need adjustments for v7.
Checkout the basics
v7 doesn't have a dedicated documentation page. Instead, you refer to the C++
bindings
for additional information. The best examples and explanations are found in
Microsoft SEAL's
repository.
View the docs from v6.0.3 and earlier
here
Check out the Sandbox to try out HE
operations and even generate example code. Just a heads-up: the sandbox was
built against an older version of node-seal, so while the demos still work,
the code it generates isn't compatible with v7.
If you'd rather read an example, take a look here.
For more exhaustive examples, view the tests.
For changes in this library, take a look here.
For changes in Microsoft SEAL, take a look at their list of changes.
npm run seal:build:bench
npm run benchmarkSee also: BENCHMARK.md.
- Memory: saving large keys in the browser is expensive; try a different compression mode if you get OOMs.
- Manual cleanup: call
.delete()or.deleteLater()on created objects to free C++ resources.
See CONTRIBUTING.md.
node-seal is MIT licensed.