Global

Members

merklePath[undefined] :LeafNode

Source:
Type:

merklePath[undefined] :BranchNode

Source:
Type:

Methods

alignUp(size, alignment) → {number}

Description:
  • Calculates aligned size.

Source:
Parameters:
Name Type Description
size number

Size.

alignment number

Alignment.

Returns:

Size rounded up to alignment.

Type
number

bytesToBigInt(input, size, isSigned) → {bigint}

Description:
  • Converts aligned bytes to little-endian number.

Source:
Parameters:
Name Type Default Description
input Uint8Array

Uint8 array.

size number

Number of bytes.

isSigned boolean false

\c true if number should be treated as signed.

Returns:

Value corresponding to the input.

Type
bigint

bytesToBigIntUnaligned(input, size, isSigned) → {bigint}

Description:
  • Converts bytes to little-endian number.

Source:
Parameters:
Name Type Default Description
input Uint8Array

Uint8 array.

size number

Number of bytes.

isSigned boolean false

\c true if number should be treated as signed.

Returns:

Value corresponding to the input.

Type
bigint

bytesToInt(input, size, isSigned) → {number}

Description:
  • Converts aligned bytes to little-endian number.

Source:
Parameters:
Name Type Default Description
input Uint8Array

Uint8 array.

size number

Number of bytes.

isSigned boolean false

\c true if number should be treated as signed.

Returns:

Value corresponding to the input.

Type
number

bytesToIntUnaligned(input, size, isSigned) → {number}

Description:
  • Converts bytes to little-endian number.

Source:
Parameters:
Name Type Default Description
input Uint8Array

Uint8 array.

size number

Number of bytes.

isSigned boolean false

\c true if number should be treated as signed.

Returns:

Value corresponding to the input.

Type
number

decode(encoded) → {Uint8Array}

Description:
  • Base32 decodes a base32 encoded string.

Source:
Parameters:
Name Type Description
encoded string

Base32 encoded string to decode.

Returns:

Binary data corresponding to the input string.

Type
Uint8Array

deepCompare(lhs, rhs) → {number}

Description:
  • Deeply compares two array elements.

Source:
Parameters:
Name Type Description
lhs object

Left object to compare.

rhs object

Right object to compare.

Returns:

1 if lhs is greater than rhs; -1 if lhs is less than rhs; 0 if lhs and rhs are equal.

Type
number

deriveSharedKey(keyPair, otherPublicKey) → {SharedKey256}

Description:
  • Derives shared key from key pair and other party's public key.

Source:
Parameters:
Name Type Description
keyPair KeyPair

Key pair.

otherPublicKey PublicKey

Other party's public key.

Returns:

Shared encryption key.

Type
SharedKey256

deriveSharedKey(keyPair, otherPublicKey) → {SharedKey256}

Description:
  • Derives shared key from key pair and other party's public key.

Source:
Parameters:
Name Type Description
keyPair KeyPair

Key pair.

otherPublicKey PublicKey

Other party's public key.

Returns:

Shared encryption key.

Type
SharedKey256

deriveSharedKeyDeprecated(keyPair, otherPublicKey, salt) → {SharedKey256}

Description:
  • Derives shared key from key pair, other party's public key and salt

Source:
Deprecated:
  • This is _old_ method of deriving shared key and should not be used in new applications.
Parameters:
Name Type Description
keyPair KeyPair

Key pair.

otherPublicKey PublicKey

Other party's public key.

salt Uint8Array

Random salt. Should be unique per every use.

Returns:

Shared encryption key.

Type
SharedKey256

deriveSharedKeyFactory(info, hasher) → {function}

Description:
  • Creates a shared key factory given a tag and a hash function.

Source:
Parameters:
Name Type Description
info string

Tag used in HKDF algorithm.

hasher object

Hash object to use.

Returns:

Creates a shared key from a raw private key and public key.

Type
function

deriveSharedSecretFactory(hasher) → {function}

Description:
  • Creates a shared secret factory given a hash function.

Source:
Parameters:
Name Type Description
hasher object

Hash object to use.

Returns:

Creates a shared secret from a raw private key and public key.

Type
function

deserializePatriciaTreeNodes(buffer) → {Array.<TreeNode>}

Description:
  • Deserializes a buffer containing patricia tree nodes.

Source:
Parameters:
Name Type Description
buffer Uint8Array

Buffer containing serialized patricia tree nodes.

Returns:

Deserialized patricia tree nodes.

Type
Array.<TreeNode>

encode(data) → {string}

Description:
  • Base32 encodes a binary buffer.

Source:
Parameters:
Name Type Description
data Uint8Array

Binary data to encode.

Returns:

Base32 encoded string corresponding to the input data.

Type
string

generateMosaicAliasId(fullyQualifiedName) → {bigint}

Description:
  • Generates a mosaic id from a fully qualified mosaic alias name.

Source:
Parameters:
Name Type Description
fullyQualifiedName string

Fully qualified mosaic name.

Returns:

Computed mosaic id.

Type
bigint

generateMosaicId(ownerAddress, nonce) → {bigint}

Description:
  • Generates a mosaic id from an owner address and a nonce.

Source:
Parameters:
Name Type Description
ownerAddress Address

Owner address.

nonce number

Nonce.

Returns:

Computed mosaic id.

Type
bigint

generateNamespaceId(name, parentNamespaceId) → {bigint}

Description:
  • Generates a namespace id from a name and an optional parent namespace id.

Source:
Parameters:
Name Type Default Description
name string

Namespace name.

parentNamespaceId bigint 0

Parent namespace id.

Returns:

Computed namespace id.

Type
bigint

generateNamespacePath(fullyQualifiedName) → {Array.<bigint>}

Description:
  • Parses a fully qualified namespace name into a path.

Source:
Parameters:
Name Type Description
fullyQualifiedName string

Fully qualified namespace name.

Returns:

Computed namespace path.

Type
Array.<bigint>

hexToUint8(input) → {Uint8Array}

Description:
  • Converts a hex string to a uint8 array.

Source:
Parameters:
Name Type Description
input string

Hex encoded string.

Returns:

Uint8 array corresponding to the input.

Type
Uint8Array

intToBytes(value, byteSize, isSigned) → {Uint8Array}

Description:
  • Converts an integer to bytes.

Source:
Parameters:
Name Type Default Description
value number | bigint

Integer value.

byteSize number

Number of output bytes.

isSigned boolean false

\c true if the value is signed.

Returns:

Byte representation of the integer.

Type
Uint8Array

isHexString(input) → {boolean}

Description:
  • Determines whether or not a string is a hex string.

Source:
Parameters:
Name Type Description
input string

String to test.

Returns:

\c true if the input is a hex string, \c false otherwise.

Type
boolean

isValidNamespaceName(name) → {boolean}

Description:
  • Returns true if a name is a valid namespace name.

Source:
Parameters:
Name Type Description
name string

Namespace name to check.

Returns:

true if the specified name is valid.

Type
boolean

metadataUpdateValue(oldValue, newValue) → {Uint8Array}

Description:
  • Creates a metadata payload for updating old value to new value.

Source:
Parameters:
Name Type Description
oldValue Uint8Array | undefined

Old metadata value.

newValue Uint8Array

New metadata value.

Returns:

Metadata payload for updating old value to new value.

Type
Uint8Array

proveMerkle(leafHash, merklePath, rootHash) → {boolean}

Description:
  • Proves a merkle hash.

Source:
Parameters:
Name Type Description
leafHash Hash256

Leaf hash to prove.

merklePath Array.<MerklePart>

Merkle hash chain path from leaf to root.

rootHash Hash256

Root hash of the merkle tree.

Returns:

\c true if leaf hash is connected to root hash; false otherwise.

Type
boolean

provePatriciaMerkle(encodedKey, valueToTest, merklePath, stateHash, subcacheMerkleRoots) → {number}

Description:
  • Proves a patricia merkle hash.

Source:
Parameters:
Name Type Description
encodedKey Hash256

Encoded key of the state to prove.

valueToTest Hash256

Expected hash of the state to prove.

merklePath Array.<TreeNode>

Merkle node path from root to leaf.

stateHash Hash256

State hash from a block header.

subcacheMerkleRoots Array.<Hash256>

Sub cache merkle roots corresponding to the state hash.

Returns:

Proof result code.

Type
number

readArray(bufferInput, FactoryClass, accessor) → {Array.<object>}

Description:
  • Reads array of objects.

Source:
Parameters:
Name Type Description
bufferInput Uint8Array

Buffer input.

FactoryClass Object

Factory used to deserialize objects.

accessor function | undefined

Optional accessor used to check objects order.

Returns:

Array of deserialized objects.

Type
Array.<object>

readArrayCount(bufferInput, FactoryClass, count, accessor) → {Array.<object>}

Description:
  • Reads array of deterministic number of objects.

Source:
Parameters:
Name Type Description
bufferInput Uint8Array

Buffer input.

FactoryClass Object

Factory used to deserialize objects.

count number

Number of object to deserialize.

accessor function | undefined

Optional accessor used to check objects order.

Returns:

Array of deserialized objects.

Type
Array.<object>

readVariableSizeElements(bufferInput, FactoryClass, alignment, skipLastElementPadding) → {Array.<object>}

Description:
  • Reads array of variable size objects.

Source:
Parameters:
Name Type Default Description
bufferInput Uint8Array

Buffer input.

FactoryClass Object

Factory used to deserialize objects.

alignment number

Alignment used to make sure each object is at boundary.

skipLastElementPadding boolean false

\c true if last element is not aligned/padded.

Returns:

Array of deserialized objects.

Type
Array.<object>

ripemdKeccak256(payload) → {Uint8Array}

Description:
  • Hashes payload with keccak 256 and then hashes the result with ripemd160.

Source:
Parameters:
Name Type Description
payload Uint8Array

Input buffer to hash.

Returns:

Hash result.

Type
Uint8Array

size(elements, alignment, skipLastElementPadding) → {number}

Description:
  • Calculates size of variable size objects.

Source:
Parameters:
Name Type Default Description
elements Array.<object>

Serializable elements.

alignment number 0

Alignment used for calculations.

skipLastElementPadding boolean false

\c true if last element should not be aligned.

Returns:

Computed size.

Type
number

toByte(char1, char2) → {number}

Description:
  • Decodes two hex characters into a byte.

Source:
Parameters:
Name Type Description
char1 string

First hex digit.

char2 string

Second hex digit.

Returns:

Decoded byte.

Type
number

tryParseUint(str) → {number|undefined}

Description:
  • Tries to parse a string representing an unsigned integer.

Source:
Parameters:
Name Type Description
str string

String to parse.

Returns:

Number represented by the input or undefined.

Type
number | undefined

uint8ToHex(input) → {string}

Description:
  • Converts a uint8 array to a hex string.

Source:
Parameters:
Name Type Description
input Uint8Array

Uint8 array.

Returns:

Hex encoded string corresponding to the input.

Type
string

writeArray(output, elements, accessor)

Description:
  • Writes array of objects.

Source:
Parameters:
Name Type Description
output Object

Output sink.

elements Array.<object>

Serializable elements.

accessor function | undefined

Optional accessor used to check objects order.

writeArrayCount(output, elements, count, accessor)

Description:
  • Writes array of deterministic number of objects.

Source:
Parameters:
Name Type Description
output Object

Output sink.

elements Array.<object>

Serializable elements.

count number

Number of objects to write.

accessor function | undefined

Optional accessor used to check objects order.

writeVariableSizeElements(output, elements, alignment, skipLastElementPadding)

Description:
  • Writes array of variable size objects.

Source:
Parameters:
Name Type Default Description
output Object

Output sink.

elements Array.<object>

Serializable elements.

alignment number

Alignment used to make sure each object is at boundary.

skipLastElementPadding boolean false

\c true if last element should not be aligned/padded.

Type Definitions

MerklePart

Description:
  • Represents part of a merkle tree proof.

Source:
Properties:
Name Type Description
hash Hash256

Hash at this node.

isLeft boolean

\c true if this is a left node; right otherwise.

Represents part of a merkle tree proof.

Type:
  • object

PatriciaTreePath

Description:
  • Path in a Patricia merkle treee.

Source:
Properties:
Name Type Description
path Uint8Array

Bytes composing the full path.

size number

Length (in nibbles) of the path.

Path in a Patricia merkle treee.

Type:
  • object

TryDecodeResult

Description:
  • Result of a try decode operation.

Source:
Properties:
Name Type Description
isDecoded boolean

\c true if message has been decoded and decrypted; \c false otherwise.

message Uint8Array | Message

Decoded message when isDecoded is \c true; encoded message otherwise.

Result of a try decode operation.

Type:
  • object

TryDecodeResult

Description:
  • Result of a try decode operation.

Source:
Properties:
Name Type Description
isDecoded boolean

\c true if message has been decoded and decrypted; \c false otherwise.

message Uint8Array

Decoded message when isDecoded is \c true; encoded message otherwise.

Result of a try decode operation.

Type:
  • object