Class: CryptoNote

CryptoNote(configopt)

new CryptoNote(configopt)

Initializes a new CryptoNote object
Parameters:
Name Type Attributes Description
config CryptoNote.Config <optional>
A configuration object for the object
Source:

Members

(readonly) cryptoType :string

Returns the underlying cryptography module used
Type:
  • string
Source:

Methods

absoluteToRelativeOffsets(offsets) → {Array.<string>}

Converts a list of absolute output offsets to relative offsets
Parameters:
Name Type Description
offsets Array.<number> | Array.<string> the offsets
Source:
Returns:
the relative offsets
Type
Array.<string>

cnFastHash(data) → {string}

Hashes the the supplied data with the CryptoNight Fast Hash method
Parameters:
Name Type Description
data string hexadecimal representation of data to hash
Source:
Returns:
hexadecimal representation of the hash
Type
string

createAddressFromKeys(privateSpendKey, privateViewKey, addressPrefixopt) → {CryptoNote.Wallet}

Creates a new wallet from keys
Parameters:
Name Type Attributes Default Description
privateSpendKey string the wallet private spend key
privateViewKey string the wallet private view key
addressPrefix number <optional>
3914525 decimal representation of the CryptoNote address prefix
Source:
Returns:
The wallet restored from the provided private spend and view keys
Type
CryptoNote.Wallet

createAddressFromMnemonic(mnemonic, langopt, addressPrefixopt) → {CryptoNote.Wallet}

Creates a new wallet from mnemonic seed phrase
Parameters:
Name Type Attributes Default Description
mnemonic string the wallet mnemonic seed phrase
lang string <optional>
en language for the returned mnemonic
addressPrefix number <optional>
3914525 decimal representation of the CryptoNote address prefix
Source:
Returns:
The wallet restored from the provided mnemonic phrase
Type
CryptoNote.Wallet

createAddressFromSeed(seed, langopt, addressPrefixopt) → {CryptoNote.Wallet}

Creates a new wallet from a wallet seed
Parameters:
Name Type Attributes Default Description
seed string hexadecimal representation of the wallet seed
lang string <optional>
en language for the returned mnemonic
addressPrefix number <optional>
3914525 decimal representation of the CryptoNote address prefix
Source:
Returns:
The wallet restored from the provided seed
Type
CryptoNote.Wallet

createIntegratedAddress(address, paymentIdopt, addressPrefixopt) → {string}

Creates an integrated address from the supplied wallet address and payment ID
Parameters:
Name Type Attributes Default Description
address string the wallet address
paymentId string <optional>
"" a 64 hexadecimal character payment ID
addressPrefix number <optional>
3914525 decimal representation of the CryptoNote address prefix
Source:
Returns:
The Base58 Integrated address
Type
string

createNewAddress(entropyopt, langopt, addressPrefixopt) → {CryptoNote.Wallet}

Creates a new wallet
Parameters:
Name Type Attributes Default Description
entropy string <optional>
random random data for entropy purposes
lang string <optional>
en language for the returned mnemonic
addressPrefix number <optional>
3914525 decimal representation of the CryptoNote address prefix
Source:
Returns:
A newly generated wallet
Type
CryptoNote.Wallet

createNewSeed(entropyopt, iterationsopt) → {string}

Creates a new wallet seed using the supplied entropy and iteration count
Parameters:
Name Type Attributes Default Description
entropy string <optional>
random random data for entropy purposes
iterations number <optional>
1 the number of times to perform a simple KDF operation on the entropy
Source:
Returns:
the new seed in hexadecimal
Type
string

createSubWalletFromPrivateSpendKey(privateSpendKey, subWalletIndex, langopt, addressPrefixopt) → {Wallet}

Creates a new deterministic subwallet using the supplied values
Parameters:
Name Type Attributes Default Description
privateSpendKey string the seed/privateSpendKey of the primary wallet
subWalletIndex number the subwallet index number
lang string <optional>
english the language of the wallet (only used if index == 0)
addressPrefix number <optional>
3914525 decimal representation of the CryptoNote address prefix
Source:
Returns:
The generated subwallet
Type
Wallet

createTransaction(newOutputs, ourOutputs, randomOuts, mixin, feeAmount, paymentIdopt, unlockTimeopt, extraDataopt) → {CryptoNote.GeneratedTransaction}

Creates a new Transaction object using the supplied values
Parameters:
Name Type Attributes Default Description
newOutputs Array.<CryptoNote.GeneratedOutput> The outputs of the new transaction
ourOutputs Array.<CryptoNote.Output> The outputs we are spending
randomOuts Array.<CryptoNote.RandomOutput> The random outputs to mix with
mixin number The mixin count to use
feeAmount number The transaction fee to use
paymentId string <optional>
"" The payment ID to use with the transaction
unlockTime number <optional>
0 The unlock time for the transaction
extraData Buffer | Object | string <optional>
extra data to include in the transaction
Source:
Returns:
A newly generated transaction
Type
CryptoNote.GeneratedTransaction

(async) createTransactionAsync(newOutputs, ourOutputs, randomOuts, mixin, feeAmount, paymentIdopt, unlockTimeopt, extraDataopt) → {Promise.<CryptoNote.GeneratedTransaction>}

Creates a new Transaction using the supplied values in an asynchronous manner
Parameters:
Name Type Attributes Default Description
newOutputs Array.<CryptoNote.GeneratedOutput> The outputs of the new transaction
ourOutputs Array.<CryptoNote.Output> The outputs we are spending
randomOuts Array.<CryptoNote.RandomOutput> The random outputs to mix with
mixin number The mixin count to use
feeAmount number The transaction fee to use
paymentId string <optional>
"" The payment ID to use with the transaction
unlockTime number <optional>
0 The unlock time for the transaction
extraData Buffer | Object | string <optional>
extra data to include in the transaction
Source:
Returns:
A newly generated transaction
Type
Promise.<CryptoNote.GeneratedTransaction>

createTransactionOutputs(address, amount) → {Array.<CryptoNote.GeneratedOutput>}

Creates pretty (base 10) outputs for the address and amount specified
Parameters:
Name Type Description
address string the destination wallet address
amount number the total amount for which we need to generate outputs
Source:
Returns:
The generated outputs for the specified recipient and amount
Type
Array.<CryptoNote.GeneratedOutput>

createTransactionStructure(newOutputs, ourOutputs, randomOuts, mixin, feeAmount, paymentIdopt, unlockTimeopt, _asyncopt, extraDataopt) → {Transaction}

Creates a new Transaction object using the supplied values
Parameters:
Name Type Attributes Default Description
newOutputs Array.<CryptoNote.GeneratedOutput> The outputs of the new transaction
ourOutputs Array.<CryptoNote.Output> The outputs we are spending
randomOuts Array.<CryptoNote.RandomOutput> The random outputs to mix with
mixin number The mixin count to use
feeAmount number The transaction fee to use
paymentId string <optional>
"" The payment ID to use with the transaction
unlockTime number <optional>
0 The unlock time for the transaction
_async boolean <optional>
false Whether we are calling this method asynchronously or not
extraData Buffer | Object | string <optional>
extra data to include in the transaction
Source:
Returns:
A newly generated transaction
Type
Transaction

decodeAddress(address, addressPrefixopt) → {CryptoNote.Address}

Decodes the given address into its respective parts
Parameters:
Name Type Attributes Default Description
address string the wallet address
addressPrefix number <optional>
3914525 decimal representation of the CryptoNote address prefix
Source:
Returns:
The decoded address structure
Type
CryptoNote.Address

decodeAddressPrefix(address) → {CryptoNote.AddressPrefix}

Decodes the address prefix from the given wallet address
Parameters:
Name Type Description
address string the wallet address
Source:
Returns:
The address prefix structure
Type
CryptoNote.AddressPrefix

encodeAddress(publicViewKey, publicSpendKey, paymentIdopt, addressPrefixopt) → {string}

Encodes the public information into a wallet address
Parameters:
Name Type Attributes Default Description
publicViewKey string the wallet public view key
publicSpendKey string the wallet public spend key
paymentId string <optional>
"" a 64 hexadecimal character payment ID
addressPrefix number <optional>
3914525 decimal representation of the CryptoNote address prefix
Source:
Returns:
the address in Base58
Type
string

encodeRawAddress(rawAddress) → {string}

Encodes a raw (hex) address into Base58
Parameters:
Name Type Description
rawAddress string the hexadecimal representation of the address
Source:
Returns:
the address in Base58
Type
string

formatMoney(amount) → {string}

Formats the amount into a human readable form
Parameters:
Name Type Description
amount number the amount to format
Source:
Returns:
the human readable amount
Type
string

generateKeyDerivation(transactionPublicKey, privateViewKey) → {string}

Generates a key derivation from the supplied keys
Parameters:
Name Type Description
transactionPublicKey string the transaction public key
privateViewKey string the wallet private view key
Source:
Returns:
the key derivation
Type
string

