Sybil

Implementation of face recognition in NodeJS.

Sybil
Author: The Kuwa Foundation / Priyadarshi Rath

Watcher

Implementation of watcher service in Node JS.

Watcher
Author: The Kuwa Foundation / Priyadarshi Rath

Watcher

Implementation of watcher service in Node JS.

Watcher
Author: The Kuwa Foundation / Priyadarshi Rath

getRotation

Reads video metadata to find the angle by which the video frames have been rotated by a video capture device.

getRotation(videoPath: String): number
Parameters
videoPath (String) The path to the video file.
Returns
number: theta - The angle by which the video was rotated by the device.

loadWallet

Loads an Ethereum wallet file using a specified path, address and password.

loadWallet(walletPath: String, accountAddress: String, password: String): void
Parameters
walletPath (String) The path to the registrar's wallet JSON file.
accountAddress (String) Ethereum address of the registrar's wallet.
password (String) Password to the registrar's wallet.
Returns
void:

loadWallet

Loads an Ethereum wallet file using a specified path, address and password.

loadWallet(walletPath: String, accountAddress: String, password: String): void
Parameters
walletPath (String) The path to the registrar's wallet JSON file.
accountAddress (String) Ethereum address of the registrar's wallet.
password (String) Password to the registrar's wallet.
Returns
void:

getFaceImages

Reads a video file and saves frames into a path determined by saveDir.

getFaceImages(videoPath: String, clientAddress: String): void
Parameters
videoPath (String) The path to the video file that the client uploaded.
clientAddress (String) The ethereum address of the client.
Returns
void:

loadContract

Loads a Kuwa Registration Smart Contract.

loadContract(ContractABI: Object, ContractAddress: String, from: String, gasPrice: String, gas: String): Promise
Parameters
ContractABI (Object) Application Binary Interface obtained after deploying the Kuwa Registration Smart Contract.
ContractAddress (String) Address of the Kuwa Registration Smart Contract.
from (String) Ethereum address of the registrar's wallet.
gasPrice (String) The amount of ether the registrar is willing to spend per unit of gas.
gas (String) The maximum amount of gas the registrar wants to spend on this transaction.
Returns
Promise: contract - Promise object representing the smart contract.

loadContract

Loads a Kuwa Registration Smart Contract.

loadContract(ContractABI: Object, ContractAddress: String, from: String, gasPrice: String, gas: String): Promise
Parameters
ContractABI (Object) Application Binary Interface obtained after deploying the Kuwa Registration Smart Contract.
ContractAddress (String) Address of the Kuwa Registration Smart Contract.
from (String) Ethereum address of the registrar's wallet.
gasPrice (String) The amount of ether the registrar is willing to spend per unit of gas.
gas (String) The maximum amount of gas the registrar wants to spend on this transaction.
Returns
Promise: contract - Promise object representing the smart contract.

getChallengePhrase

Gets the challenge phrase for a Kuwa Registration Smart Contract.

getChallengePhrase(smartContract: Object): Promise
Parameters
smartContract (Object) Object representing Kuwa Registration Smart Contract.
Returns
Promise: phrase - Promise object representing the challenge phrase.

getChallengePhrase

Gets the challenge phrase for a Kuwa Registration Smart Contract.

getChallengePhrase(smartContract: Object): Promise
Parameters
smartContract (Object) Object representing Kuwa Registration Smart Contract.
Returns
Promise: phrase - Promise object representing the challenge phrase.

compareFaces

Compares the face embeddings of two people.

compareFaces(imgDir1: String, imgDir2: String): Boolean
Parameters
imgDir1 (String) The directory containing the face image of the first person.
imgDir2 (String) The directory containing the face image of the second person.
Returns
Boolean: isSameFace - Either 1 (representing the same person) or 0 (representing different people).

validateKuwaID

Marks a Kuwa ID as Valid.

validateKuwaID(senderAddress: String, ContractAddress: String, smartContract: Object, gasLimit: String, gasPrice: String): Promise
Parameters
senderAddress (String) Ethereum address of the registrar's wallet.
ContractAddress (String) Address of the Kuwa Registration Smart Contract.
smartContract (Object) Object representing Kuwa Registration Smart Contract.
gasLimit (String) The maximum amount of gas the registrar wants to spend on this transaction.
gasPrice (String) The amount of ether the registrar is willing to spend per unit of gas.
Returns
Promise: receipt - Promise object representing the transaction receipt.

validateKuwaID

Marks a Kuwa ID as Valid.

validateKuwaID(senderAddress: String, ContractAddress: String, smartContract: Object, gasLimit: String, gasPrice: String): Promise
Parameters
senderAddress (String) Ethereum address of the registrar's wallet.
ContractAddress (String) Address of the Kuwa Registration Smart Contract.
smartContract (Object) Object representing Kuwa Registration Smart Contract.
gasLimit (String) The maximum amount of gas the registrar wants to spend on this transaction.
gasPrice (String) The amount of ether the registrar is willing to spend per unit of gas.
Returns
Promise: receipt - Promise object representing the transaction receipt.

getImageDescriptors

Reads the image files in a directory and gets the face embeddings in the image files.

getImageDescriptors(imgDir: String): Array
Parameters
imgDir (String) The directory containing the face images.
Returns
Array: faceEmbedding - A vector representing the face embedding of the person in the image.

inValidateKuwaID

Marks a Kuwa ID as Invalid.

inValidateKuwaID(senderAddress: String, ContractAddress: String, smartContract: Object, gasLimit: String, gasPrice: String): Promise
Parameters
senderAddress (String) Ethereum address of the registrar's wallet.
ContractAddress (String) Address of the Kuwa Registration Smart Contract.
smartContract (Object) Object representing Kuwa Registration Smart Contract.
gasLimit (String) The maximum amount of gas the registrar wants to spend on this transaction.
gasPrice (String) The amount of ether the registrar is willing to spend per unit of gas.
Returns
Promise: receipt - Promise object representing the transaction receipt.

inValidateKuwaID

Marks a Kuwa ID as Invalid.

inValidateKuwaID(senderAddress: String, ContractAddress: String, smartContract: Object, gasLimit: String, gasPrice: String): Promise
Parameters
senderAddress (String) Ethereum address of the registrar's wallet.
ContractAddress (String) Address of the Kuwa Registration Smart Contract.
smartContract (Object) Object representing Kuwa Registration Smart Contract.
gasLimit (String) The maximum amount of gas the registrar wants to spend on this transaction.
gasPrice (String) The amount of ether the registrar is willing to spend per unit of gas.
Returns
Promise: receipt - Promise object representing the transaction receipt.

getEuclideanDistance

Computes the Euclidean Distance between two vectors.

getEuclideanDistance(faceEmbedding1: Array, faceEmbedding2: Array): number
Parameters
faceEmbedding1 (Array) The face embedding of the first person.
faceEmbedding2 (Array) The face embedding of the second person.
Returns
number: euclideanDistance - The Eudlidean distance between the face embeddings.

getStatus

Gets the registration status for a Kuwa Registration Smart Contract.

getStatus(smartContract: Object): Promise
Parameters
smartContract (Object) Object representing Kuwa Registration Smart Contract.
Returns
Promise: registrationStatus - Promise object representing the registration status of the smart contract.

getStatus

Gets the registration status for a Kuwa Registration Smart Contract.

getStatus(smartContract: Object): Promise
Parameters
smartContract (Object) Object representing Kuwa Registration Smart Contract.
Returns
Promise: registrationStatus - Promise object representing the registration status of the smart contract.

findDuplicate

Finds if a new candidate for registration is a valid person.

findDuplicate(dictionary: Object, hashval: String): Boolean
Parameters
dictionary (Object) A dictionary containing all valid registrations.
hashval (String) The hash value obtained by hashing the new video file.
Returns
Boolean: isDuplicate - Value indicating whether the new person is valid (new).

findDuplicate

Finds if a new candidate for registration is a valid person.

findDuplicate(dictionary: Object, hashval: String): Boolean
Parameters
dictionary (Object) A dictionary containing all valid registrations.
hashval (String) The hash value obtained by hashing the new video file.
Returns
Boolean: isDuplicate - Value indicating whether the new person is valid (new).

insertRow

Inserts a row into the registrar database.

insertRow(ClientAddress: String, ContractAddress: String, regStatus: String): void
Parameters
ClientAddress (String) Ethereum address of the Client.
ContractAddress (String) Ethereum address of the Kuwa Registration Smart Contract.
regStatus (String) The status of the Kuwa Registration Smart Contract corresponding to the Client.
Returns
void:

insertRow

Inserts a row into the registrar database.

insertRow(ClientAddress: String, ContractAddress: String, regStatus: String): void
Parameters
ClientAddress (String) Ethereum address of the Client.
ContractAddress (String) Ethereum address of the Kuwa Registration Smart Contract.
regStatus (String) The status of the Kuwa Registration Smart Contract corresponding to the Client.
Returns
void:

registerFile

The main execution function of the watcher.

registerFile(event: Event, filePath: String): void
Parameters
event (Event) Any change/update to the directory being watched.
filePath (String) Absolute path to the new file added.
Returns
void:

registerFile

The main execution function of the watcher.

registerFile(event: Event, filePath: String): void
Parameters
event (Event) Any change/update to the directory being watched.
filePath (String) Absolute path to the new file added.
Returns
void: