Module: lib/protocol/crypto

Module for Whiteflag cryptographic functions

Source:
Tutorials:

Members

(inner, constant) authParams :Object

Defines the Whiteflag secret authentication token parameters as per par 5.2.3 of the WF specification

Type:
  • Object
Source:

(inner, constant) cryptoParams :Object

Defines the Whiteflag encryption parameters as per par 5.2.3 of the WF specification

Type:
  • Object
Source:

Methods

(inner) decryptMessage(wfMessage, encodedMessage, callback)

Decrypts a binary encoded encrypted Whiteflag message

Parameters:
Name Type Description
wfMessage wfMessage

a Whiteflag message

encodedMessage Buffer

a binary encoded and encrypted Whiteflag message

callback wfMessageCb

function called on completion

Source:

(inner) encryptMessage(wfMessage, encodedMessage, callback)

Encrypts a binary encoded Whiteflag message

Parameters:
Name Type Description
wfMessage wfMessage

a Whiteflag message

encodedMessage Buffer

an unencrypted binary encoded Whiteflag message

callback wfMessageCb

function called on completion

Source:

(inner) generateECDHsecret(id, otherPublicKey, callback)

Generates a shared secret based on incoming public ECDH key pair and provides the public key

Parameters:
Name Type Description
id string

ECDH key pair identifier

otherPublicKey string

hexadecimal representation of a received public ECDH key

callback genericCb

function called on completion

Source:

(inner) getECDHpubKey(id, newKeyPair, callback)

Generates ECDH key pair and provides the public key

Parameters:
Name Type Description
id string

ECDH key pair identifier

newKeyPair boolean

replace existing ECDH key pair if true

callback cryptoCDHpublicKeyCb

function called on completion

Source:

(inner) getTokenVerificationData(authToken, address, callback)

Generates verification data from shared secret authentication token

Parameters:
Name Type Description
authToken Buffer

binary encoded secret authentication token as input key material

address Buffer

binary encoded blockchain address by which the token is used

callback genericCb

function called on completion

Source:

Type Definitions

cryptoCDHpublicKeyCb(err, publicKey, newKey)

Parameters:
Name Type Description
err Error

any error

publicKey string

the hexadecimal encoded ECDH public key

newKey boolean

true if new keypair generated, else false

Source: