Socket
Socket
Sign inDemoInstall

node-hcrypt

Package Overview
Dependencies
100
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-hcrypt

Fully homomorphic encryption implementation for node.js


Version published
Weekly downloads
2
Maintainers
1
Created
Weekly downloads
 

Readme

Source

hcrypt

Fully homomorphic encryption implementation for node.js

This package provides an API for node.js application to use homomorphic encryption to perform some computations.

Only integers are currently supported.

Operations supported: algebraic addition and multiplication.


Prerequisites

You must have GMP (5.0.0+ or MPIR 2.6.0+) and MPFR (3.0.0+) libraries installed in the system. Also, build tools are required for the native addon.

For Debian-based: sudo apt-get install libgmp-dev libmpfr-dev libmpfr4 gcc g++ automake autoconf

For RHEL-based: sudo yum install gmp mpfr gcc gcc-c++ automake autoconf, but note that gmp and mpfr versions in the repo are outdated so you should just compile them from sources.

On Windows you can use cygwin, just don't forget to set GMP and MPFR to devel while installing.

This package should work with latest stable npm and node, but may also work with any below. If you run into any problems while installing be sure to udpate npm first.

MPFR: http://www.mpfr.org/mpfr-current/#download GMP: https://gmplib.org/#DOWNLOAD


To Install

npm install node-hcrypt

The installation may take a while.


API

The module exports two main object types: Crypto and Operator. Crypto provides with encrypting / decrypting functionality while Operator deals with the operations on encrypted data. Module also exports helpers for converting any arbitrary numbers and performing operations with them, but they will be integrated into the mentioned above object types soon.

Crypto
var hcrypt = require('node-hcrypt');

var crypto = new hcrypt.Crypto();
Methods
MethodDescription
encrypt(int bit):stringEncrypts 1 or 0. Returns encrypted value as a base64 string.
decrypt(string encrypted):intDecrypts. Returns 1 or 0.
export():objectReturns public key for use with Operator.
Operator
var hcrypt = require('node-hcrypt');

var crypto = new hcrypt.Crypto();

var operator = new hcrypt.Operator(crypto.export());
Methods
MethodDescription
add(string encryptedA, string encryptedB):string encryptedCPerforms logical addition.
mul(string encryptedA, string encryptedB):string encryptedCPerforms logical multiplication.
halfAdd(string encryptedA, string encryptedB):[string encryptedC, string carryD]Performs half-addition with carry in return.
fullAdd(string carryI, string encryptedA, string encryptedB):[string encryptedC, string carryD]Performs full addition with a carry in return.
recrypt(string encryptedI):string encryptedOPerforms cryptographic refresh. Should be done after 2-3 operations under the same encrypted value.
Tests

WIP

License

MIT

Keywords

FAQs

Last updated on 13 Nov 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc