On this page

# ZxAIBC

ZxAIBC

This is the NaeuralEdgeProtocol Network Blockchain engine. Its purpose is to offer any integrator common features like signature checking, message validation or key pair generation.

## Constructor

### new ZxAIBC(options)

NaeuralEdgeProtocol Network Blockchain engine constructor.

Parameters:

Name | Type | Description
--- | --- | ---
`options` | ZxAIBlockchainOptions |

Source
  - utils/blockchain.js, line 59

## Classes

ZxAIBC

## Members

### (private) compressedPublicKey :string

A handy cache for the public key.

Type:

- string

Source
  - utils/blockchain.js, line 74

### (private) debugMode :boolean

Flag to boot the engine in debug mode. Will output signature verification logs.

Type:

- boolean

Source
  - utils/blockchain.js, line 82

### (private) keyPair :Object

The keypair that is in use.

Type:

- Object

Source
  - utils/blockchain.js, line 66

## Methods

### (private) _deriveSharedKey(peerPublicKey) → {*}

Parameters:

Name | Type | Description
--- | --- | ---
`peerPublicKey` |  |

Source
  - utils/blockchain.js, line 534

Returns:

Type:
  *

### (private) _getHash(input) → {Object}

Returns the hash for a provided input. Inputs can be either a string or an object. Any other datatype will throw an error.

Parameters:

Name | Type | Description
--- | --- | ---
`input` |  |

Source
  - utils/blockchain.js, line 469

Returns:

Type:
  Object

### (private) _getPrivateKey() → {crypto.KeyObject}

Source
  - utils/blockchain.js, line 457

Returns:

Type:
  crypto.KeyObject

### (private) _prepareMessage(input, signatureB64, format) → {object|string}

Generates and applies all the signatures and hashes to the input object. The format can be either `json` or `object` and it allows the caller to select the format of the returned value.

Parameters:

Name | Type | Description
--- | --- | ---
`input` |  |
`signatureB64` | string | the signature
`format` | string | the format to return

Source
  - utils/blockchain.js, line 512

Returns:

the original object with signature properties appended

Type:
  object | string

### (private) _signHash(binHash) → {string}

Generates the signature for the provided hash.

Parameters:

Name | Type | Description
--- | --- | ---
`binHash` | Buffer | the hash to sign

Source
  - utils/blockchain.js, line 497

Returns:

the signature for the provided hash

Type:
  string

### getAddress() → {string}

Returns the NaeuralEdgeProtocol Network blockchain address.

Source
  - utils/blockchain.js, line 280

Returns:

the NaeuralEdgeProtocol Network Address

Type:
  string

### getPublicKeyDER() → {string}

Returns the public key as a string.

Source
  - utils/blockchain.js, line 271

Returns:

the public key in DER format

Type:
  string

### sign(input, format) → {string|any}

Returns the signed input object with all the cryptographical metadata appended to it. The format can be either `json` or `object` and it allows the caller to select the format of the returned value.

Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`input` | object | string |  | the input to be signed
`format` | string | json | selector for the returned value

Source
  - utils/blockchain.js, line 296

Returns:

the signed input

Type:
  string | any

### verify(fullJSONMessage) → {boolean}

Verifies the message signature. If the message is incorrectly signed, will return false.

Parameters:

Name | Type | Description
--- | --- | ---
`fullJSONMessage` | string | the message to verify

Source
  - utils/blockchain.js, line 309

Returns:

verification result

Type:
  boolean

### (private, static) _removeAddressPrefix(address) → {string}

Removes the prefix from the address.

Parameters:

Name | Type | Description
--- | --- | ---
`address` | string |

Source
  - utils/blockchain.js, line 444

Returns:

Type:
  string

### (static) generateKeys() → {crypto.KeyPairKeyObjectResult}

Generates a pair of public-private keys that can be used throughout this module or when interacting with the network.

Source
  - utils/blockchain.js, line 110

Returns:

the keypair

Type:
  crypto.KeyPairKeyObjectResult

Type anything to view search result