5.1.4 • Published 6 months ago

node-seal v5.1.4

Weekly downloads
15
License
MIT
Repository
github
Last release
6 months ago

node-seal · GitHub license codecov npm version FOSSA Status

node-seal is a homomorphic encryption library for TypeScript or 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, Browser: Install once, work in any server/client configuration.

Now supporting Microsoft SEAL 4.1.2

Installation

node-seal can be installed with your favorite package manager:

npm install node-seal
yarn add node-seal

Import the library using import or require syntax:

// Auto-detects browser or nodejs.
// Defaults to "node-seal/throws_wasm_node_umd" for NodeJS
// Defaults to "node-seal/throws_wasm_web_umd" for Browsers
// Defaults to "node-seal/throws_wasm_web_es" for Modules
import SEAL from 'node-seal'
const SEAL = require('node-seal')

You may also specify a deep import to target your environment better. This is useful for environments that aren't detected properly or do not support WebAssembly. In addition, there are two separate bundles for throwing on transparent ciphertexts and another for allowing transparent ciphertexts. If you're unsure what you need, start with the build that throws on transparent ciphertexts. This is also the default import that is used.

The deep import link is structured like the following:

node-seal / <throws|allows>_wasm_<node|web|worker>_<umd|es>

// Always Pick a variant which throws on transparent ciphertexts unless you
// have a specific reason to allow the use of transparent ciphertexts.
import SEAL from 'node-seal/throws_wasm_node_umd'

// Or pick a variant which allows transparent ciphertexts (only use this if you know what you're doing)
import SEAL from 'node-seal/allows_wasm_node_umd'

React-Native

React-native does not support WASM libraries; however, it is possible to run a WASM library, including node-seal by using a WebView to load both the library and a simple interface to communicate with on top of the built-in postMessage API. Instead of publicly hosting the web application to be rendered by the WebView, it is possible to bundle the mini web application into a single HTML file (with JS inlined) and load the HTML file directly to the WebView.

Demo

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 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!

Usage

Checkout the basics

Documentation

View the latest docs here

Examples

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.

Changes

For changes in this library, take a look here.

For changes in Microsoft SEAL, take a look at their list of changes.

Benchmarking

Microsoft SEAL has a native benchmark tool that we compile directly to WASM.

  1. npm run seal:build:bench
  2. npm run benchmark

Performance

Microsoft SEAL now comes with a benchmark binary that can be directly compiled to WASM. All numbers are measured in us and are ran on an arm64 system

Test specs:

  • MacBook Pro (14-inch, 2021)
  • MacOS Ventura 13.1 (22C65)
  • Apple M1 Pro (8 performance and 2 efficiency), 32 GB

Versions:

  • Microsoft SEAL v4.1.0
  • Node-seal v5.1.0
  • NodeJS v18.12.1
  • Chrome Version 108.0.5359.124 (Official Build) (arm64)
  • Firefox Version 108.0.1 (64-bit)
  • Safari Version 16.2 (18614.3.7.1.5)
Native (No HEXL)NodeChromeFirefoxSafari
n=1024 / log(q)=27 / KeyGen / Secret/iterations:1066.7143460100.0100.0
n=1024 / log(q)=27 / KeyGen / Public/iterations:1092.718710100.000100
n=1024 / log(q)=27 / BFV / EncryptSecret/iterations:101063601210300600
n=1024 / log(q)=27 / BFV / EncryptPublic/iterations:101484121310400500
n=1024 / log(q)=27 / BFV / Decrypt/iterations:1030.6148160200300
n=1024 / log(q)=27 / BFV / EncodeBatch/iterations:106.1720.520.00.0000.000
n=1024 / log(q)=27 / BFV / DecodeBatch/iterations:108.8724.340.00.0000.000
n=1024 / log(q)=27 / BFV / EvaluateAddCt/iterations:103.4213.810.00.000200
n=1024 / log(q)=27 / BFV / EvaluateAddPt/iterations:109.21160180100.0100.0
n=1024 / log(q)=27 / BFV / EvaluateNegate/iterations:102.222.2010.00.0000.000
n=1024 / log(q)=27 / BFV / EvaluateSubCt/iterations:102.6312.50.0000.0000.000
n=1024 / log(q)=27 / BFV / EvaluateSubPt/iterations:107.20169210200100
n=1024 / log(q)=27 / BFV / EvaluateMulCt/iterations:1027497517409001400
n=1024 / log(q)=27 / BFV / EvaluateMulPt/iterations:1035.0117180100.0200
n=1024 / log(q)=27 / BFV / EvaluateSquare/iterations:102097521300600900
n=1024 / log(q)=27 / BGV / EncryptSecret/iterations:101092131020100.0100
n=1024 / log(q)=27 / BGV / EncryptPublic/iterations:101512821150200200
n=1024 / log(q)=27 / BGV / Decrypt/iterations:1016.364.11100.000200
n=1024 / log(q)=27 / BGV / EncodeBatch/iterations:106.0119.330.00.0000.000
n=1024 / log(q)=27 / BGV / DecodeBatch/iterations:108.5923.940.00.000100
n=1024 / log(q)=27 / BGV / EvaluateNegate/iterations:102.513.050.0000.0000.000
n=1024 / log(q)=27 / BGV / EvaluateNegateInplace/iterations:101.801.840.0000.0000.000
n=1024 / log(q)=27 / BGV / EvaluateAddCt/iterations:103.108.350.0000.0000.000
n=1024 / log(q)=27 / BGV / EvaluateAddCtInplace/iterations:102.5612.510.00.0000.000
n=1024 / log(q)=27 / BGV / EvaluateAddPt/iterations:1013.640.050.00.000100
n=1024 / log(q)=27 / BGV / EvaluateAddPtInplace/iterations:1013.138.150.00.000100.0
n=1024 / log(q)=27 / BGV / EvaluateMulCt/iterations:1010.237.650.00.0000.000
n=1024 / log(q)=27 / BGV / EvaluateMulCtInplace/iterations:108.9536.840.00.0000.000
n=1024 / log(q)=27 / BGV / EvaluateMulPt/iterations:1016.046.950.00.000100
n=1024 / log(q)=27 / BGV / EvaluateMulPtInplace/iterations:1015.745.880.00.000100.0
n=1024 / log(q)=27 / BGV / EvaluateSquare/iterations:107.5528.350.00.0000.000
n=1024 / log(q)=27 / BGV / EvaluateSquareInplace/iterations:107.1527.030.00.0000.000
n=1024 / log(q)=27 / BGV / EvaluateToNTTInplace/iterations:1014.045.150.00.0000.000
n=1024 / log(q)=27 / BGV / EvaluateFromNTTInplace/iterations:1010.737.950.00.0000.000
n=1024 / log(q)=27 / CKKS / EncryptSecret/iterations:1095.81921010100100.0
n=1024 / log(q)=27 / CKKS / EncryptPublic/iterations:101442601170200200
n=1024 / log(q)=27 / CKKS / Decrypt/iterations:104.7412.630.00.000100.0
n=1024 / log(q)=27 / CKKS / EncodeDouble/iterations:1023.265.470.0100400
n=1024 / log(q)=27 / CKKS / DecodeDouble/iterations:1019.949.070.00.000300
n=1024 / log(q)=27 / CKKS / EvaluateAddCt/iterations:103.348.8410.00.0000.000
n=1024 / log(q)=27 / CKKS / EvaluateAddPt/iterations:102.384.4110.000.0000.000
n=1024 / log(q)=27 / CKKS / EvaluateNegate/iterations:102.311.5510.000.0000.000
n=1024 / log(q)=27 / CKKS / EvaluateSubCt/iterations:102.769.5410.000.000100.0
n=1024 / log(q)=27 / CKKS / EvaluateSubPt/iterations:102.224.520.000100.00.000
n=1024 / log(q)=27 / CKKS / EvaluateMulCt/iterations:109.5042.720.00.0000.000
n=1024 / log(q)=27 / CKKS / EvaluateMulPt/iterations:105.1516.220.00.0000.000
n=1024 / log(q)=27 / CKKS / EvaluateSquare/iterations:107.6027.530.00.0000.000
n=1024 / log(q)=27 / UTIL / NTTForward/iterations:1014.746.270.00.0000.000
n=1024 / log(q)=27 / UTIL / NTTInverse/iterations:1011.037.180.0100.00.000
n=1024 / log(q)=0 / UTIL / NTTForwardLowLevel/iterations:108.7522.230.00.000100
n=1024 / log(q)=0 / UTIL / NTTInverseLowLevel/iterations:105.6818.340.00.0000.000
n=1024 / log(q)=0 / UTIL / NTTForwardLowLevelLazy/iterations:105.0718.010.000.0000.000
n=1024 / log(q)=0 / UTIL / NTTInverseLowLevelLazy/iterations:105.2417.930.0100.0100.0
n=2048 / log(q)=54 / KeyGen / Secret/iterations:10105182710100100.0
n=2048 / log(q)=54 / KeyGen / Public/iterations:101503021750200200
n=2048 / log(q)=54 / BFV / EncryptSecret/iterations:101706372310600600
n=2048 / log(q)=54 / BFV / EncryptPublic/iterations:102587782470800800
n=2048 / log(q)=54 / BFV / Decrypt/iterations:1053.7192320200300
n=2048 / log(q)=54 / BFV / EncodeBatch/iterations:1011.743.560.00.0000.000
n=2048 / log(q)=54 / BFV / DecodeBatch/iterations:1017.153.280.0100.0100
n=2048 / log(q)=54 / BFV / EvaluateAddCt/iterations:105.7016.710.00.0000.000
n=2048 / log(q)=54 / BFV / EvaluateAddPt/iterations:1013.9336430400300
n=2048 / log(q)=54 / BFV / EvaluateNegate/iterations:103.412.350.0000.0000.000
n=2048 / log(q)=54 / BFV / EvaluateSubCt/iterations:104.8818.110.000.000100
n=2048 / log(q)=54 / BFV / EvaluateSubPt/iterations:1013.6335440400500
n=2048 / log(q)=54 / BFV / EvaluateMulCt/iterations:105781945348017001500
n=2048 / log(q)=54 / BFV / EvaluateMulPt/iterations:1072.4269370200200
n=2048 / log(q)=54 / BFV / EvaluateSquare/iterations:104271457253012001300
n=2048 / log(q)=54 / BGV / EncryptSecret/iterations:101833401830300300
n=2048 / log(q)=54 / BGV / EncryptPublic/iterations:102805072170300400
n=2048 / log(q)=54 / BGV / Decrypt/iterations:1031.7123190300100
n=2048 / log(q)=54 / BGV / EncodeBatch/iterations:1011.940.560.00.0000.000
n=2048 / log(q)=54 / BGV / DecodeBatch/iterations:1017.150.760.00.000100.0
n=2048 / log(q)=54 / BGV / EvaluateNegate/iterations:103.783.0610.000.0000.000
n=2048 / log(q)=54 / BGV / EvaluateNegateInplace/iterations:102.731.690.0000.0000.000
n=2048 / log(q)=54 / BGV / EvaluateAddCt/iterations:105.5616.840.01000.000
n=2048 / log(q)=54 / BGV / EvaluateAddCtInplace/iterations:104.2417.750.00.0000.000
n=2048 / log(q)=54 / BGV / EvaluateAddPt/iterations:1027.869.11400.000100.0
n=2048 / log(q)=54 / BGV / EvaluateAddPtInplace/iterations:1026.273.2100100.0100.0
n=2048 / log(q)=54 / BGV / EvaluateMulCt/iterations:1017.173.290.01000.000
n=2048 / log(q)=54 / BGV / EvaluateMulCtInplace/iterations:1016.275.8100.0100.0100
n=2048 / log(q)=54 / BGV / EvaluateMulPt/iterations:1030.692.81100.000200
n=2048 / log(q)=54 / BGV / EvaluateMulPtInplace/iterations:1029.788.2110100100
n=2048 / log(q)=54 / BGV / EvaluateSquare/iterations:1013.857.360.00.0000.000
n=2048 / log(q)=54 / BGV / EvaluateSquareInplace/iterations:1012.657.350.0100.00.000
n=2048 / log(q)=54 / BGV / EvaluateToNTTInplace/iterations:1027.396.21301000.000
n=2048 / log(q)=54 / BGV / EvaluateFromNTTInplace/iterations:1020.879.2130100.0100.0
n=2048 / log(q)=54 / CKKS / EncryptSecret/iterations:101522861740200200
n=2048 / log(q)=54 / CKKS / EncryptPublic/iterations:102714652080300300
n=2048 / log(q)=54 / CKKS / Decrypt/iterations:108.3724.340.0100.00.000
n=2048 / log(q)=54 / CKKS / EncodeDouble/iterations:1047.7100150100200
n=2048 / log(q)=54 / CKKS / DecodeDouble/iterations:1040.571.1120100.0200
n=2048 / log(q)=54 / CKKS / EvaluateAddCt/iterations:105.2716.320.00.0000.000
n=2048 / log(q)=54 / CKKS / EvaluateAddPt/iterations:103.648.160.0000.0000.000
n=2048 / log(q)=54 / CKKS / EvaluateNegate/iterations:103.082.310.0000.0000.000
n=2048 / log(q)=54 / CKKS / EvaluateSubCt/iterations:104.6818.820.00.0000.000
n=2048 / log(q)=54 / CKKS / EvaluateSubPt/iterations:103.588.1610.000.0000.000
n=2048 / log(q)=54 / CKKS / EvaluateMulCt/iterations:1017.777.380.0100.0100.0
n=2048 / log(q)=54 / CKKS / EvaluateMulPt/iterations:109.4032.550.0100.00.000
n=2048 / log(q)=54 / CKKS / EvaluateSquare/iterations:1013.553.760.01000.000
n=2048 / log(q)=54 / UTIL / NTTForward/iterations:1029.697.1150100.00.000
n=2048 / log(q)=54 / UTIL / NTTInverse/iterations:1022.583.91200.000100.0
n=2048 / log(q)=0 / UTIL / NTTForwardLowLevel/iterations:1015.349.570.01000.000
n=2048 / log(q)=0 / UTIL / NTTInverseLowLevel/iterations:1011.839.570.0100.0100.0
n=2048 / log(q)=0 / UTIL / NTTForwardLowLevelLazy/iterations:1010.039.660.00.0000.000
n=2048 / log(q)=0 / UTIL / NTTInverseLowLevelLazy/iterations:1010.838.770.00.000100.0
n=4096 / log(q)=109 / KeyGen / Secret/iterations:102685341720300400
n=4096 / log(q)=109 / KeyGen / Public/iterations:1054510766400700800
n=4096 / log(q)=109 / KeyGen / Relin/iterations:10110220731279015001600
n=4096 / log(q)=109 / KeyGen / Galois/iterations:10107821501282016001600
n=4096 / log(q)=109 / BFV / EncryptSecret/iterations:104771619590015001400
n=4096 / log(q)=109 / BFV / EncryptPublic/iterations:107782444620020002200
n=4096 / log(q)=109 / BFV / Decrypt/iterations:101786301070500500
n=4096 / log(q)=109 / BFV / EncodeBatch/iterations:1024.386.41500.0000.000
n=4096 / log(q)=109 / BFV / DecodeBatch/iterations:1033.5106160100100
n=4096 / log(q)=109 / BFV / EvaluateAddCt/iterations:1016.166.180.00.0000.000
n=4096 / log(q)=109 / BFV / EvaluateAddPt/iterations:1039.2702890700600
n=4096 / log(q)=109 / BFV / EvaluateNegate/iterations:1011.28.470.000100.00.000
n=4096 / log(q)=109 / BFV / EvaluateSubCt/iterations:1012.169.970.00.0000.000
n=4096 / log(q)=109 / BFV / EvaluateSubPt/iterations:1037.0698900800800
n=4096 / log(q)=109 / BFV / EvaluateMulCt/iterations:10184268411143058005100
n=4096 / log(q)=109 / BFV / EvaluateMulPt/iterations:1028010151480700600
n=4096 / log(q)=109 / BFV / EvaluateSquare/iterations:1013594941839042004500
n=4096 / log(q)=109 / BFV / EvaluateModSwitchInplace/iterations:1026.91171900.000100
n=4096 / log(q)=109 / BFV / EvaluateRelinInplace/iterations:103891518206011002100
n=4096 / log(q)=109 / BFV / EvaluateRotateRows/iterations:103971385206013001400
n=4096 / log(q)=109 / BFV / EvaluateRotateCols/iterations:103991396209012001100
n=4096 / log(q)=109 / BGV / EncryptSecret/iterations:1050610175150800700
n=4096 / log(q)=109 / BGV / EncryptPublic/iterations:1010092796681018002200
n=4096 / log(q)=109 / BGV / Decrypt/iterations:10104400660300200
n=4096 / log(q)=109 / BGV / EncodeBatch/iterations:1025.086.31401000.000
n=4096 / log(q)=109 / BGV / DecodeBatch/iterations:1033.8106140200100.0
n=4096 / log(q)=109 / BGV / EvaluateNegate/iterations:1010.612.020.00.0000.000
n=4096 / log(q)=109 / BGV / EvaluateNegateInplace/iterations:109.215.940.0000.0000.000
n=4096 / log(q)=109 / BGV / EvaluateAddCt/iterations:1014.976.91000.0000.000
n=4096 / log(q)=109 / BGV / EvaluateAddCtInplace/iterations:1011.169.01100.0000.000
n=4096 / log(q)=109 / BGV / EvaluateAddPt/iterations:1092.0263390200200
n=4096 / log(q)=109 / BGV / EvaluateAddPtInplace/iterations:1089.6260340200300
n=4096 / log(q)=109 / BGV / EvaluateMulCt/iterations:1063.62713103000.000
n=4096 / log(q)=109 / BGV / EvaluateMulCtInplace/iterations:1062.6268330300500
n=4096 / log(q)=109 / BGV / EvaluateMulPt/iterations:10120347470100.0300
n=4096 / log(q)=109 / BGV / EvaluateMulPtInplace/iterations:10115351440300300
n=4096 / log(q)=109 / BGV / EvaluateSquare/iterations:1053.5216270200200
n=4096 / log(q)=109 / BGV / EvaluateSquareInplace/iterations:1052.3216250200200
n=4096 / log(q)=109 / BGV / EvaluateModSwitchInplace/iterations:10141551840500300
n=4096 / log(q)=109 / BGV / EvaluateRelinInplace/iterations:104651625241012001200
n=4096 / log(q)=109 / BGV / EvaluateRotateRows/iterations:104371620237013001100
n=4096 / log(q)=109 / BGV / EvaluateRotateRowsInplace/iterations:104461601247012001000
n=4096 / log(q)=109 / BGV / EvaluateRotateCols/iterations:104631613241013001100
n=4096 / log(q)=109 / BGV / EvaluateRotateColsInplace/iterations:104521607241012001200
n=4096 / log(q)=109 / BGV / EvaluateToNTTInplace/iterations:10111398620200200
n=4096 / log(q)=109 / BGV / EvaluateFromNTTInplace/iterations:1085.7336510200200
n=4096 / log(q)=109 / CKKS / EncryptSecret/iterations:104258074810700600
n=4096 / log(q)=109 / CKKS / EncryptPublic/iterations:109032329629018001700
n=4096 / log(q)=109 / CKKS / Decrypt/iterations:1026.094.31300.000200
n=4096 / log(q)=109 / CKKS / EncodeDouble/iterations:10129311470300200
n=4096 / log(q)=109 / CKKS / DecodeDouble/iterations:10200417640400600
n=4096 / log(q)=109 / CKKS / EvaluateAddCt/iterations:1014.763.790.00.0000.000
n=4096 / log(q)=109 / CKKS / EvaluateAddPt/iterations:108.3231.750.00.0000.000
n=4096 / log(q)=109 / CKKS / EvaluateNegate/iterations:109.918.480.0000.0000.000
n=4096 / log(q)=109 / CKKS / EvaluateSubCt/iterations:1012.668.61000.0000.000
n=4096 / log(q)=109 / CKKS / EvaluateSubPt/iterations:107.7229.940.00.0000.000
n=4096 / log(q)=109 / CKKS / EvaluateMulCt/iterations:1066.3272320300300
n=4096 / log(q)=109 / CKKS / EvaluateMulPt/iterations:1033.71221400.000100
n=4096 / log(q)=109 / CKKS / EvaluateSquare/iterations:1052.1210250200200
n=4096 / log(q)=109 / CKKS / EvaluateRescaleInplace/iterations:10101386590300300
n=4096 / log(q)=109 / CKKS / EvaluateRelinInplace/iterations:103861403216012001000
n=4096 / log(q)=109 / CKKS / EvaluateRotate/iterations:103861373206010001000
n=4096 / log(q)=109 / UTIL / NTTForward/iterations:10117398560300200
n=4096 / log(q)=109 / UTIL / NTTInverse/iterations:1090.9342470300200
n=4096 / log(q)=0 / UTIL / NTTForwardLowLevel/iterations:1032.598.7130100.00.000
n=4096 / log(q)=0 / UTIL / NTTInverseLowLevel/iterations:1023.485.2110200100
n=4096 / log(q)=0 / UTIL / NTTForwardLowLevelLazy/iterations:1019.983.7150100.0100.0
n=4096 / log(q)=0 / UTIL / NTTInverseLowLevelLazy/iterations:1024.282.91500.000100
n=8192 / log(q)=218 / KeyGen / Secret/iterations:106611453400010001000
n=8192 / log(q)=218 / KeyGen / Public/iterations:10152828671872023002400
n=8192 / log(q)=218 / KeyGen / Relin/iterations:106168114887505094009700
n=8192 / log(q)=218 / KeyGen / Galois/iterations:106159115667585094009700
n=8192 / log(q)=218 / BFV / EncryptSecret/iterations:10152444931867041004000
n=8192 / log(q)=218 / BFV / EncryptPublic/iterations:10206269141536056005000
n=8192 / log(q)=218 / BFV / Decrypt/iterations:106482380398019001800
n=8192 / log(q)=218 / BFV / EncodeBatch/iterations:1052.2186270200100.0
n=8192 / log(q)=218 / BFV / DecodeBatch/iterations:1068.8229330200200
n=8192 / log(q)=218 / BFV / EvaluateAddCt/iterations:1060.82684000.0000.000
n=8192 / log(q)=218 / BFV / EvaluateAddPt/iterations:101101631218016002000
n=8192 / log(q)=218 / BFV / EvaluateNegate/iterations:1041.533.570.00.0000.000
n=8192 / log(q)=218 / BFV / EvaluateSubCt/iterations:1045.72773700.000200
n=8192 / log(q)=218 / BFV / EvaluateSubPt/iterations:101031650218020001000
n=8192 / log(q)=218 / BFV / EvaluateMulCt/iterations:10682726875505702330019700
n=8192 / log(q)=218 / BFV / EvaluateMulPt/iterations:1011864344631033002900
n=8192 / log(q)=218 / BFV / EvaluateSquare/iterations:10502119686394501730016300
n=8192 / log(q)=218 / BFV / EvaluateModSwitchInplace/iterations:101364807900.000200
n=8192 / log(q)=218 / BFV / EvaluateRelinInplace/iterations:10192071491089057004600
n=8192 / log(q)=218 / BFV / EvaluateRotateRows/iterations:10199570611062058005000
n=8192 / log(q)=218 / BFV / EvaluateRotateCols/iterations:10197370641063059004900
n=8192 / log(q)=218 / BGV / EncryptSecret/iterations:10166434101705026002600
n=8192 / log(q)=218 / BGV / EncryptPublic/iterations:10289987691828065005700
n=8192 / log(q)=218 / BGV / Decrypt/iterations:103991416228012001100
n=8192 / log(q)=218 / BGV / EncodeBatch/iterations:1052.8186290200100.0
n=8192 / log(q)=218 / BGV / DecodeBatch/iterations:1070.4224320100.00.000
n=8192 / log(q)=218 / BGV / EvaluateNegate/iterations:1045.043.380.0100.0100.0
n=8192 / log(q)=218 / BGV / EvaluateNegateInplace/iterations:1033.722.940.00.0000.000
n=8192 / log(q)=218 / BGV / EvaluateAddCt/iterations:1054.12994200.000200
n=8192 / log(q)=218 / BGV / EvaluateAddCtInplace/iterations:1044.7279350100.00.000
n=8192 / log(q)=218 / BGV / EvaluateAddPt/iterations:103791100158010001000
n=8192 / log(q)=218 / BGV / EvaluateAddPtInplace/iterations:10368108815501000300
n=8192 / log(q)=218 / BGV / EvaluateMulCt/iterations:10265108512808001000
n=8192 / log(q)=218 / BGV / EvaluateMulCtInplace/iterations:10246107312801100800
n=8192 / log(q)=218 / BGV / EvaluateMulPt/iterations:104661420196011001100
n=8192 / log(q)=218 / BGV / EvaluateMulPtInplace/iterations:104391431193011001000
n=8192 / log(q)=218 / BGV / EvaluateSquare/iterations:10214869106010001000
n=8192 / log(q)=218 / BGV / EvaluateSquareInplace/iterations:1019285910501000700
n=8192 / log(q)=218 / BGV / EvaluateModSwitchInplace/iterations:106132321338014001300
n=8192 / log(q)=218 / BGV / EvaluateRelinInplace/iterations:10218880971183060005500
n=8192 / log(q)=218 / BGV / EvaluateRotateRows/iterations:10219380561174062005400
n=8192 / log(q)=218 / BGV / EvaluateRotateRowsInplace/iterations:10217579421173063005500
n=8192 / log(q)=218 / BGV / EvaluateRotateCols/iterations:10220379721176061005300
n=8192 / log(q)=218 / BGV / EvaluateRotateColsInplace/iterations:10220179411171067006000
n=8192 / log(q)=218 / BGV / EvaluateToNTTInplace/iterations:104801713251011001000
n=8192 / log(q)=218 / BGV / EvaluateFromNTTInplace/iterations:10382146121301200800
n=8192 / log(q)=218 / CKKS / EncryptSecret/iterations:10132224881561019002000
n=8192 / log(q)=218 / CKKS / EncryptPublic/iterations:10248372841609052004700
n=8192 / log(q)=218 / CKKS / Decrypt/iterations:1099.4377530400300
n=8192 / log(q)=218 / CKKS / EncodeDouble/iterations:1041311291660800800
n=8192 / log(q)=218 / CKKS / DecodeDouble/iterations:108471789285020001600
n=8192 / log(q)=218 / CKKS / EvaluateAddCt/iterations:1054.12523900.000100.0
n=8192 / log(q)=218 / CKKS / EvaluateAddPt/iterations:1030.11281900.0000.000
n=8192 / log(q)=218 / CKKS / EvaluateNegate/iterations:1037.830.550.00.0000.000
n=8192 / log(q)=218 / CKKS / EvaluateSubCt/iterations:1047.1274360100.0100
n=8192 / log(q)=218 / CKKS / EvaluateSubPt/iterations:1026.81171902000.000
n=8192 / log(q)=218 / CKKS / EvaluateMulCt/iterations:102651093130011001000
n=8192 / log(q)=218 / CKKS / EvaluateMulPt/iterations:101344885502001000
n=8192 / log(q)=218 / CKKS / EvaluateSquare/iterations:101908431040800500
n=8192 / log(q)=218 / CKKS / EvaluateRescaleInplace/iterations:104441694256014001200
n=8192 / log(q)=218 / CKKS / EvaluateRelinInplace/iterations:10193671191067053004800
n=8192 / log(q)=218 / CKKS / EvaluateRotate/iterations:10199970971060055004800
n=8192 / log(q)=218 / UTIL / NTTForward/iterations:104801716256013001000
n=8192 / log(q)=218 / UTIL / NTTInverse/iterations:103821461215011001000
n=8192 / log(q)=0 / UTIL / NTTForwardLowLevel/iterations:1062.8214330200200
n=8192 / log(q)=0 / UTIL / NTTInverseLowLevel/iterations:1048.7181260100200
n=8192 / log(q)=0 / UTIL / NTTForwardLowLevelLazy/iterations:1044.0181260200100
n=8192 / log(q)=0 / UTIL / NTTInverseLowLevelLazy/iterations:1047.31782700.0000.000
n=16384 / log(q)=438 / KeyGen / Secret/iterations:10193050041094036003100
n=16384 / log(q)=438 / KeyGen / Public/iterations:10525098526298082008300
n=16384 / log(q)=438 / KeyGen / Relin/iterations:1041363797595054706550066500
n=16384 / log(q)=438 / KeyGen / Galois/iterations:1041180791145130606520066100
n=16384 / log(q)=438 / BFV / EncryptSecret/iterations:10558915454662701340012600
n=16384 / log(q)=438 / BFV / EncryptPublic/iterations:10643522588440501730015200
n=16384 / log(q)=438 / BFV / Decrypt/iterations:10258495241525076006600
n=16384 / log(q)=438 / BFV / EncodeBatch/iterations:10114404590200200
n=16384 / log(q)=438 / BFV / DecodeBatch/iterations:10147477710400400
n=16384 / log(q)=438 / BFV / EvaluateAddCt/iterations:1027810321610300300
n=16384 / log(q)=438 / BFV / EvaluateAddPt/iterations:104034055529036003200
n=16384 / log(q)=438 / BFV / EvaluateNegate/iterations:10167125220200100
n=16384 / log(q)=438 / BFV / EvaluateSubCt/iterations:10199110114202000.000
n=16384 / log(q)=438 / BFV / EvaluateSubPt/iterations:103734123530039003200
n=16384 / log(q)=438 / BFV / EvaluateMulCt/iterations:102981711773622742010240086600
n=16384 / log(q)=438 / BFV / EvaluateMulPt/iterations:10498318316265001370011700
n=16384 / log(q)=438 / BFV / EvaluateSquare/iterations:1022176867921709207740069900
n=16384 / log(q)=438 / BFV / EvaluateModSwitchInplace/iterations:105962209330014001000
n=16384 / log(q)=438 / BFV / EvaluateRelinInplace/iterations:101194445319659903470029100
n=16384 / log(q)=438 / BFV / EvaluateRotateRows/iterations:101210844093657303480029600
n=16384 / log(q)=438 / BFV / EvaluateRotateCols/iterations:101197943902667203470029400
n=16384 / log(q)=438 / BGV / EncryptSecret/iterations:10613413390636601050010000
n=16384 / log(q)=438 / BGV / EncryptPublic/iterations:10996532783589402340020300
n=16384 / log(q)=438 / BGV / Decrypt/iterations:1017155731912048004100
n=16384 / log(q)=438 / BGV / EncodeBatch/iterations:10107399620300200
n=16384 / log(q)=438 / BGV / DecodeBatch/iterations:10143474740200300
n=16384 / log(q)=438 / BGV / EvaluateNegate/iterations:10185169360300100.0
n=16384 / log(q)=438 / BGV / EvaluateNegateInplace/iterations:1014390.1200100100.0
n=16384 / log(q)=438 / BGV / EvaluateAddCt/iterations:1023411961610300400
n=16384 / log(q)=438 / BGV / EvaluateAddCtInplace/iterations:1029111081430200600
n=16384 / log(q)=438 / BGV / EvaluateAddPt/iterations:1015594515676027002400
n=16384 / log(q)=438 / BGV / EvaluateAddPtInplace/iterations:1015344480693030002700
n=16384 / log(q)=438 / BGV / EvaluateMulCt/iterations:1010174357526041003900
n=16384 / log(q)=438 / BGV / EvaluateMulCtInplace/iterations:109784299519041003800
n=16384 / log(q)=438 / BGV / EvaluateMulPt/iterations:1019195894823048004400
n=16384 / log(q)=438 / BGV / EvaluateMulPtInplace/iterations:1019205859821049004400
n=16384 / log(q)=438 / BGV / EvaluateSquare/iterations:108263473424030002900
n=16384 / log(q)=438 / BGV / EvaluateSquareInplace/iterations:108103431415031002900
n=16384 / log(q)=438 / BGV / EvaluateModSwitchInplace/iterations:10274597591458072006200
n=16384 / log(q)=438 / BGV / EvaluateRelinInplace/iterations:101261247355712003670031200
n=16384 / log(q)=438 / BGV / EvaluateRotateRows/iterations:101293647165700903670031300
n=16384 / log(q)=438 / BGV / EvaluateRotateRowsInplace/iterations:101276846966709403660031300
n=16384 / log(q)=438 / BGV / EvaluateRotateCols/iterations:101285347131706403630031300
n=16384 / log(q)=438 / BGV / EvaluateRotateColsInplace/iterations:101281346947707203660031100
n=16384 / log(q)=438 / BGV / EvaluateToNTTInplace/iterations:10205672611070051004100
n=16384 / log(q)=438 / BGV / EvaluateFromNTTInplace/iterations:1016396253941048004000
n=16384 / log(q)=438 / CKKS / EncryptSecret/iterations:10473191465772075007400
n=16384 / log(q)=438 / CKKS / EncryptPublic/iterations:10821125798493701830016000
n=16384 / log(q)=438 / CKKS / Decrypt/iterations:103921500199013001100
n=16384 / log(q)=438 / CKKS / EncodeDouble/iterations:1014444363651032002800
n=16384 / log(q)=438 / CKKS / DecodeDouble/iterations:10430589081474091008600
n=16384 / log(q)=438 / CKKS / EvaluateAddCt/iterations:1022410021650200200
n=16384 / log(q)=438 / CKKS / EvaluateAddPt/iterations:101265066600.000200
n=16384 / log(q)=438 / CKKS / EvaluateNegate/iterations:101651202103000.000
n=16384 / log(q)=438 / CKKS / EvaluateSubCt/iterations:1019311041390100.0200
n=16384 / log(q)=438 / CKKS / EvaluateSubPt/iterations:101144686300.000100.0
n=16384 / log(q)=438 / CKKS / EvaluateMulCt/iterations:1010354355519040003900
n=16384 / log(q)=438 / CKKS / EvaluateMulPt/iterations:105121948224021001800
n=16384 / log(q)=438 / CKKS / EvaluateSquare/iterations:107683374406032003000
n=16384 / log(q)=438 / CKKS / EvaluateRescaleInplace/iterations:10202770301090054004400
n=16384 / log(q)=438 / CKKS / EvaluateRelinInplace/iterations:101239143962662803430029100
n=16384 / log(q)=438 / CKKS / EvaluateRotate/iterations:101252843821659303450029200
n=16384 / log(q)=438 / UTIL / NTTForward/iterations:10210172771090048004300
n=16384 / log(q)=438 / UTIL / NTTInverse/iterations:1017006285936047004000
n=16384 / log(q)=0 / UTIL / NTTForwardLowLevel/iterations:10134454670300300
n=16384 / log(q)=0 / UTIL / NTTInverseLowLevel/iterations:10110389550200300
n=16384 / log(q)=0 / UTIL / NTTForwardLowLevelLazy/iterations:1094.3387580100200
n=16384 / log(q)=0 / UTIL / NTTInverseLowLevelLazy/iterations:10102387590300200
n=32768 / log(q)=881 / KeyGen / Secret/iterations:10779418226337301360011400
n=32768 / log(q)=881 / KeyGen / Public/iterations:1019455359592212003000030400
n=32768 / log(q)=881 / KeyGen / Relin/iterations:102901375351913305720454400459800
n=32768 / log(q)=881 / KeyGen / Galois/iterations:102845055321673285190449200454100
n=32768 / log(q)=881 / BFV / EncryptSecret/iterations:1022457539152334404570043300
n=32768 / log(q)=881 / BFV / EncryptPublic/iterations:1027071778041320306110053300
n=32768 / log(q)=881 / BFV / Decrypt/iterations:10990636006567102850023700
n=32768 / log(q)=881 / BFV / EncodeBatch/iterations:102568591350600600
n=32768 / log(q)=881 / BFV / DecodeBatch/iterations:10321100314901100100.0
n=32768 / log(q)=881 / BFV / EvaluateAddCt/iterations:109933899600010001100
n=32768 / log(q)=881 / BFV / EvaluateAddPt/iterations:102362105171354085008000
n=32768 / log(q)=881 / BFV / EvaluateNegate/iterations:10629465920600500
n=32768 / log(q)=881 / BFV / EvaluateSubCt/iterations:1076841845340900800
n=32768 / log(q)=881 / BFV / EvaluateSubPt/iterations:102355107611364086007900
n=32768 / log(q)=881 / BFV / EvaluateMulCt/iterations:101379385318341078700463000383100
n=32768 / log(q)=881 / BFV / EvaluateMulPt/iterations:1019996723011060505480045900
n=32768 / log(q)=881 / BFV / EvaluateSquare/iterations:10103629399673824100353300306200
n=32768 / log(q)=881 / BFV / EvaluateModSwitchInplace/iterations:102262101091429052005000
n=32768 / log(q)=881 / BFV / EvaluateRelinInplace/iterations:1074559277711414450214000181800
n=32768 / log(q)=881 / BFV / EvaluateRotateRows/iterations:1075499276267414860216200183100
n=32768 / log(q)=881 / BFV / EvaluateRotateCols/iterations:1075629276612415690216200183000
n=32768 / log(q)=881 / BGV / EncryptSecret/iterations:1023877511902313004010039200
n=32768 / log(q)=881 / BGV / EncryptPublic/iterations:10394091213291986708880077400
n=32768 / log(q)=881 / BGV / Decrypt/iterations:10678521804336901750015000
n=32768 / log(q)=881 / BGV / EncodeBatch/iterations:102568621330900700
n=32768 / log(q)=881 / BGV / DecodeBatch/iterations:1031710011530900500
n=32768 / log(q)=881 / BGV / EvaluateNegate/iterations:10737655132010001000
n=32768 / log(q)=881 / BGV / EvaluateNegateInplace/iterations:10799336760600500
n=32768 / log(q)=881 / BGV / EvaluateAddCt/iterations:10905378559309001000
n=32768 / log(q)=881 / BGV / EvaluateAddCtInplace/iterations:1062541505370400800
n=32768 / log(q)=881 / BGV / EvaluateAddPt/iterations:10603617338262901180010000
n=32768 / log(q)=881 / BGV / EvaluateAddPtInplace/iterations:1058841721126150116009800
n=32768 / log(q)=881 / BGV / EvaluateMulCt/iterations:10378716312194801570014400
n=32768 / log(q)=881 / BGV / EvaluateMulCtInplace/iterations:10353016058190101560014100
n=32768 / log(q)=881 / BGV / EvaluateMulPt/iterations:10740422868318701890016700
n=32768 / log(q)=881 / BGV / EvaluateMulPtInplace/iterations:10725322829321201900016500
n=32768 / log(q)=881 / BGV / EvaluateSquare/iterations:10313513104160601200011600
n=32768 / log(q)=881 / BGV / EvaluateSquareInplace/iterations:10304812740154901190011000
n=32768 / log(q)=881 / BGV / EvaluateModSwitchInplace/iterations:101083238685580502810024600
n=32768 / log(q)=881 / BGV / EvaluateRelinInplace/iterations:1077860288197433160221400187800
n=32768 / log(q)=881 / BGV / EvaluateRotateRows/iterations:1078629287167431860221500188600
n=32768 / log(q)=881 / BGV / EvaluateRotateRowsInplace/iterations:1078221286311432220221100188500
n=32768 / log(q)=881 / BGV / EvaluateRotateCols/iterations:1078445287150433080221800188600
n=32768 / log(q)=881 / BGV / EvaluateRotateColsInplace/iterations:1078351287128432190221000187800
n=32768 / log(q)=881 / BGV / EvaluateToNTTInplace/iterations:10813728871430201940016200
n=32768 / log(q)=881 / BGV / EvaluateFromNTTInplace/iterations:10665625156374701930015400
n=32768 / log(q)=881 / CKKS / EncryptSecret/iterations:1018153349822068902840028400
n=32768 / log(q)=881 / CKKS / EncryptPublic/iterations:1032572977121644107130061600
n=32768 / log(q)=881 / CKKS / Decrypt/iterations:1014945668754044004000
n=32768 / log(q)=881 / CKKS / EncodeDouble/iterations:10676916548246101190010200
n=32768 / log(q)=881 / CKKS / DecodeDouble/iterations:102191845509752204750047500
n=32768 / log(q)=881 / CKKS / EvaluateAddCt/iterations:1091237826020900900
n=32768 / log(q)=881 / CKKS / EvaluateAddPt/iterations:1050918752570200700
n=32768 / log(q)=881 / CKKS / EvaluateNegate/iterations:10645458890800500
n=32768 / log(q)=881 / CKKS / EvaluateSubCt/iterations:1077741925420800900
n=32768 / log(q)=881 / CKKS / EvaluateSubPt/iterations:1044817962450200100
n=32768 / log(q)=881 / CKKS / EvaluateMulCt/iterations:10379016369194001590014400
n=32768 / log(q)=881 / CKKS / EvaluateMulPt/iterations:1019067290842076007100
n=32768 / log(q)=881 / CKKS / EvaluateSquare/iterations:10293112665150401180010900
n=32768 / log(q)=881 / CKKS / EvaluateRescaleInplace/iterations:10745227233418402030017200
n=32768 / log(q)=881 / CKKS / EvaluateRelinInplace/iterations:1074785276801416320214300181300
n=32768 / log(q)=881 / CKKS / EvaluateRotate/iterations:1075781276715415740215100182400
n=32768 / log(q)=881 / UTIL / NTTForward/iterations:10829428889429201960016300
n=32768 / log(q)=881 / UTIL / NTTInverse/iterations:10684225324379701940015600
n=32768 / log(q)=0 / UTIL / NTTForwardLowLevel/iterations:102859611460800600
n=32768 / log(q)=0 / UTIL / NTTInverseLowLevel/iterations:102278321250700700
n=32768 / log(q)=0 / UTIL / NTTForwardLowLevelLazy/iterations:102068221310700400
n=32768 / log(q)=0 / UTIL / NTTInverseLowLevelLazy/iterations:102168171260700400

Caveats

Conversion from C++ to Web Assembly has some limitations:

  • ±2^53 bit numbers: JavaScript uses 2^53 numbers (not true 64 bit). This means we lose some precision after cryptographic operations are computed in WASM and we want to send the results to JS for consumption (across the WASM <> JS boundary). If you're using the CKKS scheme, you need to keep this in mind. BFV users will inherently adhere to these limitations due to the Int32Array/Uint32Array TypedArrays. Recently, BFV users now have support for BigInt64Array/BigUint64Array TypedArrays but at a significant encode/decode penalty - encyption/evaluation/decryption performance is the same.

  • 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 polyModulusDegreess above 16384. 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 when using the default zstd compression. User's who are experiencing OOM exceptions when saving GaloisKeys should try specifying a compression override such as none or the less performant zlib. Ex: galoisKeys.save(seal.ComprModeType.zlib)

  • 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()

Contributing

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.

License

node-seal is MIT licensed.

FOSSA Status

5.1.4

6 months ago

5.1.3

11 months ago

5.1.2

1 year ago

5.1.1

2 years ago

5.0.1

2 years ago

5.1.0

2 years ago

5.0.0

3 years ago

4.6.4

3 years ago

4.6.3

3 years ago

4.6.2

3 years ago

4.6.1

3 years ago

4.6.0

3 years ago

4.5.7

3 years ago

4.5.6

3 years ago

4.5.5

4 years ago

4.5.4

4 years ago

4.5.3

4 years ago

4.5.2

4 years ago

4.5.1

4 years ago

4.5.0

4 years ago

4.4.2

4 years ago

4.4.1

4 years ago

4.4.0

4 years ago

4.3.10

4 years ago

4.3.9

4 years ago

4.3.8

4 years ago

4.3.7

4 years ago

4.3.6

4 years ago

4.3.5

4 years ago

4.3.4

4 years ago

4.3.3

4 years ago

4.3.2

4 years ago

4.3.1

5 years ago

4.3.0

5 years ago

4.2.4

5 years ago

4.2.3

5 years ago

4.2.2

5 years ago

4.2.1

5 years ago

4.2.0

5 years ago

4.1.5

5 years ago

4.1.4

5 years ago

4.1.3

5 years ago

4.1.2

5 years ago

4.1.1

5 years ago

4.1.0

5 years ago

4.0.3

5 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.2.4

5 years ago

3.2.3

5 years ago

3.2.2

5 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.2.1

5 years ago

2.2.2

5 years ago

2.2.0

5 years ago

2.1.14

5 years ago

2.1.13

5 years ago

2.1.12

5 years ago

2.1.11

5 years ago

2.1.10

5 years ago

2.1.8

5 years ago

2.1.7

5 years ago

2.1.6

5 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago