Module crypto
Last updated
Was this helpful?
Last updated
Was this helpful?
Crypto functions.
– Integer factorization
– Modular exponentiation
– Calculates CRC16 using TON algorithm.
– Generates random byte array of the specified length and returns it in base64
format
– Converts public key to ton safe_format
– Generates random ed25519 key pair.
– Signs a data using the provided keys.
– Verifies signed data using the provided public key. Raises error if verification is failed.
– Calculates SHA256 hash of the specified data.
– Calculates SHA512 hash of the specified data.
– Perform scrypt
encryption
– Generates a key pair for signing from the secret key
– Signs data using the signer's secret key.
Integer factorization
Performs prime factorization – decomposition of a composite number into a product of smaller prime integers (factors). See [https://en.wikipedia.org/wiki/Integer_factorization]
NOTE: Sync version is available only for lib-node
binding.
composite
: string – Hexadecimal representation of u64 composite number.
factors
: string[] – Two factors of composite or empty if composite can't be factorized.
Modular exponentiation
Performs modular exponentiation for big integers (base
^exponent
mod modulus
). See [https://en.wikipedia.org/wiki/Modular_exponentiation]
NOTE: Sync version is available only for lib-node
binding.
base
: string – base
argument of calculation.
exponent
: string – exponent
argument of calculation.
modulus
: string – modulus
argument of calculation.
modular_power
: string – Result of modular exponentiation
Calculates CRC16 using TON algorithm.
NOTE: Sync version is available only for lib-node
binding.
data
: string – Input data for CRC calculation.
Encoded with base64
.
crc
: number – Calculated CRC for input data.
Generates random byte array of the specified length and returns it in base64
format
NOTE: Sync version is available only for lib-node
binding.
length
: number – Size of random byte array.
bytes
: string – Generated bytes encoded in base64
.
Converts public key to ton safe_format
NOTE: Sync version is available only for lib-node
binding.
public_key
: string – Public key - 64 symbols hex string
ton_public_key
: string – Public key represented in TON safe format.
Generates random ed25519 key pair.
NOTE: Sync version is available only for lib-node
binding.
public
: string – Public key - 64 symbols hex string
secret
: string – Private key - u64 symbols hex string
Signs a data using the provided keys.
NOTE: Sync version is available only for lib-node
binding.
unsigned
: string – Data that must be signed encoded in base64
.
signed
: string – Signed data combined with signature encoded in base64
.
signature
: string – Signature encoded in hex
.
Verifies signed data using the provided public key. Raises error if verification is failed.
NOTE: Sync version is available only for lib-node
binding.
signed
: string – Signed data that must be verified encoded in base64
.
public
: string – Signer's public key - 64 symbols hex string
unsigned
: string – Unsigned data encoded in base64
.
Calculates SHA256 hash of the specified data.
NOTE: Sync version is available only for lib-node
binding.
data
: string – Input data for hash calculation.
Encoded with base64
.
hash
: string – Hash of input data
.
Encoded with 'hex'.
Calculates SHA512 hash of the specified data.
NOTE: Sync version is available only for lib-node
binding.
data
: string – Input data for hash calculation.
Encoded with base64
.
hash
: string – Hash of input data
.
Encoded with 'hex'.
Perform scrypt
encryption
Derives key from password
and key
using scrypt
algorithm. See [https://en.wikipedia.org/wiki/Scrypt].
log_n
- The log2 of the Scrypt parameter N
r
- The Scrypt parameter r
p
- The Scrypt parameter p
log_n
must be less than 64
r
must be greater than 0
and less than or equal to 4294967295
p
must be greater than 0
and less than 4294967295
log_n = 15
(n = 32768
)
r = 8
p = 1
NOTE: Sync version is available only for lib-node
binding.
password
: string – The password bytes to be hashed. Must be encoded with base64
.
salt
: string – Salt bytes that modify the hash to protect against Rainbow table attacks. Must be encoded with base64
.
log_n
: number – CPU/memory cost parameter
r
: number – The block size parameter, which fine-tunes sequential memory read size and performance.
p
: number – Parallelization parameter.
dk_len
: number – Intended output length in octets of the derived key.
key
: string – Derived key.
Encoded with hex
.
Generates a key pair for signing from the secret key
NOTE: Sync version is available only for lib-node
binding.
secret
: string – Secret key - unprefixed 0-padded to 64 symbols hex string
public
: string – Public key - 64 symbols hex string
secret
: string – Private key - u64 symbols hex string
Signs data using the signer's secret key.
NOTE: Sync version is available only for lib-node
binding.
unsigned
: string – Data that must be signed encoded in base64
.
secret
: string – Signer's secret key - unprefixed 0-padded to 128 symbols hex string (concatenation of 64 symbols secret and 64 symbols public keys). See nacl_sign_keypair_from_secret_key
.
signed
: string – Signed data, encoded in base64
.
Verifies the signature and returns the unsigned message
Verifies the signature in signed
using the signer's public key public
and returns the message unsigned
.
If the signature fails verification, crypto_sign_open raises an exception.
NOTE: Sync version is available only for lib-node
binding.
signed
: string – Signed data that must be unsigned.
Encoded with base64
.
public
: string – Signer's public key - unprefixed 0-padded to 64 symbols hex string
unsigned
: string – Unsigned data, encoded in base64
.
Signs the message using the secret key and returns a signature.
Signs the message unsigned
using the secret key secret
and returns a signature signature
.
NOTE: Sync version is available only for lib-node
binding.
unsigned
: string – Data that must be signed encoded in base64
.
secret
: string – Signer's secret key - unprefixed 0-padded to 128 symbols hex string (concatenation of 64 symbols secret and 64 symbols public keys). See nacl_sign_keypair_from_secret_key
.
signature
: string – Signature encoded in hex
.
Verifies the signature with public key and unsigned
data.
NOTE: Sync version is available only for lib-node
binding.
unsigned
: string – Unsigned data that must be verified.
Encoded with base64
.
signature
: string – Signature that must be verified.
Encoded with hex
.
public
: string – Signer's public key - unprefixed 0-padded to 64 symbols hex string.
succeeded
: boolean – true
if verification succeeded or false
if it failed
Generates a random NaCl key pair
NOTE: Sync version is available only for lib-node
binding.
public
: string – Public key - 64 symbols hex string
secret
: string – Private key - u64 symbols hex string
Generates key pair from a secret key
NOTE: Sync version is available only for lib-node
binding.
secret
: string – Secret key - unprefixed 0-padded to 64 symbols hex string
public
: string – Public key - 64 symbols hex string
secret
: string – Private key - u64 symbols hex string
Public key authenticated encryption
Encrypt and authenticate a message using the senders secret key, the receivers public key, and a nonce.
NOTE: Sync version is available only for lib-node
binding.
decrypted
: string – Data that must be encrypted encoded in base64
.
nonce
: string – Nonce, encoded in hex
their_public
: string – Receiver's public key - unprefixed 0-padded to 64 symbols hex string
secret
: string – Sender's private key - unprefixed 0-padded to 64 symbols hex string
encrypted
: string – Encrypted data encoded in base64
.
Decrypt and verify the cipher text using the receivers secret key, the senders public key, and the nonce.
NOTE: Sync version is available only for lib-node
binding.
encrypted
: string – Data that must be decrypted.
Encoded with base64
.
nonce
: string – Nonce
their_public
: string – Sender's public key - unprefixed 0-padded to 64 symbols hex string
secret
: string – Receiver's private key - unprefixed 0-padded to 64 symbols hex string
decrypted
: string – Decrypted data encoded in base64
.
Encrypt and authenticate message using nonce and secret key.
NOTE: Sync version is available only for lib-node
binding.
decrypted
: string – Data that must be encrypted.
Encoded with base64
.
nonce
: string – Nonce in hex
key
: string – Secret key - unprefixed 0-padded to 64 symbols hex string
encrypted
: string – Encrypted data encoded in base64
.
Decrypts and verifies cipher text using nonce
and secret key
.
NOTE: Sync version is available only for lib-node
binding.
encrypted
: string – Data that must be decrypted.
Encoded with base64
.
nonce
: string – Nonce in hex
key
: string – Secret key - unprefixed 0-padded to 64 symbols hex string
decrypted
: string – Decrypted data encoded in base64
.
Prints the list of words from the specified dictionary
NOTE: Sync version is available only for lib-node
binding.
words
: string – The list of mnemonic words
Generates a random mnemonic
Generates a random mnemonic from the specified dictionary and word count
NOTE: Sync version is available only for lib-node
binding.
word_count
?: number – Mnemonic word count
phrase
: string – String of mnemonic words
Generates mnemonic from pre-generated entropy
NOTE: Sync version is available only for lib-node
binding.
entropy
: string – Entropy bytes.
Hex encoded.
word_count
?: number – Mnemonic word count
phrase
: string – Phrase
Validates a mnemonic phrase
The phrase supplied will be checked for word length and validated according to the checksum specified in BIP0039.
NOTE: Sync version is available only for lib-node
binding.
phrase
: string – Phrase
word_count
?: number – Word count
valid
: boolean – Flag indicating if the mnemonic is valid or not
Derives a key pair for signing from the seed phrase
Validates the seed phrase, generates master key and then derives the key pair from the master key and the specified path
NOTE: Sync version is available only for lib-node
binding.
phrase
: string – Phrase
path
?: string – Derivation path, for instance "m/44'/396'/0'/0/0"
word_count
?: number – Word count
public
: string – Public key - 64 symbols hex string
secret
: string – Private key - u64 symbols hex string
Generates an extended master private key that will be the root for all the derived keys
NOTE: Sync version is available only for lib-node
binding.
phrase
: string – String with seed phrase
word_count
?: number – Mnemonic word count
xprv
: string – Serialized extended master private key
Returns extended private key derived from the specified extended private key and child index
NOTE: Sync version is available only for lib-node
binding.
xprv
: string – Serialized extended private key
child_index
: number – Child index (see BIP-0032)
hardened
: boolean – Indicates the derivation of hardened/not-hardened key (see BIP-0032)
xprv
: string – Serialized extended private key
Derives the extended private key from the specified key and path
NOTE: Sync version is available only for lib-node
binding.
xprv
: string – Serialized extended private key
path
: string – Derivation path, for instance "m/44'/396'/0'/0/0"
xprv
: string – Derived serialized extended private key
Extracts the private key from the serialized extended private key
NOTE: Sync version is available only for lib-node
binding.
xprv
: string – Serialized extended private key
secret
: string – Private key - 64 symbols hex string
Extracts the public key from the serialized extended private key
NOTE: Sync version is available only for lib-node
binding.
xprv
: string – Serialized extended private key
public
: string – Public key - 64 symbols hex string
Performs symmetric chacha20
encryption.
NOTE: Sync version is available only for lib-node
binding.
data
: string – Source data to be encrypted or decrypted.
Must be encoded with base64
.
key
: string – 256-bit key.
Must be encoded with hex
.
nonce
: string – 96-bit nonce.
Must be encoded with hex
.
data
: string – Encrypted/decrypted data.
Encoded with base64
.
Creates a Crypto Box instance.
Crypto Box is a root crypto object, that encapsulates some secret (seed phrase usually) in encrypted form and acts as a factory for all crypto primitives used in SDK: keys for signing and encryption, derived from this secret.
Crypto Box encrypts original Seed Phrase with salt and password that is retrieved from password_provider
callback, implemented on Application side.
When used, decrypted secret shows up in core library's memory for a very short period of time and then is immediately overwritten with zeroes.
NOTE: Sync version is available only for lib-node
binding.
secret_encryption_salt
: string – Salt used for secret encryption. For example, a mobile device can use device ID as salt.
Removes Crypto Box. Clears all secret data.
NOTE: Sync version is available only for lib-node
binding.
Get Crypto Box Info. Used to get encrypted_secret
that should be used for all the cryptobox initializations except the first one.
NOTE: Sync version is available only for lib-node
binding.
encrypted_secret
: string – Secret (seed phrase) encrypted with salt and password.
Get Crypto Box Seed Phrase.
Attention! Store this data in your application for a very short period of time and overwrite it with zeroes ASAP.
NOTE: Sync version is available only for lib-node
binding.
phrase
: string
wordcount
: number
Get handle of Signing Box derived from Crypto Box.
NOTE: Sync version is available only for lib-node
binding.
handle
: number – Crypto Box Handle.
hdpath
?: string – HD key derivation path.
By default, Everscale HD path is used.
secret_lifetime
?: number – Store derived secret for this lifetime (in ms). The timer starts after each signing box operation. Secrets will be deleted immediately after each signing box operation, if this value is not set.
Gets Encryption Box from Crypto Box.
Derives encryption keypair from cryptobox secret and hdpath and stores it in cache for secret_lifetime
or until explicitly cleared by clear_crypto_box_secret_cache
method. If secret_lifetime
is not specified - overwrites encryption secret with zeroes immediately after encryption operation.
NOTE: Sync version is available only for lib-node
binding.
handle
: number – Crypto Box Handle.
hdpath
?: string – HD key derivation path.
By default, Everscale HD path is used.
secret_lifetime
?: number – Store derived secret for encryption algorithm for this lifetime (in ms). The timer starts after each encryption box operation. Secrets will be deleted (overwritten with zeroes) after each encryption operation, if this value is not set.
Removes cached secrets (overwrites with zeroes) from all signing and encryption boxes, derived from crypto box.
NOTE: Sync version is available only for lib-node
binding.
Register an application implemented signing box.
NOTE: Sync version is available only for lib-node
binding.
Creates a default signing box implementation.
NOTE: Sync version is available only for lib-node
binding.
public
: string – Public key - 64 symbols hex string
secret
: string – Private key - u64 symbols hex string
Returns public key of signing key pair.
NOTE: Sync version is available only for lib-node
binding.
pubkey
: string – Public key of signing box.
Encoded with hex
Returns signed user data.
NOTE: Sync version is available only for lib-node
binding.
unsigned
: string – Unsigned user data.
Must be encoded with base64
.
signature
: string – Data signature.
Encoded with hex
.
Removes signing box from SDK.
NOTE: Sync version is available only for lib-node
binding.
Register an application implemented encryption box.
NOTE: Sync version is available only for lib-node
binding.
Removes encryption box from SDK
NOTE: Sync version is available only for lib-node
binding.
Queries info from the given encryption box
NOTE: Sync version is available only for lib-node
binding.
Encrypts data using given encryption box Note.
Block cipher algorithms pad data to cipher block size so encrypted data can be longer then original data. Client should store the original data size after encryption and use it after decryption to retrieve the original data from decrypted data.
NOTE: Sync version is available only for lib-node
binding.
data
: string – Data to be encrypted, encoded in Base64
data
: string – Encrypted data, encoded in Base64.
Padded to cipher block size
Decrypts data using given encryption box Note.
Block cipher algorithms pad data to cipher block size so encrypted data can be longer then original data. Client should store the original data size after encryption and use it after decryption to retrieve the original data from decrypted data.
NOTE: Sync version is available only for lib-node
binding.
data
: string – Data to be decrypted, encoded in Base64
data
: string – Decrypted data, encoded in Base64.
Creates encryption box with specified algorithm
NOTE: Sync version is available only for lib-node
binding.
One of the following value:
InvalidPublicKey = 100
InvalidSecretKey = 101
InvalidKey = 102
InvalidFactorizeChallenge = 106
InvalidBigInt = 107
ScryptFailed = 108
InvalidKeySize = 109
NaclSecretBoxFailed = 110
NaclBoxFailed = 111
NaclSignFailed = 112
Bip39InvalidEntropy = 113
Bip39InvalidPhrase = 114
Bip32InvalidKey = 115
Bip32InvalidDerivePath = 116
Bip39InvalidDictionary = 117
Bip39InvalidWordCount = 118
MnemonicGenerationFailed = 119
MnemonicFromEntropyFailed = 120
SigningBoxNotRegistered = 121
InvalidSignature = 122
EncryptionBoxNotRegistered = 123
InvalidIvSize = 124
UnsupportedCipherMode = 125
CannotCreateCipher = 126
EncryptDataError = 127
DecryptDataError = 128
IvRequired = 129
CryptoBoxNotRegistered = 130
InvalidCryptoBoxType = 131
CryptoBoxSecretSerializationError = 132
CryptoBoxSecretDeserializationError = 133
InvalidNonceSize = 134
Encryption box information.
hdpath
?: string – Derivation path, for instance "m/44'/396'/0'/0/0"
algorithm
?: string – Cryptographic algorithm, used by this encryption box
options
?: any – Options, depends on algorithm and specific encryption box implementation
public
?: any – Public information, depends on algorithm
Depends on value of the type
field.
When type is 'AES'
When type is 'ChaCha20'
When type is 'NaclBox'
When type is 'NaclSecretBox'
Variant constructors:
One of the following value:
CBC = "CBC"
CFB = "CFB"
CTR = "CTR"
ECB = "ECB"
OFB = "OFB"
key
: string
iv
?: string
iv
?: string
key
: string – 256-bit key.
Must be encoded with hex
.
nonce
: string – 96-bit nonce.
Must be encoded with hex
.
their_public
: string – 256-bit key.
Must be encoded with hex
.
secret
: string – 256-bit key.
Must be encoded with hex
.
nonce
: string – 96-bit nonce.
Must be encoded with hex
.
key
: string – Secret key - unprefixed 0-padded to 64 symbols hex string
nonce
: string – Nonce in hex
Creates Crypto Box from a random seed phrase. This option can be used if a developer doesn't want the seed phrase to leave the core library's memory, where it is stored encrypted.
This type should be used upon the first wallet initialization, all further initializations should use EncryptedSecret
type instead.
Get encrypted_secret
with get_crypto_box_info
function and store it on your side.
wordcount
: number
Restores crypto box instance from an existing seed phrase. This type should be used when Crypto Box is initialized from a seed phrase, entered by a user.
This type should be used only upon the first wallet initialization, all further initializations should use EncryptedSecret
type instead.
Get encrypted_secret
with get_crypto_box_info
function and store it on your side.
phrase
: string
wordcount
: number
Use this type for wallet reinitializations, when you already have encrypted_secret
on hands. To get encrypted_secret
, use get_crypto_box_info
function after you initialized your crypto box for the first time.
It is an object, containing seed phrase or private key, encrypted with secret_encryption_salt
and password from password_provider
.
Note that if you want to change salt or password provider, then you need to reinitialize the wallet with PredefinedSeedPhrase
, then get EncryptedSecret
via get_crypto_box_info
, store it somewhere, and only after that initialize the wallet with EncryptedSecret
type.
encrypted_secret
: string – It is an object, containing encrypted seed phrase or private key (now we support only seed phrase).
Crypto Box Secret.
Depends on value of the type
field.
When type is 'RandomSeedPhrase'
Creates Crypto Box from a random seed phrase. This option can be used if a developer doesn't want the seed phrase to leave the core library's memory, where it is stored encrypted.
This type should be used upon the first wallet initialization, all further initializations should use EncryptedSecret
type instead.
Get encrypted_secret
with get_crypto_box_info
function and store it on your side.
wordcount
: number
When type is 'PredefinedSeedPhrase'
Restores crypto box instance from an existing seed phrase. This type should be used when Crypto Box is initialized from a seed phrase, entered by a user.
This type should be used only upon the first wallet initialization, all further initializations should use EncryptedSecret
type instead.
Get encrypted_secret
with get_crypto_box_info
function and store it on your side.
phrase
: string
wordcount
: number
When type is 'EncryptedSecret'
Use this type for wallet reinitializations, when you already have encrypted_secret
on hands. To get encrypted_secret
, use get_crypto_box_info
function after you initialized your crypto box for the first time.
It is an object, containing seed phrase or private key, encrypted with secret_encryption_salt
and password from password_provider
.
Note that if you want to change salt or password provider, then you need to reinitialize the wallet with PredefinedSeedPhrase
, then get EncryptedSecret
via get_crypto_box_info
, store it somewhere, and only after that initialize the wallet with EncryptedSecret
type.
encrypted_secret
: string – It is an object, containing encrypted seed phrase or private key (now we support only seed phrase).
Variant constructors:
Depends on value of the type
field.
When type is 'ChaCha20'
When type is 'NaclBox'
When type is 'NaclSecretBox'
Variant constructors:
nonce
: string – 96-bit nonce.
Must be encoded with hex
.
their_public
: string – 256-bit key.
Must be encoded with hex
.
nonce
: string – 96-bit nonce.
Must be encoded with hex
.
nonce
: string – Nonce in hex
One of the following value:
Ton = 0
– TON compatible dictionary
English = 1
– English BIP-39 dictionary
ChineseSimplified = 2
– Chinese simplified BIP-39 dictionary
ChineseTraditional = 3
– Chinese traditional BIP-39 dictionary
French = 4
– French BIP-39 dictionary
Italian = 5
– Italian BIP-39 dictionary
Japanese = 6
– Japanese BIP-39 dictionary
Korean = 7
– Korean BIP-39 dictionary
Spanish = 8
– Spanish BIP-39 dictionary
composite
: string – Hexadecimal representation of u64 composite number.
factors
: string[] – Two factors of composite or empty if composite can't be factorized.
base
: string – base
argument of calculation.
exponent
: string – exponent
argument of calculation.
modulus
: string – modulus
argument of calculation.
modular_power
: string – Result of modular exponentiation
data
: string – Input data for CRC calculation.
Encoded with base64
.
crc
: number – Calculated CRC for input data.
length
: number – Size of random byte array.
bytes
: string – Generated bytes encoded in base64
.
public_key
: string – Public key - 64 symbols hex string
ton_public_key
: string – Public key represented in TON safe format.
public
: string – Public key - 64 symbols hex string
secret
: string – Private key - u64 symbols hex string
unsigned
: string – Data that must be signed encoded in base64
.
signed
: string – Signed data combined with signature encoded in base64
.
signature
: string – Signature encoded in hex
.
signed
: string – Signed data that must be verified encoded in base64
.
public
: string – Signer's public key - 64 symbols hex string
unsigned
: string – Unsigned data encoded in base64
.
data
: string – Input data for hash calculation.
Encoded with base64
.
hash
: string – Hash of input data
.
Encoded with 'hex'.
password
: string – The password bytes to be hashed. Must be encoded with base64
.
salt
: string – Salt bytes that modify the hash to protect against Rainbow table attacks. Must be encoded with base64
.
log_n
: number – CPU/memory cost parameter
r
: number – The block size parameter, which fine-tunes sequential memory read size and performance.
p
: number – Parallelization parameter.
dk_len
: number – Intended output length in octets of the derived key.
key
: string – Derived key.
Encoded with hex
.
secret
: string – Secret key - unprefixed 0-padded to 64 symbols hex string
unsigned
: string – Data that must be signed encoded in base64
.
secret
: string – Signer's secret key - unprefixed 0-padded to 128 symbols hex string (concatenation of 64 symbols secret and 64 symbols public keys). See nacl_sign_keypair_from_secret_key
.
signed
: string – Signed data, encoded in base64
.
signed
: string – Signed data that must be unsigned.
Encoded with base64
.
public
: string – Signer's public key - unprefixed 0-padded to 64 symbols hex string
unsigned
: string – Unsigned data, encoded in base64
.
signature
: string – Signature encoded in hex
.
unsigned
: string – Unsigned data that must be verified.
Encoded with base64
.
signature
: string – Signature that must be verified.
Encoded with hex
.
public
: string – Signer's public key - unprefixed 0-padded to 64 symbols hex string.
succeeded
: boolean – true
if verification succeeded or false
if it failed
secret
: string – Secret key - unprefixed 0-padded to 64 symbols hex string
decrypted
: string – Data that must be encrypted encoded in base64
.
nonce
: string – Nonce, encoded in hex
their_public
: string – Receiver's public key - unprefixed 0-padded to 64 symbols hex string
secret
: string – Sender's private key - unprefixed 0-padded to 64 symbols hex string
encrypted
: string – Encrypted data encoded in base64
.
encrypted
: string – Data that must be decrypted.
Encoded with base64
.
nonce
: string – Nonce
their_public
: string – Sender's public key - unprefixed 0-padded to 64 symbols hex string
secret
: string – Receiver's private key - unprefixed 0-padded to 64 symbols hex string
decrypted
: string – Decrypted data encoded in base64
.
decrypted
: string – Data that must be encrypted.
Encoded with base64
.
nonce
: string – Nonce in hex
key
: string – Secret key - unprefixed 0-padded to 64 symbols hex string
encrypted
: string – Data that must be decrypted.
Encoded with base64
.
nonce
: string – Nonce in hex
key
: string – Secret key - unprefixed 0-padded to 64 symbols hex string
words
: string – The list of mnemonic words
word_count
?: number – Mnemonic word count
phrase
: string – String of mnemonic words
entropy
: string – Entropy bytes.
Hex encoded.
word_count
?: number – Mnemonic word count
phrase
: string – Phrase
phrase
: string – Phrase
word_count
?: number – Word count
valid
: boolean – Flag indicating if the mnemonic is valid or not
phrase
: string – Phrase
path
?: string – Derivation path, for instance "m/44'/396'/0'/0/0"
word_count
?: number – Word count
phrase
: string – String with seed phrase
word_count
?: number – Mnemonic word count
xprv
: string – Serialized extended master private key
xprv
: string – Serialized extended private key
child_index
: number – Child index (see BIP-0032)
hardened
: boolean – Indicates the derivation of hardened/not-hardened key (see BIP-0032)
xprv
: string – Serialized extended private key
xprv
: string – Serialized extended private key
path
: string – Derivation path, for instance "m/44'/396'/0'/0/0"
xprv
: string – Derived serialized extended private key
xprv
: string – Serialized extended private key
secret
: string – Private key - 64 symbols hex string
xprv
: string – Serialized extended private key
public
: string – Public key - 64 symbols hex string
data
: string – Source data to be encrypted or decrypted.
Must be encoded with base64
.
key
: string – 256-bit key.
Must be encoded with hex
.
nonce
: string – 96-bit nonce.
Must be encoded with hex
.
data
: string – Encrypted/decrypted data.
Encoded with base64
.
secret_encryption_salt
: string – Salt used for secret encryption. For example, a mobile device can use device ID as salt.
encryption_public_key
: string – Temporary library pubkey, that is used on application side for password encryption, along with application temporary private key and nonce. Used for password decryption on library side.
Interface that provides a callback that returns an encrypted password, used for cryptobox secret encryption
To secure the password while passing it from application to the library, the library generates a temporary key pair, passes the pubkey to the passwordProvider, decrypts the received password with private key, and deletes the key pair right away.
Application should generate a temporary nacl_box_keypair and encrypt the password with naclbox function using nacl_box_keypair.secret and encryption_public_key keys + nonce = 24-byte prefix of encryption_public_key.
Depends on value of the type
field.
When type is 'GetPassword'
encryption_public_key
: string – Temporary library pubkey, that is used on application side for password encryption, along with application temporary private key and nonce. Used for password decryption on library side.
Variant constructors:
encrypted_password
: string – Password, encrypted and encoded to base64. Crypto box uses this password to decrypt its secret (seed phrase).
app_encryption_pubkey
: string – Hex encoded public key of a temporary key pair, used for password encryption on application side.
Used together with encryption_public_key
to decode encrypted_password
.
Depends on value of the type
field.
When type is 'GetPassword'
encrypted_password
: string – Password, encrypted and encoded to base64. Crypto box uses this password to decrypt its secret (seed phrase).
app_encryption_pubkey
: string – Hex encoded public key of a temporary key pair, used for password encryption on application side.
Used together with encryption_public_key
to decode encrypted_password
.
Variant constructors:
encrypted_secret
: string – Secret (seed phrase) encrypted with salt and password.
phrase
: string
wordcount
: number
handle
: number – Crypto Box Handle.
hdpath
?: string – HD key derivation path.
By default, Everscale HD path is used.
secret_lifetime
?: number – Store derived secret for this lifetime (in ms). The timer starts after each signing box operation. Secrets will be deleted immediately after each signing box operation, if this value is not set.
handle
: number – Crypto Box Handle.
hdpath
?: string – HD key derivation path.
By default, Everscale HD path is used.
secret_lifetime
?: number – Store derived secret for encryption algorithm for this lifetime (in ms). The timer starts after each encryption box operation. Secrets will be deleted (overwritten with zeroes) after each encryption operation, if this value is not set.
Get signing box public key
Sign data
unsigned
: string – Data to sign encoded as base64
Signing box callbacks.
Depends on value of the type
field.
When type is 'GetPublicKey'
Get signing box public key
When type is 'Sign'
Sign data
unsigned
: string – Data to sign encoded as base64
Variant constructors:
Result of getting public key
public_key
: string – Signing box public key
Result of signing data
signature
: string – Data signature encoded as hex
Returning values from signing box callbacks.
Depends on value of the type
field.
When type is 'GetPublicKey'
Result of getting public key
public_key
: string – Signing box public key
When type is 'Sign'
Result of signing data
signature
: string – Data signature encoded as hex
Variant constructors:
pubkey
: string – Public key of signing box.
Encoded with hex
unsigned
: string – Unsigned user data.
Must be encoded with base64
.
signature
: string – Data signature.
Encoded with hex
.
Get encryption box info
Encrypt data
data
: string – Data, encoded in Base64
Decrypt data
data
: string – Data, encoded in Base64
Interface for data encryption/decryption
Depends on value of the type
field.
When type is 'GetInfo'
Get encryption box info
When type is 'Encrypt'
Encrypt data
data
: string – Data, encoded in Base64
When type is 'Decrypt'
Decrypt data
data
: string – Data, encoded in Base64
Variant constructors:
Result of getting encryption box info
Result of encrypting data
data
: string – Encrypted data, encoded in Base64
Result of decrypting data
data
: string – Decrypted data, encoded in Base64
Returning values from signing box callbacks.
Depends on value of the type
field.
When type is 'GetInfo'
Result of getting encryption box info
When type is 'Encrypt'
Result of encrypting data
data
: string – Encrypted data, encoded in Base64
When type is 'Decrypt'
Result of decrypting data
data
: string – Decrypted data, encoded in Base64
Variant constructors:
data
: string – Data to be encrypted, encoded in Base64
data
: string – Encrypted data, encoded in Base64.
Padded to cipher block size
data
: string – Data to be decrypted, encoded in Base64
data
: string – Decrypted data, encoded in Base64.
Interface that provides a callback that returns an encrypted password, used for cryptobox secret encryption
To secure the password while passing it from application to the library, the library generates a temporary key pair, passes the pubkey to the passwordProvider, decrypts the received password with private key, and deletes the key pair right away.
Application should generate a temporary nacl_box_keypair and encrypt the password with naclbox function using nacl_box_keypair.secret and encryption_public_key keys + nonce = 24-byte prefix of encryption_public_key.
NOTE: Sync version is available only for lib-node
binding.
encryption_public_key
: string – Temporary library pubkey, that is used on application side for password encryption, along with application temporary private key and nonce. Used for password decryption on library side.
encrypted_password
: string – Password, encrypted and encoded to base64. Crypto box uses this password to decrypt its secret (seed phrase).
app_encryption_pubkey
: string – Hex encoded public key of a temporary key pair, used for password encryption on application side.
Used together with encryption_public_key
to decode encrypted_password
.
Signing box callbacks.
Get signing box public key
NOTE: Sync version is available only for lib-node
binding.
public_key
: string – Signing box public key
Sign data
NOTE: Sync version is available only for lib-node
binding.
unsigned
: string – Data to sign encoded as base64
signature
: string – Data signature encoded as hex
Interface for data encryption/decryption
Get encryption box info
NOTE: Sync version is available only for lib-node
binding.
Encrypt data
NOTE: Sync version is available only for lib-node
binding.
data
: string – Data, encoded in Base64
data
: string – Encrypted data, encoded in Base64
Decrypt data
NOTE: Sync version is available only for lib-node
binding.
data
: string – Data, encoded in Base64
data
: string – Decrypted data, encoded in Base64
– Verifies the signature and returns the unsigned message
– Signs the message using the secret key and returns a signature.
– Verifies the signature with public key and unsigned
data.
– Generates a random NaCl key pair
– Generates key pair from a secret key
– Public key authenticated encryption
– Decrypt and verify the cipher text using the receivers secret key, the senders public key, and the nonce.
– Encrypt and authenticate message using nonce and secret key.
– Decrypts and verifies cipher text using nonce
and secret key
.
– Prints the list of words from the specified dictionary
– Generates a random mnemonic
– Generates mnemonic from pre-generated entropy
– Validates a mnemonic phrase
– Derives a key pair for signing from the seed phrase
– Generates an extended master private key that will be the root for all the derived keys
– Returns extended private key derived from the specified extended private key and child index
– Derives the extended private key from the specified key and path
– Extracts the private key from the serialized extended private key
– Extracts the public key from the serialized extended private key
– Performs symmetric chacha20
encryption.
– Creates a Crypto Box instance.
– Removes Crypto Box. Clears all secret data.
– Get Crypto Box Info. Used to get encrypted_secret
that should be used for all the cryptobox initializations except the first one.
– Get Crypto Box Seed Phrase.
– Get handle of Signing Box derived from Crypto Box.
– Gets Encryption Box from Crypto Box.
– Removes cached secrets (overwrites with zeroes) from all signing and encryption boxes, derived from crypto box.
– Register an application implemented signing box.
– Creates a default signing box implementation.
– Returns public key of signing key pair.
– Returns signed user data.
– Removes signing box from SDK.
– Register an application implemented encryption box.
– Removes encryption box from SDK
– Queries info from the given encryption box
– Encrypts data using given encryption box Note.
– Decrypts data using given encryption box Note.
– Creates encryption box with specified algorithm
– Encryption box information.
– Creates Crypto Box from a random seed phrase. This option can be used if a developer doesn't want the seed phrase to leave the core library's memory, where it is stored encrypted.
– Restores crypto box instance from an existing seed phrase. This type should be used when Crypto Box is initialized from a seed phrase, entered by a user.
– Use this type for wallet reinitializations, when you already have encrypted_secret
on hands. To get encrypted_secret
, use get_crypto_box_info
function after you initialized your crypto box for the first time.
– Crypto Box Secret.
– Interface that provides a callback that returns an encrypted password, used for cryptobox secret encryption
– Get signing box public key
– Sign data
– Signing box callbacks.
– Result of getting public key
– Result of signing data
– Returning values from signing box callbacks.
– Get encryption box info
– Encrypt data
– Decrypt data
– Interface for data encryption/decryption
– Result of getting encryption box info
– Result of encrypting data
– Result of decrypting data
– Returning values from signing box callbacks.
– Interface that provides a callback that returns an encrypted password, used for cryptobox secret encryption
– Signing box callbacks.
– Interface for data encryption/decryption
keys
: – Sign keys.
NOTE: In the result the secret key is actually the concatenation of secret and public keys (128 symbols hex string) by design of . See also .
dictionary
?: – Dictionary identifier
dictionary
?: – Dictionary identifier
dictionary
?: – Dictionary identifier
dictionary
?: – Dictionary identifier
dictionary
?: – Dictionary identifier
dictionary
?: – Dictionary identifier
secret
: – Cryptobox secret
obj
: – Interface that provides a callback that returns an encrypted password, used for cryptobox secret encryption
handle
:
handle
:
handle
:
handle
:
dictionary
:
handle
: – Handle of the signing box.
algorithm
: – Encryption algorithm.
handle
: – Handle of the encryption box.
handle
:
obj
: – Signing box callbacks.
handle
: – Handle of the signing box.
handle
: – Handle of the signing box.
handle
: – Handle of the signing box.
signing_box
: – Signing Box handle.
handle
: – Handle of the signing box.
obj
: – Interface for data encryption/decryption
handle
: – Handle of the encryption box.
handle
: – Handle of the encryption box.
encryption_box
: – Encryption box handle
info
: – Encryption box information
encryption_box
: – Encryption box handle
encryption_box
: – Encryption box handle
algorithm
: – Encryption algorithm specifier including cipher parameters (key, IV, etc)
handle
: – Handle of the encryption box.
value
:
value
:
value
:
value
:
value
:
value
:
value
:
value
:
mode
:
mode
:
dictionary
:
dictionary
:
dictionary
:
dictionary
:
value
:
value
:
value
:
value
:
value
:
value
:
keys
: – Sign keys.
dictionary
?: – Dictionary identifier
dictionary
?: – Dictionary identifier
dictionary
?: – Dictionary identifier
dictionary
?: – Dictionary identifier
dictionary
?: – Dictionary identifier
dictionary
?: – Dictionary identifier
secret
: – Cryptobox secret
handle
:
dictionary
:
handle
: – Handle of the signing box.
algorithm
: – Encryption algorithm.
handle
: – Handle of the encryption box.
signing_box
: – Signing Box handle.
info
:
info
:
encryption_box
: – Encryption box handle
info
: – Encryption box information
encryption_box
: – Encryption box handle
encryption_box
: – Encryption box handle
algorithm
: – Encryption algorithm specifier including cipher parameters (key, IV, etc)
info
: