{"id":13654944,"url":"https://github.com/s0l0ist/node-seal","last_synced_at":"2025-10-10T13:14:27.866Z","repository":{"id":41348096,"uuid":"190240163","full_name":"s0l0ist/node-seal","owner":"s0l0ist","description":"Homomorphic Encryption for TypeScript or JavaScript - Microsoft SEAL","archived":false,"fork":false,"pushed_at":"2025-08-28T08:48:48.000Z","size":85347,"stargazers_count":208,"open_issues_count":0,"forks_count":25,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-10-09T09:05:46.706Z","etag":null,"topics":["crypto","cryptography","cryptosystem","emscripten","encryption","homomorphic","homomorphic-encryption","homomorphism","javascript","microsoft","microsoft-seal","node-seal","seal","web-assembly","webassembly"],"latest_commit_sha":null,"homepage":"https://s0l0ist.github.io/node-seal/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/s0l0ist.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-06-04T16:28:01.000Z","updated_at":"2025-10-08T16:42:23.000Z","dependencies_parsed_at":"2023-12-28T22:01:20.524Z","dependency_job_id":"891e936b-9a7e-49fe-b727-9ff0130d6f11","html_url":"https://github.com/s0l0ist/node-seal","commit_stats":null,"previous_names":["morfix-io/node-seal"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/s0l0ist/node-seal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0l0ist%2Fnode-seal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0l0ist%2Fnode-seal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0l0ist%2Fnode-seal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0l0ist%2Fnode-seal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s0l0ist","download_url":"https://codeload.github.com/s0l0ist/node-seal/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0l0ist%2Fnode-seal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004073,"owners_count":26083665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crypto","cryptography","cryptosystem","emscripten","encryption","homomorphic","homomorphic-encryption","homomorphism","javascript","microsoft","microsoft-seal","node-seal","seal","web-assembly","webassembly"],"created_at":"2024-08-02T03:00:52.993Z","updated_at":"2025-10-10T13:14:27.859Z","avatar_url":"https://github.com/s0l0ist.png","language":"TypeScript","readme":"# [node-seal](https://github.com/s0l0ist/node-seal) \u0026middot; [![GitHub license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/s0l0ist/node-seal/blob/main/LICENSE) [![codecov](https://codecov.io/gh/s0l0ist/node-seal/branch/main/graph/badge.svg)](https://codecov.io/gh/s0l0ist/node-seal) [![npm version](https://badge.fury.io/js/node-seal.svg)](https://www.npmjs.com/package/node-seal) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fs0l0ist%2Fnode-seal.svg?type=shield\u0026issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fs0l0ist%2Fnode-seal?ref=badge_shield\u0026issueType=license)\n\nnode-seal is a homomorphic encryption library for TypeScript or JavaScript.\n\n- **Web Assembly:** Fastest web implementation of the C++ [Microsoft\n  SEAL](https://github.com/microsoft/SEAL) library\n- **Zero dependencies:** Very lean, only contains a low level API which is very\n  close to the C++ calls from Microsoft SEAL.\n- **Node.js, Browser:** Install once, work in any server/client configuration.\n\n**Now supporting Microsoft SEAL 4.1.2**\n\n## Installation\n\nnode-seal can be installed with your favorite package manager:\n\n```shell\nnpm install node-seal\n```\n\n```shell\nyarn add node-seal\n```\n\nImport the library using `import` or `require` syntax:\n\n```javascript\n// Auto-detects browser or nodejs.\n// Defaults to \"node-seal/throws_wasm_node_umd\" for NodeJS\n// Defaults to \"node-seal/throws_wasm_web_umd\" for Browsers\n// Defaults to \"node-seal/throws_wasm_web_es\" for Modules\nimport SEAL from 'node-seal'\nconst SEAL = require('node-seal')\n```\n\nYou may also specify a deep import to target your environment better. This is\nuseful for environments that aren't detected properly or do not support\nWebAssembly. In addition, there are two separate bundles for throwing on\ntransparent ciphertexts and another for allowing transparent ciphertexts. If\nyou're unsure what you need, start with the build that **throws** on transparent\nciphertexts. This is also the default import that is used.\n\nThe deep import link is structured like the following:\n\n`node-seal / \u003cthrows|allows\u003e_wasm_\u003cnode|web|worker\u003e_\u003cumd|es\u003e`\n\n```javascript\n// Always Pick a variant which throws on transparent ciphertexts unless you\n// have a specific reason to allow the use of transparent ciphertexts.\nimport SEAL from 'node-seal/throws_wasm_node_umd'\n\n// Or pick a variant which allows transparent ciphertexts (only use this if you know what you're doing)\nimport SEAL from 'node-seal/allows_wasm_node_umd'\n```\n\n#### React-Native\n\nReact-native does not support Wasm libraries; however, it is possible to run a\nWasm library, including `node-seal` by using a\n[WebView](https://github.com/react-native-webview/react-native-webview#readme)\nto load both the library and a simple interface to communicate with on top of\nthe built-in `postMessage` API. Instead of publicly hosting the web application\nto be rendered by the WebView, it is possible to bundle the mini web application\ninto a single HTML file (with JS inlined) and load the HTML file directly to the\nWebView.\n\n#### Cloudflare Workers\n\nThe Wasm library needs to be explicitly imported, it will be compiled and\nprovided by the Cloudflare Workers runtime. Example:\n\n```javascript\nimport SEAL from 'node-seal/throws_wasm_cf_worker_es'\nimport wasm from 'node-seal/seal_throws_wasm_cf_worker.wasm'\n\nexport default {\n  async fetch(request) {\n    const seal = await SEAL(wasm)\n    return new Response(seal.Version)\n  }\n}\n```\n\n## Demo\n\nGo to the [sandbox](https://s0l0ist.github.io/seal-sandbox/)\n\nThis sandbox was built for users to experiment and learn how to use Microsoft\nSEAL featuring node-seal.\n\n- **Encryption Parameters:** experiment with many settings to prototype a\n  context.\n- **Keys:** Create, download, upload Secret/Public Keys - even for\n  Relinearization and Galois Keys.\n- **Variables:** Create, download, upload PlainTexts or CipherTexts\n- **Functions:** Create a list of HE functions to execute!\n- **Code Generation:** After your experimentation is complete, generate working\n  code to use!\n\n## Usage\n\nCheckout the [basics](USAGE.md)\n\n## Documentation\n\nView the latest docs [here](https://s0l0ist.github.io/node-seal)\n\n## Examples\n\nCheck out the [Sandbox](https://s0l0ist.github.io/seal-sandbox/) to run HE\nfunctions and even generate working code!\n\nIf you'd rather read an example, take a look [here](FULL-EXAMPLE.md).\n\nFor more exhaustive examples, view the [tests](src/__tests__).\n\n## Changes\n\nFor changes in this library, take a look [here](CHANGES.md).\n\nFor changes in Microsoft SEAL, take a look at their [list of\nchanges](https://github.com/microsoft/SEAL/blob/master/CHANGES.md).\n\n## Benchmarking\n\nMicrosoft SEAL has a native benchmark tool that we compile directly to WASM.\n\n1. `npm run seal:build:bench`\n2. `npm run benchmark`\n\n## Benchmark\n\nCheckout the [benchmark](BENCHMARK.md)\n\n## Caveats\n\nConversion from C++ to Web Assembly has some limitations:\n\n- **±2^53 bit numbers:** JavaScript uses 2^53 numbers (not true 64 bit). This\n  means we lose some precision after cryptographic operations are computed in\n  WASM and we want to send the results to JS for consumption (across the WASM \u003c\u003e\n  JS boundary). If you're using the `CKKS` scheme, you need to keep this in\n  mind. `BFV` users will inherently adhere to these limitations due to the\n  Int32Array/Uint32Array TypedArrays. Recently, `BFV` users now have support for\n  BigInt64Array/BigUint64Array TypedArrays but at a significant encode/decode\n  penalty - encyption/evaluation/decryption performance is the same.\n\n- **Memory:** Generating large keys and saving them in the browser could be\n  problematic. We can control NodeJS heap size, but not inside a user's browser.\n\n  Saving keys is very memory intensive especially for `polyModulusDegrees`s\n  above `16384`. This is because there's currently no way (that we have found)\n  to use io streams across JS and Web Assembly code, so the strings have to be\n  buffered completely in RAM and they can be very, very large when using the\n  default `zstd` compression. User's who are experiencing OOM exceptions when\n  saving `GaloisKeys` should try specifying a compression override such as\n  `none` or the less performant `zlib`. Ex:\n  `galoisKeys.save(seal.ComprModeType.zlib)`\n\n- **Garbage Collection**: By default, when a JavaScript object is dereferenced,\n  the underlying WebAssembly (C++) object remains in memory.\n\nYou have two options for cleanup:\n\n- In performance-sensitive code (e.g. tight loops), explicitly call\n  `\u003cinstance\u003e.delete()` to release memory immediately.\n- If the environment supports `FinalizationRegistry`, the C++ resources will be\n  released automatically once the object is garbage collected.\n\n## Contributing\n\nThe main purpose of this library is to continue to evolve and promote the\nadoption of homomorphic encryption (using Microsoft SEAL) in modern web\napplications today. Development of node-seal happens in the open on GitHub, and\nwe are grateful to the community for contributing bugfixes and improvements.\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nnode-seal is [MIT licensed](LICENSE).\n\n[![FOSSA\nStatus](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fs0l0ist%2Fnode-seal.svg?type=large\u0026issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fs0l0ist%2Fnode-seal?ref=badge_large\u0026issueType=license)\n","funding_links":[],"categories":["Libraries","TypeScript"],"sub_categories":["[Sunscreen](https://sunscreen.tech/)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs0l0ist%2Fnode-seal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs0l0ist%2Fnode-seal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs0l0ist%2Fnode-seal/lists"}