Module: orc/utils

Source:

Methods


<static> bufferAsReadableStream(buffer)

Returns a readable stream version of the given buffer
Parameters:
Name Type Description
buffer buffer
Source:
Returns:
Type
object

<static> createCipher(publicKey, privateKey)

Returns a cipher stream using aes256-cbc-sha256-hmac using a ECDH secret derived from the given public and private keys
Parameters:
Name Type Description
publicKey buffer SECP256k1 public key bytes
privateKey buffer SECP256k1 private key bytes
Source:
Returns:
Type
object

<static> createDecipher(publicKey, privateKey)

Returns a cipher stream using aes256-cbc-sha256-hmac using a ECDH secret derived from the given public and private keys
Parameters:
Name Type Description
publicKey buffer SECP256k1 public key bytes
privateKey buffer SECP256k1 private key bytes
Source:
Returns:
Type
object

<static> createShardDownloader(farmer, hash, token [, agent])

Returns a request object for downloading a shard from a farmer
Parameters:
Name Type Argument Description
farmer array Farmer contact object
hash string The hash of the shard to upload
token string The authorized transfer token
agent Agent <optional>
Source:
Returns:
Type
https.ClientRequest

<static> createShardUploader(farmer, hash, token [, agent])

Returns a request object for uploading a shard to a farmer
Parameters:
Name Type Argument Description
farmer array Farmer contact object
hash string The hash of the shard to upload
token string The authorized transfer token
agent Agent <optional>
Source:
Returns:
Type
https.ClientRequest

<static> decrypt(data, publicKey, privateKey)

Decrypt the data using ECDH
Parameters:
Name Type Description
data buffer
publicKey buffer
privateKey buffer
Source:
Returns:
Type
buffer

<static> encrypt(data, publicKey, privateKey)

Encrypt the data using ECDH
Parameters:
Name Type Description
data buffer
publicKey buffer
privateKey buffer
Source:
Returns:
Type
buffer

<static> getCapacityFromFlags(flags)

Returns a dictionary of capacity information from contact flags
Parameters:
Name Type Description
flags array
Source:
Returns:
Type
object

<static> getContactURL(contact)

Returns a stringified URL from the supplied contact object
Parameters:
Name Type Description
contact array
Properties
Name Type Description
0 string Node identity key
1 object
Properties
Name Type Description
hostname string
port string
protocol string
Source:
Returns:
Type
string

<static> getErasureParameters(n)

Returns the appropriate shard size, number of shards, and number of parity shards for RS encoding/decoding provided the total number of bytes of the complete content
Parameters:
Name Type Description
n number Number of bytes in data
Source:
Returns:
Type
object

<static> getNextPowerOfTwo(number)

Returns the next power of two number
Parameters:
Name Type Description
number number
Source:
Returns:
Type
number

<static> isCompatibleVersion(version)

Returns whether or not the supplied semver tag is compatible
Parameters:
Name Type Description
version string The semver tag from the contact
Source:
Returns:
Type
boolean

<static> isHexaString(a)

Determines if a value is hexadecimal string
Parameters:
Name Type Description
a * The value to be tested
Source:
Returns:
Type
boolean

<static> isValidContact(contact, loopback)

Determines if the supplied contact is valid
Parameters:
Name Type Description
contact array The contact information for a given peer
loopback boolean Allows contacts that are localhost
Source:
Returns:
Type
boolean

<static> isValidHDNodeKey(hdKey)

Checks if the supplied HD key is valid (base58 encoded) and proper length
Parameters:
Name Type Description
hdKey string The HD key in base 58 encoding
Source:
Returns:
isValidHDKey
Type
boolean

<static> isValidNodeIndex(hdIndex)

Checks if the input is a non-hardened HD key index
Parameters:
Name Type Description
hdIndex number The HD key index
Source:
Returns:
isValidHDKeyIndex
Type
boolean

<static> rmd160(input, encoding)

Returns the RIPEMD-160 hash of the input
Parameters:
Name Type Description
input string | buffer Data to hash
encoding string The encoding type of the data
Source:
Returns:
Type
buffer

<static> rmd160sha256(input, encoding)

Returns the RIPEMD-160 SHA-256 hash of this input
Parameters:
Name Type Description
input string | buffer Data to hash
encoding string The encoding type of the data
Source:
Returns:
Type
buffer

<static> sha256(input, encoding)

Returns the SHA-256 hash of the input
Parameters:
Name Type Description
input string | buffer Data to hash
encoding string The encoding type of the data
Source:
Returns:
Type
buffer