Class: Crypto

Crypto()

new Crypto()

Initializes the module if a callback function is specified
Source:

Members

(readonly) isNative :boolean

Whether the module is using native JS or WASM methods
Type:
  • boolean
Source:

(readonly) isReady :boolean

Whether the module is loaded and ready
Type:
  • boolean
Source:

(readonly) type :string

What type of underlying cryptographic library is being used
Type:
  • string
Source:

Methods

checkKey(key) → {boolean}

Checks that the given key is a valid public key
Parameters:
Name Type Description
key string the public key to check
Source:
Returns:
whether the key is a valid public key
Type
boolean

checkRingSignatures(transactionPrefixHash, keyImage, inputKeys, signatures) → {boolean}

Validates that the ring signatures provided are valid
Parameters:
Name Type Description
transactionPrefixHash string the transaction prefix hash
keyImage string the key image that the signature pertains to
inputKeys Array.<string> the input keys used in the ring
signatures Array.<string> the signatures to verify
Source:
Returns:
whether the signatures are valid or not
Type
boolean

checkSignature(hash, publicKey, signature) → {boolean}

Checks an individual signature
Parameters:
Name Type Description
hash string the input hash
publicKey string the public key used
signature string the signature to check
Source:
Returns:
whether the signature is valid
Type
boolean

chukwa_slow_hash(data) → {Array.<(boolean|string)>}

Chukwa Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_dark_lite_slow_hash_v0(data) → {Array.<(boolean|string)>}

CryptoNight Dark Lite v0 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_dark_lite_slow_hash_v1(data) → {Array.<(boolean|string)>}

CryptoNight Dark Lite v1 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_dark_lite_slow_hash_v2(data) → {Array.<(boolean|string)>}

CryptoNight Dark Lite v2 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_dark_slow_hash_v0(data) → {Array.<(boolean|string)>}

CryptoNight Dark v0 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_dark_slow_hash_v1(data) → {Array.<(boolean|string)>}

CryptoNight Dark v1 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_dark_slow_hash_v2(data) → {Array.<(boolean|string)>}

CryptoNight Dark v2 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_fast_hash(data) → {Array.<(boolean|string)>}

CryptoNight Fast Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_lite_slow_hash_v0(data) → {Array.<(boolean|string)>}

CryptoNight Lite v0 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_lite_slow_hash_v1(data) → {Array.<(boolean|string)>}

CryptoNight Lite v1 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_lite_slow_hash_v2(data) → {Array.<(boolean|string)>}

CryptoNight Lite v2 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_slow_hash_v0(data) → {Array.<(boolean|string)>}

CryptoNight v0 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_slow_hash_v1(data) → {Array.<(boolean|string)>}

CryptoNight v1 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_slow_hash_v2(data) → {Array.<(boolean|string)>}

CryptoNight v2 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_soft_shell_slow_hash_v0(data, height) → {Array.<(boolean|string)>}

CryptoNight Soft Shell v0 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
height number the height to use in the calculation
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_soft_shell_slow_hash_v1(data, height) → {Array.<(boolean|string)>}

CryptoNight Soft Shell v1 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
height number the height to use in the calculation
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_soft_shell_slow_hash_v2(data, height) → {Array.<(boolean|string)>}

CryptoNight Soft Shell v2 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
height number the height to use in the calculation
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_turtle_lite_slow_hash_v0(data) → {Array.<(boolean|string)>}

CryptoNight Turtle Lite v0 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_turtle_lite_slow_hash_v1(data) → {Array.<(boolean|string)>}

CryptoNight Turtle Lite v1 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_turtle_lite_slow_hash_v2(data) → {Array.<(boolean|string)>}

CryptoNight Turtle Lite v2 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_turtle_slow_hash_v0(data) → {Array.<(boolean|string)>}

CryptoNight Turtle v0 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_turtle_slow_hash_v1(data) → {Array.<(boolean|string)>}

CryptoNight Turtle v1 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

cn_turtle_slow_hash_v2(data) → {Array.<(boolean|string)>}

CryptoNight Turtle v2 Slow Hash Method
Parameters:
Name Type Description
data string hexadecimal string to hash
Source:
Returns:
array consisting of [error, hash]
Type
Array.<(boolean|string)>

derivePublicKey(derivation, outputIndex, publicKey) → {Array.<(boolean|string)>}

Derives the public key from the specified parameters
Parameters:
Name Type Description
derivation string the derivation
outputIndex number the output index in the transaction
publicKey string the public key
Source:
Returns:
array consisting of [error, publicKey]
Type
Array.<(boolean|string)>

deriveSecretKey(derivation, outputIndex, secretKey) → {Array.<(boolean|string)>}

Derives the secret key from the specified parameters
Parameters:
Name Type Description
derivation string the derivation
outputIndex number the output index in the transaction
secretKey string the secret key
Source:
Returns:
array consisting of [error, secretKey]
Type
Array.<(boolean|string)>

generateDeterministicSubwalletKeys() → {Array.<(boolean|{publicKey: string, secretKey: string})>}

Generates a deterministic subwallet key pair
Source:
Returns:
array consisting of [error, keys]
Type
Array.<(boolean|{publicKey: string, secretKey: string})>

generateKeyDerivation(transactionPublicKey, privateViewKey) → {Array.<(boolean|string)>}

