Skip to content

Node.js port of seal C++ package relased by microsft and containing homomorfic encryption primitives

Notifications You must be signed in to change notification settings

PrivateSky/sealjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Branches:

  • master: C++ addon for NodeJS, using node-addon-api - the OOP version of N-API
  • seal-wasm-external: JavaScript (glue code) and WebAssembly files, using Emscripten
  • seal-wasm-embedded: JavaScript with embedded WebAssembly, using Emscripten

sealjs

Node.js port of SEAL C++ package released by Microsoft and containing homomorphic encryption primitives

Building and running

Compile and build:

$ npm install

Then run a JS sample similar to example_bfv_basics_i() from SEAL Examples :

$ npm run demo

or see our API in action:

$ npm start

How to use

var seal = require('bindings')('nodeseal');

1. Create the homomorphic encryption context

The next statements create 4 contexts having the same encryption parameters (the scheme is 'BFV' by default):

var hc1 = seal.generateHomomorficContext();
var hc2 = new seal.HomomorphicContext();
var hc3 = new seal.HomomorphicContext(2048, 'coeff_modulus_128', 1<<8);
var hc4 = new seal.HomomorphicContext( hc3.getEncryptionParameters() );

The three parameters for hc3 are:

  • poly_modulus_degree: Number - one of the values: 1024, 2048, 4096, 8192, 16384, or 32768
  • coeff_modulus: String - one of the values: "coeff_modulus_128", "coeff_modulus_192", or "coeff_modulus_256"
  • plain_modulus: UINT64

2. Invoke various methods of a HomomorphicContext object

GET/SET:

  • getEncryptionParameters() //no setter; use HomomorphicContext(parms) instead
  • getPublicKey()
  • setPublicKey()
  • getSecretKey()
  • setSecretKey()

INT32 <=> Ciphertext converters:

  • encrypt()
  • decrypt()

Homomorphic arithmetic:

  • negate()
  • add()
  • sub()
  • multiply()
  • square()

Notes

The SEAL's EncryptionParameters, PublicKey, SecretKey and Ciphertext objects are serialized to/from the JS environment as Base64 encoded strings.

Portability

We adapted the module to build on both Windows 10 and Ubuntu 18.04 LTS (bionic), by adjusting:

  • build parameters - binding.gyp
  • SEAL macrodefinitions - seal/util/config.h

to a common code; please inspect config.h for the list of enabled / disabled SEAL macros.

About

Node.js port of seal C++ package relased by microsft and containing homomorfic encryption primitives

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages