Hierarchy

  • CryptoModule
    • Crypto

Constructors

Properties

Accessors

Methods

aes_decrypt aes_encrypt argon2d argon2i argon2id base58_address_decode base58_address_encode base58_decode base58_decode_check base58_encode base58_encode_check blake2b calculate_base2_exponent check_borromean_signature check_bulletproof check_bulletproof_plus check_clsag_signature check_commitments_parity check_outputs_proof check_point check_rfc8032_signature check_scalar check_signature check_triptych_signature cn_base58_address_decode cn_base58_address_encode cn_base58_decode cn_base58_decode_check cn_base58_encode cn_base58_encode_check complete_borromean_signature complete_clsag_signature complete_signature complete_triptych_signature derive_public_key derive_secret_key entropy_recover generate_amount_mask generate_borromean_signature generate_bulletproof generate_bulletproof_plus generate_child_key generate_clsag_signature generate_commitment_blinding_factor generate_derivation generate_derivation_scalar generate_key_image generate_key_image_v2 generate_keys generate_keys_m generate_outputs_proof generate_pedersen_commitment generate_pseudo_commitments generate_rfc8032_signature generate_seed generate_signature generate_transaction_fee_commitment generate_triptych_signature hash_to_point hash_to_scalar languages make_path mnemonics_decode mnemonics_encode mnemonics_word_index prepare_borromean_signature prepare_clsag_signature prepare_signature prepare_triptych_signature private_key_to_keys random_entropy random_hash random_hashes random_point random_points random_scalar random_scalars root_hash root_hash_from_branch scalar_reduce secret_key_to_public_key sha256 sha3 sha384 sha3_slow sha512 toggle_masked_amount tree_branch tree_depth underive_public_key word_list word_list_trimmed force_js_library force_wasm_library init

Constructors

  • Protected

    We cannot create a new instance using this method as we need to await the loading of an underlying module, hence, we need to await the static init() method on this class to receive an instance of the class

    Returns Crypto

Properties

runtime_configuration: ModuleSettings = ...

Accessors

  • get external_library(): Partial<ICryptoLibrary>
  • Gets the external library calls that replace our cryptographic method calls

    Returns Partial<ICryptoLibrary>

  • set external_library(config): void
  • Sets external library calls that replace our cryptographic method calls

    Parameters

    Returns void

  • get is_native(): boolean
  • Returns if the underlying cryptographic library is of the Node.js C++ Addon type

    Returns boolean

  • get library_name(): string
  • Returns the underlying cryptographic library name

    Returns string

  • get library_type(): LibraryType
  • Returns the underlying cryptographic library type

    Returns LibraryType

  • get external_library(): Partial<ICryptoLibrary>
  • Gets the external library calls that replace our cryptographic method calls

    Returns Partial<ICryptoLibrary>

  • set external_library(config): void
  • Sets external library calls that replace our cryptographic method calls

    Parameters

    Returns void

  • get is_native(): boolean
  • Returns if the underlying cryptographic library is of the Node.js C++ Addon type

    Returns boolean

  • get library_name(): string
  • Returns the underlying cryptographic library name

    Returns string

  • get library_type(): LibraryType
  • Returns the underlying cryptographic library type

    Returns LibraryType

Methods

  • Decrypts the data from the provided hexidecimal encoded encrypted string using the supplied password

    Type Parameters

    • OutputType = string

    Parameters

    • input: string
    • password: string
    • Optionaliterations: number

    Returns Promise<OutputType>

  • Encrypts the provides string using the supplied password into a hexadecimal encoded string

    Type Parameters

    • InputType = string

    Parameters

    • input: InputType
    • password: string
    • Optionaliterations: number

    Returns Promise<string>

  • Hashes the input data using Argon2d and returns the resulting hash value

    Parameters

    • input: any
    • iterations: number = 1
    • memory: number = 256
    • threads: number = 1

    Returns Promise<string>

  • Hashes the input data using Argon2i and returns the resulting hash value

    Parameters

    • input: any
    • iterations: number = 1
    • memory: number = 256
    • threads: number = 1

    Returns Promise<string>

  • Hashes the input data using Argon2id and returns the resulting hash value

    Parameters

    • input: any
    • iterations: number = 1
    • memory: number = 256
    • threads: number = 1

    Returns Promise<string>

  • Decodes an address from Base58

    Parameters

    • base58: string

    Returns Promise<{
        prefix: number;
        public_spend: string;
        public_view?: string;
    }>

  • Encodes an address into Base58

    Parameters

    • prefix: number
    • public_spend: string
    • Optionalpublic_view: string

    Returns Promise<string>

  • Decodes a Base58 encoded string

    Parameters

    • base58: string

    Returns Promise<Buffer<ArrayBufferLike>>

  • Decodes a Base58 encoded string after verifying the checksum value included

    Parameters

    • base58: string

    Returns Promise<Buffer<ArrayBufferLike>>

  • Encodes the value specified into Base58

    Parameters

    • value: string | Buffer<ArrayBufferLike>

    Returns Promise<string>

  • Encodes the value specified into Base58 and appends a checksum to the result

    Parameters

    • value: string | Buffer<ArrayBufferLike>

    Returns Promise<string>

  • Hashes the input data using Blake2b and returns the resulting hash value

    Parameters

    • input: any

    Returns Promise<string>

  • Calculates the exponent of 2^e that matches the target value

    Parameters

    • value: number

    Returns Promise<number>

  • Checks a borromean ring signature to verify that it was created by one of the candidate public keys

    Parameters

    Returns Promise<boolean>

  • Checks that a Bulletproof proof is valid

    Parameters

    Returns Promise<boolean>

  • Checks that a Bulletproof+ proof is valid

    Parameters

    Returns Promise<boolean>

  • Checks a CLSAG ring signature to verify that it was created by one of the candidate public keys.

    Parameters

    • message_digest: string
    • key_image: string
    • public_keys: string[]
    • signature: crypto_clsag_signature_t
    • Optionalcommitments: string[]

    Returns Promise<boolean>

  • Verifies that the sum of output pedersen commitments plus a pedersen commitment of the transaction fee are equal to the sum of pseudo pedersen commitments

    Parameters

    • pseudo_commitments: string[]
    • output_commitments: string[]
    • transaction_fee: number

    Returns Promise<boolean>

  • Verifies the proof provides using the public ephemerals by decoding the Base58 proof, extracting the key images, the signatures, and then verifying if those signatures are all valid, in which case, the key images are returned

    Parameters

    • public_ephemerals: string[]
    • proof: string

    Returns Promise<string[]>

  • Checks if the value provided is a valid ED25519 point

    Parameters

    • value: string

    Returns Promise<boolean>

  • Checks an ED25519 RFC8032 signature to verify that it was created with the secret key of the public key specified

    Parameters

    • message: string
    • public_key: string
    • signature: string

    Returns Promise<boolean>

  • Checks if the value provided is a valid ED25519 scalar

    Parameters

    • value: string

    Returns Promise<boolean>

  • Checks a simple ED25519 signature to verify that it was created with the secret key of the public key specified

    Parameters

    • message_digest: string
    • public_key: string
    • signature: string

    Returns Promise<boolean>

  • Checks a Triptych ring signature to verify that it was created by one of the candidate public keys.

    Parameters

    Returns Promise<boolean>

  • Decodes an address from CryptoNote Base58

    Parameters

    • base58: string

    Returns Promise<{
        prefix: number;
        public_spend: string;
        public_view?: string;
    }>

  • Encodes an address into CryptoNote Base58

    Parameters

    • prefix: number
    • public_spend: string
    • Optionalpublic_view: string

    Returns Promise<string>

  • Decodes a CryptoNote Base58 string

    Parameters

    • base58: string

    Returns Promise<Buffer<ArrayBufferLike>>

  • Decodes a CryptoNote Base58 encoded string after verifying the checkvalue value included

    Parameters

    • base58: string

    Returns Promise<Buffer<ArrayBufferLike>>

  • Encodes the specified value into CryptoNote Base58

    Parameters

    • value: string | Buffer<ArrayBufferLike>

    Returns Promise<string>

  • Encodes the value specified into CryptoNote Base58 and appends a checksum to the result

    Parameters

    • value: string | Buffer<ArrayBufferLike>

    Returns Promise<string>

  • Completes a previously prepared CLSAG ring signature

    Parameters

    Returns Promise<crypto_clsag_signature_t>

  • Completes a previously prepared signature

    Parameters

    • secret_key: string
    • signature: string

    Returns Promise<string>

  • Derives a public ephemeral from a derivation scalar and a public key

    Note: P = [(Ds * G) + B] mod l

    Parameters

    • derivation_scalar: string
    • public_key: string

    Returns Promise<string>

  • Derives a secret ephemeral from a derivation scalar and a secret key

    Note: p = (Ds + b) mod l

    Parameters

    • derivation_scalar: string
    • secret_key: string

    Returns Promise<string>

  • Recovers entropy from a mnemonic phrase or a list of mnemonic phrase words

    Parameters

    • mnenomic_phrase: string | string[]
    • language: Language = Language.ENGLISH

    Returns Promise<crypto_entropy_t>

  • Generates the amount mask for the given deriviation scalar

    Parameters

    • derivation_scalar: string

    Returns Promise<string>

  • Generates a borromean ring signature for the message digest using the secret key specified and the list of all possible public key signing candidates

    Parameters

    • message_digest: string
    • secret_ephemeral: string
    • public_keys: string[]

    Returns Promise<crypto_borromean_signature_t>

  • Generates a Bulletproof Zero-Knowledge proof of the amount(s) specified

    Parameters

    • amounts: number[]
    • blinding_factors: string[]
    • N: number = 64

    Returns Promise<{
        commitments: string[];
        proof: crypto_bulletproof_t;
    }>

  • Generates a Bulletproof+ Zero-Knowledge proof of the amount(s) specified

    Parameters

    • amounts: number[]
    • blinding_factors: string[]
    • N: number = 64

    Returns Promise<{
        commitments: string[];
        proof: crypto_bulletproof_plus_t;
    }>

  • Generates a Hierarchical Deterministic Key Pair using the provided path

    Parameters

    • seed: string
    • OptionalpurposeOrPath: string | number

      the purpose (numeric) or path (e.g. m/44'/0'/1/3)

    • Optionalcoin_type: number
    • Optionalaccount: number
    • Optionalchange: number
    • Optionaladdress_index: number
    • hmac_key: string = 'ed25519 seed'

    Returns Promise<key_pair_t>

  • Generates a CLSAG ring signature for the message digest using the secret key specified and the list of all possible public key signing candidates.

    Optionally, we also include proof that we have the real values of the values hidden within pedersen commitments

    Parameters

    • message_digest: string
    • secret_ephemeral: string
    • public_keys: string[]
    • Optionalinput_blinding_factor: string
    • Optionalpublic_commitments: string[]
    • Optionalpseudo_blinding_factor: string
    • Optionalpseudo_commitment: string

    Returns Promise<crypto_clsag_signature_t>

  • Generates the commitment blinding factor for the given derivation scalar

    Parameters

    • derivation_scalar: string

    Returns Promise<string>

  • Generates a key derivation

    Note: D = (a * B) mod l

    Parameters

    • public_key: string
    • secret_key: string

    Returns Promise<string>

  • Generates a key derivation scalar value

    Note: Ds = H(D || output_index) mod l

    Parameters

    • derivation: string
    • output_index: number = 0

    Returns Promise<string>

  • Generates a key image from the public and secret ephemeral

    Parameters

    • public_ephemeral: string
    • secret_ephemeral: string

    Returns Promise<string>

  • Generates a V2 key image from the secret ephemeral

    Parameters

    • secret_ephemeral: string

    Returns Promise<string>

  • Generates a secret & public key pair

    Returns Promise<key_pair_t>

  • Generates a list pf secret & public keys

    Parameters

    • count: number = 1

    Returns Promise<{
        public_keys: string[];
        secret_keys: string[];
    }>

  • Generates proof of having the secret ephemerals specified by generating the relevant public keys, key_images, and signature for each and encoding the necessary information into a Base58 encoded string that can be provided to a verified that already has the public ephemerals

    Parameters

    • secret_ephemerals: string[]

    Returns Promise<string>

  • Generates a pedersen commitment for the supplied blinding factor and amount

    Note: C = (y * G) + (a * H) mod l

    Parameters

    • blinding_factor: string
    • amount: number

    Returns Promise<string>

  • Generates a list of random blinding factors and pseudo output commitments from the list of input amounts and the output commitments while proving them to a zero-sum

    Parameters

    • amounts: number[]
    • output_blinding_factors: string[]

    Returns Promise<{
        blinding_factors: string[];
        commitments: string[];
    }>

  • Generates an ED25519 RFC8032 signature for the message using the secret key specified

    Parameters

    • message: string
    • secret_key: string

    Returns Promise<string>

  • Generates a BIP-39 seed from the provided entropy

    Parameters

    • entropy: string
    • passphrase: string = ''

    Returns Promise<string>

  • Generates a simple ED25519 signature for the message digest using the secret key specified

    Parameters

    • message_digest: string
    • secret_key: string

    Returns Promise<string>

  • Generates a pedersen commitment for a transaction fee

    Parameters

    • amount: number

    Returns Promise<string>

  • Generates a Triptych ring signature for the message digest using the secret key specified and the list of all possible public key signing candidates.

    Optionally, we also include proof that we have the real values of the values hidden within pedersen commitments

    Parameters

    • message_digest: string
    • secret_ephemeral: string
    • public_keys: string[]
    • input_blinding_factor: string
    • public_commitments: string[]
    • pseudo_blinding_factor: string
    • pseudo_commitment: string

    Returns Promise<crypto_triptych_signature_t>

  • Generates an ED25519 point by hashing the provided data and turning it into a point on the ED25519 curve

    Parameters

    • input: any

    Returns Promise<string>

  • Generates an ED25519 scalar by hashing the provided data and reducing it to an ED25519 scalar value

    Parameters

    • input: any

    Returns Promise<string>

  • Returns a list of the supported languages

    Returns Promise<Language[]>

  • Generates a hardened Hierarchical Deterministic Key path

    Parameters

    • OptionalpurposeOrPath: string | number

      the purpose (numeric) or path (e.g. m/44'/0'/1/3)

    • Optionalcoin_type: number
    • Optionalaccount: number
    • Optionalchange: number
    • Optionaladdress_index: number

    Returns string

  • Decodes a mnemonic phrase or list of mnenomic words into as seed value

    Parameters

    • mnemonic: string | string[]
    • language: Language = Language.ENGLISH

    Returns Promise<crypto_entropy_t>

  • Encodes the supplied seed into a list of mnemonic words

    Parameters

    • entropy: string
    • language: Language = Language.ENGLISH

    Returns Promise<string[]>

  • Returns the index number of the specified mnemonic word

    Parameters

    • word: string
    • language: Language = Language.ENGLISH

    Returns Promise<number>

  • Prepares a borromean ring signature for the message digest such that it can be completed in later stages of signature construction

    Parameters

    • message_digest: string
    • key_image: string
    • public_keys: string[]
    • real_output_index: number

    Returns Promise<crypto_borromean_signature_t>

  • Prepares a CLSAG ring signature for the message digest such that it can be completed in later stages of signature construction

    Parameters

    • message_digest: string
    • key_image: string
    • public_keys: string[]
    • real_output_index: number
    • Optionalinput_blinding_factor: string
    • Optionalpublic_commitments: string[]
    • Optionalpseudo_blinding_factor: string
    • Optionalpseudo_commitment: string

    Returns Promise<{
        h: string[];
        mu_P: string;
        signature: crypto_clsag_signature_t;
    }>

  • Prepares a signature for the message digest such that it can be completed in later stages of the signature construction

    Parameters

    • message_digest: string
    • public_key: string

    Returns Promise<string>

  • Prepares a Triptych ring signature for the message digest such that it can be completed in later stages of signature construction

    Parameters

    • message_digest: string
    • key_image: string
    • public_keys: string[]
    • real_output_index: number
    • input_blinding_factor: string
    • public_commitments: string[]
    • pseudo_blinding_factor: string
    • pseudo_commitment: string

    Returns Promise<{
        signature: crypto_triptych_signature_t;
        xpow: string;
    }>

  • Calculates the secret scalar and public key for the provided ED25519 private key (aka seed)

    Parameters

    • private_key: string

    Returns Promise<key_pair_t>

  • Generates a random entropy value

    Parameters

    • Optionalentropy: string
    • bits: 128 | 256 = 256
    • encode_timestamp: boolean = true

    Returns Promise<crypto_entropy_t>

  • Generates a random hash value

    Returns Promise<string>

  • Generates a list of random hashes

    Parameters

    • count: number = 1

    Returns Promise<string[]>

  • Generates a random ED25519 point value

    Returns Promise<string>

  • Generates a list of random ED25519 points

    Parameters

    • count: number = 1

    Returns Promise<string[]>

  • Generates a random ED25519 scalar value

    Returns Promise<string>

  • Generates a list of random ED25519 scalars

    Parameters

    • count: number = 1

    Returns Promise<string[]>

  • Generates the root Merkle tree hash using the list of hashes

    Parameters

    • hashes: string[]

    Returns Promise<string>

  • Generates a Merkle tree root hash value from the supplied input values

    Parameters

    • branches: string[]
    • leaf: string
    • depth: number = 0
    • path: 0 | 1 = 0

    Returns Promise<string>

  • Reduces the input value to an ED25519 scalar value

    Parameters

    • input: string | Buffer<ArrayBufferLike>

    Returns Promise<string>

  • Calculates the public key of the given secret key

    Parameters

    • secret_key: string

    Returns Promise<string>

  • Hashes the input data using sha256 and returns the resulting hash value

    Parameters

    • input: any

    Returns Promise<string>

  • Hashes the input data using sha3 and returns the resulting hash value

    Parameters

    • input: any

    Returns Promise<string>

  • Hashes the input data using sha384 and returns the resulting hash value

    Parameters

    • input: any

    Returns Promise<string>

  • Hashes the input data using a simple SHA3 KDF function and returns the resulting hash value

    Parameters

    • input: string
    • iterations: number = 0

    Returns Promise<string>

  • Hashes the input data using sha512 and returns the resulting hash value

    Parameters

    • input: any

    Returns Promise<string>

  • Toggles an amount from unmasked/masked to the inverse state of masked/unmasked using the provided amount mask

    Parameters

    • amount_mask: string
    • amount: string | number | bigint

    Returns Promise<bigint>

  • Generates Merkle tree branch from the list of hashes

    Parameters

    • hashes: string[]

    Returns Promise<string[]>

  • Calculates the depth of the Merkle tree based upon how many hashes the tree contains

    Parameters

    • value: number

    Returns Promise<number>

  • Much like derive_public_key() but calculates the public_key used from the public ephemeral

    Note: B = P - [H(D || output_index) mod l]

    Parameters

    • derivation: string
    • public_ephemeral: string
    • output_index: number = 0

    Returns Promise<string>

  • Returns the list of mnemonic words

    Parameters

    Returns Promise<string[]>

  • Returns the list of mnemonic words that have been trimmed to the minimum number of characters per word

    Parameters

    Returns Promise<string[]>

  • Forces the library to use the Javascript ASM.js underlying cryptographic library if it can

    Returns Promise<boolean>

  • Forces the library to use the WASM underlying cryptographic library if it can

    Returns Promise<boolean>

  • Initializes a new instance of this class after attempting to load the underlying cryptographic library in the order the fastest running library to the slowest

    Parameters

    Returns Promise<Crypto>