CryptoNets WebAssembly SDK
Powered by Private Identity®
https://private.id
CryptoNets™ Wasm Module Implementation is an npm package that uses the W3C WebAssembly to perform 1:N fully homomorphically encrypted (FHE) face recognition.
BENEFITS
- 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
BUILD
- Verified Identity
- Web Sign-in
- Payments
- Phone Unlock
- Ticketless Access Control
- Account Recovery
- Face CAPTCHA
Prerequisite
Sign up on the waitlist on https://private.id to obtain your apiKey.
Installation
npm install @privateid/cryptonets-web-sdk
Copy the necessary dependencies to the public folder of your app
"prestart": "cp -R ./node_modules/@privateid/cryptonets-web-sdk/wasm public/&& cp -R ./node_modules/@privateid/cryptonets-web-sdk/workers public/",
"prebuild": "cp -R ./node_modules/@privateid/cryptonets-web-sdk/wasm public/ && cp -R ./node_modules/@privateid/cryptonets-web-sdk/workers public/"
Add the necessary environment variables on the .env file in the root of your project
SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL=
REACT_APP_API_KEY=
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/cryptonets-web-sdk';
await loadPrivIdModule();
clearDB();
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/cryptonets-web-sdk';
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/cryptonets-web-sdk';
switchCamera(deviceID);
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/cryptonets-web-sdk';
switchCamera('front');
isValid
Live demo: [https://age.devel.private.id]
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/cryptonets-web-sdk';
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/cryptonets-web-sdk';
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 |
Callback
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: https://c.priv.id
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/cryptonets-web-sdk';
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
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
import { isValidPhotoID } from '@privateid/cryptonets-web-sdk';
const {result} = isValidPhotoID("PHOTO_ID_BACK", callback)
The isValidPhotoID function takes 2 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:
Front Document Scan (PHOTO_ID_FRONT)
result: status of the validation of the document
Status | Description |
---|
0 | valid document |
-1 | validation failed |
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.
Back Document Scan (PHOTO_ID_BACK)
result: status of the validation of the document
userData: an object containing all the extracted data from the PDF 417 code.
Licensing Restriction: This product is not licensed for use in regulated gaming. To license in this market, please contact CentralAMS.