npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

palisade-crypto

v0.0.1

Published

JS bindings for Palisade Homomorphic Encryption Library

Downloads

10

Readme

General information

palisade-wasm is the official web-assembly port of the PALISADE homomorphic library. palisade-wasm supports all homomorphic encryption schemes supported by PALISADE and exposes an API similar to the C++ API for PALISADE.

All versions of PALISADE starting with v1.11.3 are supported.

palisade-wasm is licensed under the BSD-3 license.

Notes specific to palisade-wasm

  • The palisade-wasm port is somewhat slower than the C++ version of PALISADE due to a normal slowdown incurred in web assembly builds (typically 2x) and additional slow-down due to the use of 64-bit arithmetic in PALISADE (64-bit arithmetic is emulated in WASM).
  • We optimized palisade-wasm for BGVrns, CKKS, and FHEW schemes. The users should typically expect a slowdown of 2x-3x as compared to clang builds and about 4x-5x as compared to gcc builds.
  • We did not optimize BFVrns and BFVrnsB. So a more significant slowdown is expected for some operations in these schemes, specifically the homomorphic multplication. We recommend using BGVrns instead of BFVrns and BFVrnsB in use cases where homomorphic computations using palisade-wasm need to be performed. In scenarios where only client operations, i.e., key generation, encryption, and decryption, are needed, either scheme can be used.
  • Web assembly running environment is typically limited to 4GB of RAM.
  • palisade-wasm does not currently support multi-threading.

Examples

palisade-wasm comes with the following examples, which are the JS versions of selected C++ PALISADE examples:

  • boolean.js: shows an example of Boolean circuit evaluation using FHEW (in the TFHE/GINX mode)
  • boolean_serial_binary.js: shows an example with serialization/deserialization of Boolean circuit evaluation using FHEW (in the TFHE/GINX mode)
  • pre_buffer.js: demonstrates use of PALISADE for encryption, proxy re-encryption and decryption of packed vector of binary data
  • simple_integer.js: simple example showing homomorphic additions, multiplications, and rotations for vectors of integers using BFVrns
  • simple_integer_bgvrns.js: simple example showing homomorphic additions, multiplications, and rotations for vectors of integers using BGVrns
  • simple_integer_serial_buffer.js: simple example showing typical serialization/deserialization calls for a prototype computing homomorphic additions, multiplications, and rotations for vectors of integers using BFVrns
  • simple_real_numbers.js: simple example showing homomorphic additions, multiplications, and rotations for vectors of real numbers using CKKS
  • threshold_fhe.js: shows several examples of threshold FHE in BGVrns, BFVrns, and CKKS

Build instructions from source

  1. Install emscripten using the instructions at https://emscripten.org/docs/getting_started/downloads.html.
  2. Install NodeJs if not already installed.
  3. Clone PALISADE either from https://gitlab.com/palisade/palisade-development or https://gitlab.com/palisade/palisade-release.
  4. Cd to the PALISADE folder (either palisade-development or palisade-release) and create embuild directory.
  5. Run
export PREFIX=~/install/location
mkdir embuild
cd embuild
emcmake cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX}
emmake make -jN

Where N is number of cores available. to do the cmake configuration. Here, ~/install/location can be replaced with any empty directory at the desired location where palisade binaries should be installed.

  1. Run
emmake make install

to install the binaries in the desired location.

To include the unit tests, examples, or benchmarks, the corresponding cmake flags can be set to "ON" instead of "OFF".

  1. Clone the palisade-wasm repository and cd to palisade-wasm.

  2. Run the following commands to build the NodeJS bindings.

mkdir build
cd build
emcmake cmake .. -DPalisade_DIR=${PREFIX}/lib/Palisade
emmake make

This should install emscripten libraries in palisade-wasm/lib directory.

  1. Now run the examples in the following directories using nodejs
  • examples/js/binfhe/
  • examples/js/pke/

Running web-assembly unit tests

Compile PALISADE in the embuild directory using the following CMake flags

emcmake cmake .. -DBUILD_UNITTESTS=ON -DCMAKE_INSTALL_PREFIX=~/install/location

Run unit tests using nodejs:

nodejs unittest/binfhe_tests.js
nodejs unittest/pke_tests.js

Running web-assembly benchmarks

Compile PALISADE in the embuild directory using the following CMake flags

emcmake cmake .. -DBUILD_BENCHMARKS=ON -DCMAKE_INSTALL_PREFIX=~/install/location

Run benchmarks using nodejs, e.g.,

nodejs benchmark/lib-benchmark.js

Typescript Development

For usage examples, we would like to test our code using the same import syntax as any other user. To achieve this, run npm link followed by npm link palisade-crypto.

Building

To build the distributed package, run npm run build_package followed by npm pack