This package has been deprecated

Author message:

This package has moved and is now available at @privateid/cryptonets-web-sdk

TypeScript icon, indicating that this package has built-in type declarations

2.0.5-alpha • Public • Published

Private ID WebAssembly SDK

Powered by Private Identity®

CryptoNets™ Wasm Module Implementation is an npm package that uses the W3C WebAssembly to perform 1:N fully homomorphically encrypted (FHE) face recognition.


  • Face biometric capture
  • Encrypted face recognition every 200ms
  • 1:n biometric match in 60ms constant time
  • Human age estimation
  • Unlimited users (unlimited gallery size)
  • Fair, accurate and unbiased
  • Preserves user privacy with neural network cryptography + fully homomorphic encryption (CryptoNets)
  • IEEE 2410 Standard for Biometric Privacy, ISO 27001, ISO 9001 compliant
  • Exempt from GDPR, CCPA, BIPA, and HIPAA privacy law obligations
  • Predicts in 50ms with or without network using local storage


  • Verified Identity
  • Web Sign-in
  • Payments
  • Phone Unlock
  • Ticketless Access Control
  • Account Recovery
  • Face CAPTCHA


Sign up on the waitlist on to obtain your apiKey.


npm install @privateid/privid-fhe-modules

Copy the necessary dependencies to the public folder of your app

"prestart": "cp -R ./node_modules/@privateid/privid-fhe-modules/wasm public/&& cp -R ./node_modules/@privateid/privid-fhe-modules/workers public/",
"prebuild": "cp -R ./node_modules/@privateid/privid-fhe-modules/wasm public/ && cp -R ./node_modules/@privateid/privid-fhe-modules/workers public/"

Add the necessary environment variables on the .env file in the root of your project

REACT_APP_WASM_MODULE= face_mask | face | voice

Load the WASM Module

The first step is to load and initialize the wasm module and clear the content of the local database.

import { loadPrivIdModule, clearDB } from '@privateid/privid-fhe-modules';

await loadPrivIdModule();

Open or switch camera

The first step is to load and initialize the wasm module.

Open the camera

To open user camera use the openCamera function with element id of the video tag in the DOM

import { openCamera } from '@privateid/privid-fhe-modules';

const { devices, faceMode } = await openCamera(element);

it returns list of the available video devices.

Switch to another camera

To switch to another media device use the switchCamera function with the ID of the device to be used

import { switchCamera } from '@privateid/privid-fhe-modules';


for the mobile phone we can select whether it's front or back camera for this we pass 'front' or 'back' to the switch function

import { switchCamera } from '@privateid/privid-fhe-modules';



Live demo: []

isValid only exercises the is_valid() call and does not find identity. The function detects if there is a valid face in the camera view or in an ImageData Array.

isValid accepts two parameters.

  • action: false for prediction (less restrictive), and true for enrollment (more restrictive). We recommend using false as your default.
  • ImageData: array of an image data to perform the face captcha on (optional)
import { isValid  } from '@privateid/privid-fhe-modules';

const {result, imageData} = isValid (false);

Face CAPTCHA returns 17 possible coded results, as follows.

Property Description
-1 No Face
0 Valid Biometric
1 Image Spoof
2 Video Spoof
3 Too close
4 Too far away
5 Too far to right
6 Too far to left
7 Too far up
8 Too far down
9 Too blurry
10 Glasses on
11 Mask on
12 Chin too far left
13 Chin too far right
14 Chin too far up
15 Chin too far down

Enroll or predict

Perform a new enrollment (register a new user) or predict (authenticate a user) using the enrollPredict function

import { enrollPredict } from '@privateid/privid-fhe-modules';

enrollPredict('userVideo', false, callback)

The function takes 3 parameters

Property Description
videoRef Video tag
action True (enroll) / false (predict)
callback The callback to be executed on each status


The enrollPredict function provides 5 status updates to allow the developer to take action at different steps of the identification process.

Status Description
VALID_FACE A face is detected
INVALID_FACE A valid face is not detected
ENROLLING Enrollment (registration) starts of a valid face
PREDICTING Prediction (authentication) starts of a valid face
WASM_RESPONSE The prediction or enrollment process is complete

Continuous enroll predict

Live demo:

Perform continuous user enrollment or prediction (registration or authentication) using the continuousEnrollPredict function. This provides the same status updates as Enroll or Predict.

import { continuousEnrollPredict } from '@privateid/privid-fhe-modules';

continuousEnrollPredict(false, callback)

The continousEnrollPredict function takes 2 parameters

Property Description
action True (enroll) / false (predict)
callback The callback to be executed on each status

isValidPhotoID (coming soon)

This function finds, crops, align and validate, front and back of the photoID, and returns back a valid cropped and aligned image of the photoID

The isValidPhotoID function takes 3 parameters

Property Description
docType it can be either PHOTO_ID_BACK (back of the photo ID) or PHOTO_ID_FRONT (front of the photo ID)
callback returns the uuid of the portrait on the Front of the Photo ID

The function returns

result: status of the validation of the document

Status Description
0 valid document

href: aligned and cropped image of the document returned in case of valid document

confScore: confidence score indicates if the image contains the 4 corners of the document, without fingers or objects hidding the document, it goes from 0 to 1.

Licensing Restriction: This product is not licensed for use in regulated gaming. To license in this market, please contact CentralAMS.


npm i @privateid/privid-fhe-modules

DownloadsWeekly Downloads





See AWS EULA Template (2020.11.20)(Private ID) at this link:

Unpacked Size

41.8 MB

Total Files


Last publish


  • shivenj
  • ng-privid
  • xcjames29
  • mikepoll
  • scottstreit