Generates the key derivation of the given keys
Parameters:
Name Type Description
transactionPublicKey string the transaction public key
privateViewKey string the private view key
Source:
Returns:
array consisting of [error, derivation]
Type
Array.<(boolean|string)>

generateKeyImage(publicKey, privateKey) → {Array.<(boolean|string)>}

Generates the key image from the given public and private keys
Parameters:
Name Type Description
publicKey string the public emphemeral
privateKey string the private emphemeral
Source:
Returns:
array consisting of [error, keyImage]
Type
Array.<(boolean|string)>

generateKeys() → {Array.<(boolean|{publicKey: string, secretKey: string})>}

Generates a key pair
Source:
Returns:
array consisting of [error, keys]
Type
Array.<(boolean|{publicKey: string, secretKey: string})>

generatePrivateViewKeyFromPrivateSpendKey(privateKey) → {Array.<(boolean|string)>}

Generates the deterministic private view key from the supplied private spend key
Parameters:
Name Type Description
privateKey string the private spend key
Source:
Returns:
array consisting of [error, privateKey]
Type
Array.<(boolean|string)>

generateRingSignatures(transactionPrefixHash, keyImage, inputKeys, privateKey, realIndex) → {Array.<(boolean|Array.<string>)>}

Generates the ring signatures for the supplied parameters
Parameters:
Name Type Description
transactionPrefixHash string the transaction prefix hash
keyImage string the key image that the signature pertains to
inputKeys Array.<string> the input keys used in the ring
privateKey string the real private key used for signing
realIndex number the index of the real output in the inputKeys array
Source:
Returns:
array consisting of [error, signatures]
Type
Array.<(boolean|Array.<string>)>

generateSignature(hash, publicKey, privateKey) → {Array.<(boolean|string)>}

Generates a single signature
Parameters:
Name Type Description
hash string the input hash
publicKey string the public key to use
privateKey string the private key to use for the signing process
Source:
Returns:
array consisting of [error, signature]
Type
Array.<(boolean|string)>

generateViewKeysFromPrivateSpendKey(privateKey) → {Array.<(boolean|{publicKey: string, secretKey: string})>}

Generates the deterministic view keys from the supplied private spend key
Parameters:
Name Type Description
privateKey string the private spend key
Source:
Returns:
array consisting of [error, keys]
Type
Array.<(boolean|{publicKey: string, secretKey: string})>

hashToEllipticCurve(hash) → {Array.<(boolean|string)>}

Converts a hash to an elliptic curve
Parameters:
Name Type Description
hash string the hash to convert
Source:
Returns:
array consisting of [error, ellipticCurve]
Type
Array.<(boolean|string)>

hashToScalar(hash) → {Array.<(boolean|string)>}

Converts a hash to a scalar
Parameters:
Name Type Description
hash string the hash to convert
Source:
Returns:
array consisting of [error, scalar]
Type
Array.<(boolean|string)>

scalarmultKey(keyImageA, keyImageB) → {Array.<(boolean|string)>}

Performs a scalar multkey operation
Parameters:
Name Type Description
keyImageA string the first key image
keyImageB string the second key image
Source:
Returns:
array consisting of [error, keyImage]
Type
Array.<(boolean|string)>

scReduce32(data) → {Array.<(boolean|string)>}

scalar 32-bit reduction
Parameters:
Name Type Description
data string hexadecimal data to reduce
Source:
Returns:
array consisting of [error, result]
Type
Array.<(boolean|string)>

secretKeyToPublicKey(privateKey) → {Array.<(boolean|string)>}

Generates the public key from the private key
Parameters:
Name Type Description
privateKey string the private key
Source:
Returns:
array consisting of [error, publicKey]
Type
Array.<(boolean|string)>

tree_branch(arr) → {Array.<(boolean|Array.<string>)>}

Calculates the tree branch of the given hashes
Parameters:
Name Type Description
arr Array.<string> the hashes to use in the calculation
Source:
Returns:
array consisting of [error, treeBranches]
Type
Array.<(boolean|Array.<string>)>

tree_depth(count) → {Array.<(boolean|number)>}

Calculates the tree depth of the given value
Parameters:
Name Type Description
count number the number of items
Source:
Returns:
array consisting of [error, treeDepth]
Type
Array.<(boolean|number)>

tree_hash(arr) → {Array.<(boolean|string)>}

Calculates the tree hash of the given hashes
Parameters:
Name Type Description
arr Array.<string> the hashes to use in the calculation
Source:
Returns:
array consisting of [error, treeHash]
Type
Array.<(boolean|string)>

tree_hash_from_branch(branches, leaf, path) → {Array.<(boolean|string)>}

Calculates the tree hash of the given branches
Parameters:
Name Type Description
branches Array.<string> the hashes of the branches to use in the calculation
leaf string the leaf to include in the calculation
path number the path to include in the calculation
Source:
Returns:
array consisting of [error, treeHash]
Type
Array.<(boolean|string)>

underivePublicKey(derivation, outputIndex, outputKey) → {Array.<(boolean|string)>}

Underives the public key from the given parameters
Parameters:
Name Type Description
derivation string the derivation
outputIndex number the output index in the transaction
outputKey string the output key
Source:
Returns:
array consisting of [error, publicKey]
Type
Array.<(boolean|string)>