generateKeyImage(transactionPublicKey, privateViewKey, publicSpendKey, privateSpendKey, outputIndex) → {string}

Generates the key image of an output that is required to spend it
Parameters:
Name Type Description
transactionPublicKey string the transaction public key
privateViewKey string the private view key of the wallet
publicSpendKey string the public spend key of the wallet
privateSpendKey string the private spend key of the wallet
outputIndex number the index of the output in the transaction
Source:
Returns:
the hexadecimal representation of the key image
Type
string

generateKeyImagePrimitive(publicSpendKey, privateSpendKey, outputIndex, derivation) → {string}

Generates the key image primitive of an output that is required to spend it
Parameters:
Name Type Description
publicSpendKey string the wallet public spend key
privateSpendKey string the wallet private spend key
outputIndex number the index of the output in the transaction
derivation string the output derivation
Source:
Returns:
the hexadecimal representation of the key image
Type
string

generateSignaturePrimitive(hash, publicKey, privateKey) → {string}

Generates a signature using the supplied parameters
Parameters:
Name Type Description
hash string the hash to sign
publicKey string the public key to use in signing
privateKey string the private key to use in signing
Source:
Returns:
the signature
Type
string

isOurTransactionOutput(transactionPublicKey, output, privateViewKey, publicSpendKey, privateSpendKeyopt) → {boolean|CryptoNote.Output}

Checks a particular output to determine if it belongs to the keys provided
Parameters:
Name Type Attributes Description
transactionPublicKey string the transaction public key
output CryptoNote.Output the transaction output to check
privateViewKey string the private view key of the wallet
publicSpendKey string the public spend key of the wallet
privateSpendKey string <optional>
the private spend key of the wallet
Source:
Returns:
If the transaction output is ours
Type
boolean | CryptoNote.Output

privateKeyToPublicKey(privateKey) → {string}

Generates the public key for the given private key
Parameters:
Name Type Description
privateKey string the private key
Source:
Returns:
the resulting public key
Type
string

relativeToAbsoluteOffsets(offsets) → {Array.<string>}

Converts a list of relative output offsets to absolute offsets
Parameters:
Name Type Description
offsets Array.<number> | Array.<string> the offsets
Source:
Returns:
the absolute offsets
Type
Array.<string>

scanTransactionOutputs(transactionPublicKey, outputs, privateViewKey, publicSpendKey, privateSpendKeyopt) → {Array.<CryptoNote.Output>}

Checks all outputs to determine if any of the outputs belong to the keys provided
Parameters:
Name Type Attributes Description
transactionPublicKey string the transaction public key
outputs Array.<CryptoNote.Output> the array of outputs of a transaction
privateViewKey string the private view key of the wallet
publicSpendKey string the public spend key of the wallet
privateSpendKey string <optional>
the private spend key of the wallet
Source:
Returns:
An array of outputs that belong to the keys provided
Type
Array.<CryptoNote.Output>

scReduce32(value) → {string}

Value to scalar method
Parameters:
Name Type Description
value string the 64-character hexadecimal value to reduce
Source:
Returns:
the resulting scalar
Type
string

signMessage(message, signerAddress, privateSpendKey) → {string}

Signs an arbitrary message from the specified signer with their private spend key
Parameters:
Name Type Description
message string | Object the message to sign
signerAddress string the signer's wallet address
privateSpendKey string the signer's private spend key
Source:
Returns:
the resulting signature
Type
string

underivePublicKey(derivation, outputIndex, outputKey) → {string}

Underives the public key from the supplied derivation and other values
Parameters:
Name Type Description
derivation string the derivation
outputIndex number the index of the output in the transaction
outputKey string the output key to underive from
Source:
Returns:
the public key
Type
string

verifyMessageSignature(message, signerAddress, signature) → {boolean}

Verifies that the signature of the supplied message was generated by the specified signer's wallet
Parameters:
Name Type Description
message string | Object the message that was signed
signerAddress string the signer's wallet address
signature string the signature to verify
Source:
Returns:
whether the signature is valid
Type
boolean

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

Verifies a signature using the supplied parameters
Parameters:
Name Type Description
hash string the hash that was signed
publicKey string the public key that was used in signing
signature string the signature
Source:
Returns:
whether the signature is valid
Type
boolean

Type Definitions

Address

A decoded address structure
Type:
  • Object
Properties:
Name Type Description
publicViewKey string The public view key of the address
publicSpendKey string The public spend key of the address
paymentId string The payment ID included in an integrated address
encodedPrefix string the encoded address prefix
prefix number The decimal encoded address prefix
rawAddress string The hexadecimal encoded address
Source:

AddressPrefix

A decoded address prefix
Type:
  • Object
Properties:
Name Type Description
prefix string The encoded address prefix
base58 string The Base58 encoded address prefix
decimal number The decimal encoded address prefix
hexadecimal string The hexadecimal encoded address prefix
Source:

Config

A structure containing the configuration for this library
Type:
  • Object
Properties:
Name Type Attributes Default Description
coinUnitPlaces number <optional>
2 The number of decimal places in the human readable form of the amount
addressPrefix number <optional>
3914525 The decimal representation of the wallet address prefix
keccakIterations number <optional>
1 The number of KDF iterations to perform for KDF operations
defaultNetworkFee number <optional>
10 The default network fee for transactions in atomic units
mmMiningBlockVersion number <optional>
2 The block version at which merged mining was enabled
maximumOutputAmount number <optional>
100000000000 The maximum amount that a single output can be in atomic units
maximumOutputsPerTransaction number <optional>
90 the maximum number of outputs per transaction permitted
maximumExtraSize number <optional>
1024 the maximum amount of extra data that is supported in a transaction
activateFeePerByteTransactions boolean <optional>
true activate logic that checks to make sure that a transaction has enough of a fee for the network rules
feePerByte number <optional>
1.953125 the network fee per byte of the transaction
feePerByteChunkSize number <optional>
256 the network fee per byte chunking size
checkRingSignatures external:Crypto.CheckRingSignatures <optional>
A user-defined check ring signatures method
checkSignature external:Crypto.CheckSignature <optional>
A user-defined check signature method
cnFastHash external:Crypto.CNFastHash <optional>
A user-defined CryptoNight Fast hash method
derivePublicKey external:Crypto.DerivePublicKey <optional>
A user-defined derive public key method
deriveSecretKey external:Crypto.DeriveSecretKey <optional>
A user-defined derive secret key method
generateDeterministicSubwalletKeys external:Crypto.GenerateDeterministicSubwalletKeys <optional>
A user-defined generate deterministic subwallet keys method
generateKeyDerivation external:Crypto.GenerateKeyDerivation <optional>
A user-defined generate key derivation method
generateKeyImage external:Crypto.GenerateKeyImage <optional>
A user-defined generate key image method
generateRingSignatures external:Crypto.GenerateRingSignatures <optional>
A user-defined generate ring signatures method
generateSignature external:Crypto.GenerateSignature <optional>
A user-defined generate signature method
secretKeyToPublicKey external:Crypto.SecretKeyToPublicKey <optional>
A user-defined secret key to private key method
underivePublicKey external:Crypto.UnderivePublicKey <optional>
A user-defined underive public key method
Source:

GeneratedInput

The generated input of an output that belongs to us
Type:
  • Object
Properties:
Name Type Attributes Description
transactionKey KeyPair The key pair of the input transaction
publicEphemeral string The public Ephemeral of the output
privateEphemeral string <optional>
The private Ephemeral of the output
Source:

GeneratedOutput

A generated output for a new transaction
Type:
  • Object
Properties:
Name Type Description
amount number The amount of the generated output
keys Address The recipient of the output
Source:

GeneratedTransaction

A newly generated transaction
Properties:
Name Type Description
transaction Transaction A Transaction object
rawTransaction string A hexadecimal representation of the transaction
hash string The transaction hash
Source:

KeyPair

A public/private key pair
Type:
  • Object
Properties:
Name Type Description
privateKey string The private key
publicKey string The public key
Source:

Output

A transaction output
Type:
  • Object
Properties:
Name Type Attributes Description
key string The output key
index number The output index (in the list of transaction outputs)
globalIndex number The output global index in the blockchain
amount number The amount of the output
type string <optional>
The type of the output
keyImage string <optional>
The generated key image of the output
input GeneratedInput <optional>
The generated input of the output
Source:

RandomOutput

A random output for mixing
Type:
  • Object
Properties:
Name Type Description
key string The output key
globalIndex number The output global index in the blockchain
Source:

Wallet

A Wallet Address Structure
Type:
  • Object
Properties:
Name Type Description
spend KeyPair The spend key pair
view KeyPair The view key pair
address string The Base58 encoded wallet address
mnemonic string The wallet mnemonic phrase
seed string The wallet seed
subWalletIndex number the subwallet index number
Source: