-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
static interface
static final record
static final record
static interface
static interface
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static interface
static interface
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Crypto.ResultOfChaCha20
crypto.chacha20 Performs symmetric `chacha20` encryption.static void
clearCryptoBoxSecretCache
(Context ctx, Integer handle) crypto.clear_crypto_box_secret_cache Removes cached secrets (overwrites with zeroes) from all signing and encryption boxes, derived from crypto box.convertPublicKeyToTonSafeFormat
(Context ctx, String publicKey) crypto.convert_public_key_to_ton_safe_format Converts public key to ton safe_formatstatic Crypto.RegisteredCryptoBox
createCryptoBox
(Context ctx, String secretEncryptionSalt, Crypto.CryptoBoxSecret secretKey) crypto.create_crypto_box Creates a Crypto Box instance.createEncryptionBox
(Context ctx, Crypto.EncryptionAlgorithm algorithm) crypto.create_encryption_box Creates encryption box with specified algorithmencryptionBoxDecrypt
(Context ctx, Integer encryptionBox, String data) crypto.encryption_box_decrypt Decrypts data using given encryption box Note.encryptionBoxEncrypt
(Context ctx, Integer encryptionBox, String data) crypto.encryption_box_encrypt Encrypts data using given encryption box Note.encryptionBoxGetInfo
(Context ctx, Integer encryptionBox) crypto.encryption_box_get_info Queries info from the given encryption boxstatic Crypto.ResultOfFactorize
crypto.factorize Integer factorization Performs prime factorization – decomposition of a composite numberinto a product of smaller prime integers (factors).generateRandomBytes
(Context ctx, Number length) crypto.generate_random_bytes Generates random byte array of the specified length and returns it in `base64` formatstatic Crypto.KeyPair
crypto.generate_random_sign_keys Generates random ed25519 key pair.getCryptoBoxInfo
(Context ctx, Integer handle) crypto.get_crypto_box_info Get Crypto Box Info.getCryptoBoxSeedPhrase
(Context ctx, Integer handle) crypto.get_crypto_box_seed_phrase Get Crypto Box Seed Phrase.getEncryptionBoxFromCryptoBox
(Context ctx, Number handle, String hdpath, Crypto.BoxEncryptionAlgorithm algorithm, Number secretLifetime) crypto.get_encryption_box_from_crypto_box Gets Encryption Box from Crypto Box.static Crypto.RegisteredSigningBox
getSigningBox
(Context ctx, String publicKey, String secretKey) crypto.get_signing_box Creates a default signing box implementation.static Crypto.RegisteredSigningBox
getSigningBoxFromCryptoBox
(Context ctx, Number handle, String hdpath, Number secretLifetime) crypto.get_signing_box_from_crypto_box Get handle of Signing Box derived from Crypto Box.hdkeyDeriveFromXprv
(Context ctx, String xprv, Number childIndex, Boolean hardened) crypto.hdkey_derive_from_xprv Returns extended private key derived from the specified extended private key and child indexhdkeyDeriveFromXprvPath
(Context ctx, String xprv, String path) crypto.hdkey_derive_from_xprv_path Derives the extended private key from the specified key and pathhdkeyPublicFromXprv
(Context ctx, String xprv) crypto.hdkey_public_from_xprv Extracts the public key from the serialized extended private keyhdkeySecretFromXprv
(Context ctx, String xprv) crypto.hdkey_secret_from_xprv Extracts the private key from the serialized extended private keyhdkeyXprvFromMnemonic
(Context ctx, String phrase, Number dictionary, Number wordCount) crypto.hdkey_xprv_from_mnemonic Generates an extended master private key that will be the root for all the derived keysstatic Crypto.KeyPair
mnemonicDeriveSignKeys
(Context ctx, String phrase, String path, Number dictionary, Number wordCount) crypto.mnemonic_derive_sign_keys Derives a key pair for signing from the seed phrase Validates the seed phrase, generates master key and then derivesthe key pair from the master key and the specified pathmnemonicFromEntropy
(Context ctx, String entropy, Number dictionary, Number wordCount) crypto.mnemonic_from_entropy Generates mnemonic from pre-generated entropymnemonicFromRandom
(Context ctx, Number dictionary, Number wordCount) crypto.mnemonic_from_random Generates a random mnemonic Generates a random mnemonic from the specified dictionary and word countmnemonicVerify
(Context ctx, String phrase, Number dictionary, Number wordCount) crypto.mnemonic_verify Validates a mnemonic phrase The phrase supplied will be checked for word length and validated according to the checksumspecified in BIP0039.static Crypto.ResultOfMnemonicWords
mnemonicWords
(Context ctx, Number dictionary) crypto.mnemonic_words Prints the list of words from the specified dictionarystatic Crypto.ResultOfModularPower
modularPower
(Context ctx, String base, String exponent, String modulus) crypto.modular_power Modular exponentiation Performs modular exponentiation for big integers (`base`^`exponent` mod `modulus`).static Crypto.ResultOfNaclBox
crypto.nacl_box Public key authenticated encryption Encrypt and authenticate a message using the senders secret key, the receivers publickey, and a nonce.static Crypto.KeyPair
naclBoxKeypair
(Context ctx) crypto.nacl_box_keypair Generates a random NaCl key pairstatic Crypto.KeyPair
naclBoxKeypairFromSecretKey
(Context ctx, String secretKey) crypto.nacl_box_keypair_from_secret_key Generates key pair from a secret keystatic Crypto.ResultOfNaclBoxOpen
crypto.nacl_box_open Decrypt and verify the cipher text using the receivers secret key, the senders public key, and the nonce.static Crypto.ResultOfNaclBox
naclSecretBox
(Context ctx, String decrypted, String nonce, String key) crypto.nacl_secret_box Encrypt and authenticate message using nonce and secret key.static Crypto.ResultOfNaclBoxOpen
naclSecretBoxOpen
(Context ctx, String encrypted, String nonce, String key) crypto.nacl_secret_box_open Decrypts and verifies cipher text using `nonce` and secret `key`.static Crypto.ResultOfNaclSign
crypto.nacl_sign Signs data using the signer's secret key.naclSignDetached
(Context ctx, String unsigned, String secretKey) crypto.nacl_sign_detached Signs the message using the secret key and returns a signature.naclSignDetachedVerify
(Context ctx, String unsigned, String signature, String publicKey) crypto.nacl_sign_detached_verify Verifies the signature with public key and `unsigned` data.static Crypto.KeyPair
naclSignKeypairFromSecretKey
(Context ctx, String secretKey) crypto.nacl_sign_keypair_from_secret_key Generates a key pair for signing from the secret key **NOTE:** In the result the secret key is actually the concatenationof secret and public keys (128 symbols hex string) by design of NaCLstatic Crypto.ResultOfNaclSignOpen
naclSignOpen
(Context ctx, String signed, String publicKey) crypto.nacl_sign_open 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`.registerEncryptionBox
(Context ctx, AppEncryptionBox appObject) crypto.register_encryption_box Register an application implemented encryption box.static Crypto.RegisteredSigningBox
registerSigningBox
(Context ctx, AppSigningBox appObject) crypto.register_signing_box Register an application implemented signing box.static void
removeCryptoBox
(Context ctx, Integer handle) crypto.remove_crypto_box Removes Crypto Box.static void
removeEncryptionBox
(Context ctx, Integer handle) crypto.remove_encryption_box Removes encryption box from SDKstatic void
removeSigningBox
(Context ctx, Integer handle) crypto.remove_signing_box Removes signing box from SDK.static Crypto.ResultOfScrypt
crypto.scrypt Perform `scrypt` encryption Derives key from `password` and `key` using `scrypt` algorithm.static Crypto.ResultOfHash
crypto.sha256 Calculates SHA256 hash of the specified data.static Crypto.ResultOfHash
crypto.sha512 Calculates SHA512 hash of the specified data.static Crypto.ResultOfSign
sign
(Context ctx, String unsigned, Crypto.KeyPair keys) crypto.sign Signs a data using the provided keys.signingBoxGetPublicKey
(Context ctx, Integer handle) crypto.signing_box_get_public_key Returns public key of signing key pair.signingBoxSign
(Context ctx, Integer signingBox, String unsigned) crypto.signing_box_sign Returns signed user data.static Crypto.ResultOfTonCrc16
crypto.ton_crc16 Calculates CRC16 using TON algorithm.verifySignature
(Context ctx, String signed, String publicKey) crypto.verify_signature Verifies signed data using the provided public key.
-
Constructor Details
-
Crypto
public Crypto()
-
-
Method Details
-
factorize
public static Crypto.ResultOfFactorize factorize(Context ctx, String composite) throws EverSdkException crypto.factorize Integer factorization Performs prime factorization – decomposition of a composite numberinto a product of smaller prime integers (factors).- Parameters:
composite
- Hexadecimal representation of u64 composite number.- Returns:
Crypto.ResultOfFactorize
- Throws:
EverSdkException
-
modularPower
public static Crypto.ResultOfModularPower modularPower(Context ctx, String base, String exponent, String modulus) throws EverSdkException crypto.modular_power Modular exponentiation Performs modular exponentiation for big integers (`base`^`exponent` mod `modulus`).- Parameters:
base
- `base` argument of calculation.exponent
- `exponent` argument of calculation.modulus
- `modulus` argument of calculation.- Returns:
Crypto.ResultOfModularPower
- Throws:
EverSdkException
-
tonCrc16
crypto.ton_crc16 Calculates CRC16 using TON algorithm.- Parameters:
data
- Input data for CRC calculation. Encoded with `base64`.- Returns:
Crypto.ResultOfTonCrc16
- Throws:
EverSdkException
-
generateRandomBytes
public static Crypto.ResultOfGenerateRandomBytes generateRandomBytes(Context ctx, Number length) throws EverSdkException crypto.generate_random_bytes Generates random byte array of the specified length and returns it in `base64` format- Parameters:
length
- Size of random byte array.- Returns:
Crypto.ResultOfGenerateRandomBytes
- Throws:
EverSdkException
-
convertPublicKeyToTonSafeFormat
public static Crypto.ResultOfConvertPublicKeyToTonSafeFormat convertPublicKeyToTonSafeFormat(Context ctx, String publicKey) throws EverSdkException crypto.convert_public_key_to_ton_safe_format Converts public key to ton safe_format- Parameters:
publicKey
- Public key - 64 symbols hex string- Returns:
Crypto.ResultOfConvertPublicKeyToTonSafeFormat
- Throws:
EverSdkException
-
generateRandomSignKeys
crypto.generate_random_sign_keys Generates random ed25519 key pair.- Returns:
Crypto.KeyPair
- Throws:
EverSdkException
-
sign
public static Crypto.ResultOfSign sign(Context ctx, String unsigned, Crypto.KeyPair keys) throws EverSdkException crypto.sign Signs a data using the provided keys.- Parameters:
unsigned
- Data that must be signed encoded in `base64`.keys
- Sign keys.- Returns:
Crypto.ResultOfSign
- Throws:
EverSdkException
-
verifySignature
public static Crypto.ResultOfVerifySignature verifySignature(Context ctx, String signed, String publicKey) throws EverSdkException crypto.verify_signature Verifies signed data using the provided public key. Raises error if verification is failed.- Parameters:
signed
- Signed data that must be verified encoded in `base64`.publicKey
- Signer's public key - 64 symbols hex string- Returns:
Crypto.ResultOfVerifySignature
- Throws:
EverSdkException
-
sha256
crypto.sha256 Calculates SHA256 hash of the specified data.- Parameters:
data
- Input data for hash calculation. Encoded with `base64`.- Returns:
Crypto.ResultOfHash
- Throws:
EverSdkException
-
sha512
crypto.sha512 Calculates SHA512 hash of the specified data.- Parameters:
data
- Input data for hash calculation. Encoded with `base64`.- Returns:
Crypto.ResultOfHash
- Throws:
EverSdkException
-
scrypt
public static Crypto.ResultOfScrypt scrypt(Context ctx, String password, String salt, Number logN, Number r, Number p, Number dkLen) throws EverSdkException crypto.scrypt Perform `scrypt` encryption Derives key from `password` and `key` using `scrypt` algorithm.# Arguments- `log_n` - The log2 of the Scrypt parameter `N`- `r` - The Scrypt parameter `r`- `p` - The Scrypt parameter `p`# Conditions- `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`# Recommended values sufficient for most use-cases- `log_n = 15` (`n = 32768`)- `r = 8`- `p = 1`
- Parameters:
password
- The password bytes to be hashed. Must be encoded with `base64`.salt
- Salt bytes that modify the hash to protect against Rainbow table attacks. Must be encoded with `base64`.logN
- CPU/memory cost parameterr
- The block size parameter, which fine-tunes sequential memory read size and performance.p
- Parallelization parameter.dkLen
- Intended output length in octets of the derived key.- Returns:
Crypto.ResultOfScrypt
- Throws:
EverSdkException
-
naclSignKeypairFromSecretKey
public static Crypto.KeyPair naclSignKeypairFromSecretKey(Context ctx, String secretKey) throws EverSdkException crypto.nacl_sign_keypair_from_secret_key Generates a key pair for signing from the secret key **NOTE:** In the result the secret key is actually the concatenationof secret and public keys (128 symbols hex string) by design of NaCL- Parameters:
secretKey
- Secret key - unprefixed 0-padded to 64 symbols hex string- Returns:
Crypto.KeyPair
- Throws:
EverSdkException
-
naclSign
public static Crypto.ResultOfNaclSign naclSign(Context ctx, String unsigned, String secretKey) throws EverSdkException crypto.nacl_sign Signs data using the signer's secret key.- Parameters:
unsigned
- Data that must be signed encoded in `base64`.secretKey
- 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`.- Returns:
Crypto.ResultOfNaclSign
- Throws:
EverSdkException
-
naclSignOpen
public static Crypto.ResultOfNaclSignOpen naclSignOpen(Context ctx, String signed, String publicKey) throws EverSdkException crypto.nacl_sign_open 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.
- Parameters:
signed
- Signed data that must be unsigned. Encoded with `base64`.publicKey
- Signer's public key - unprefixed 0-padded to 64 symbols hex string- Returns:
Crypto.ResultOfNaclSignOpen
- Throws:
EverSdkException
-
naclSignDetached
public static Crypto.ResultOfNaclSignDetached naclSignDetached(Context ctx, String unsigned, String secretKey) throws EverSdkException crypto.nacl_sign_detached 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`.- Parameters:
unsigned
- Data that must be signed encoded in `base64`.secretKey
- 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`.- Returns:
Crypto.ResultOfNaclSignDetached
- Throws:
EverSdkException
-
naclSignDetachedVerify
public static Crypto.ResultOfNaclSignDetachedVerify naclSignDetachedVerify(Context ctx, String unsigned, String signature, String publicKey) throws EverSdkException crypto.nacl_sign_detached_verify Verifies the signature with public key and `unsigned` data.- Parameters:
unsigned
- Unsigned data that must be verified. Encoded with `base64`.signature
- Signature that must be verified. Encoded with `hex`.publicKey
- Signer's public key - unprefixed 0-padded to 64 symbols hex string.- Returns:
Crypto.ResultOfNaclSignDetachedVerify
- Throws:
EverSdkException
-
naclBoxKeypair
crypto.nacl_box_keypair Generates a random NaCl key pair- Returns:
Crypto.KeyPair
- Throws:
EverSdkException
-
naclBoxKeypairFromSecretKey
public static Crypto.KeyPair naclBoxKeypairFromSecretKey(Context ctx, String secretKey) throws EverSdkException crypto.nacl_box_keypair_from_secret_key Generates key pair from a secret key- Parameters:
secretKey
- Secret key - unprefixed 0-padded to 64 symbols hex string- Returns:
Crypto.KeyPair
- Throws:
EverSdkException
-
naclBox
public static Crypto.ResultOfNaclBox naclBox(Context ctx, String decrypted, String nonce, String theirPublic, String secretKey) throws EverSdkException crypto.nacl_box Public key authenticated encryption Encrypt and authenticate a message using the senders secret key, the receivers publickey, and a nonce.- Parameters:
decrypted
- Data that must be encrypted encoded in `base64`.nonce
- Nonce, encoded in `hex`theirPublic
- Receiver's public key - unprefixed 0-padded to 64 symbols hex stringsecretKey
- Sender's private key - unprefixed 0-padded to 64 symbols hex string- Returns:
Crypto.ResultOfNaclBox
- Throws:
EverSdkException
-
naclBoxOpen
public static Crypto.ResultOfNaclBoxOpen naclBoxOpen(Context ctx, String encrypted, String nonce, String theirPublic, String secretKey) throws EverSdkException crypto.nacl_box_open Decrypt and verify the cipher text using the receivers secret key, the senders public key, and the nonce.- Parameters:
encrypted
- Data that must be decrypted. Encoded with `base64`.nonce
- NoncetheirPublic
- Sender's public key - unprefixed 0-padded to 64 symbols hex stringsecretKey
- Receiver's private key - unprefixed 0-padded to 64 symbols hex string- Returns:
Crypto.ResultOfNaclBoxOpen
- Throws:
EverSdkException
-
naclSecretBox
public static Crypto.ResultOfNaclBox naclSecretBox(Context ctx, String decrypted, String nonce, String key) throws EverSdkException crypto.nacl_secret_box Encrypt and authenticate message using nonce and secret key.- Parameters:
decrypted
- Data that must be encrypted. Encoded with `base64`.nonce
- Nonce in `hex`key
- Secret key - unprefixed 0-padded to 64 symbols hex string- Returns:
Crypto.ResultOfNaclBox
- Throws:
EverSdkException
-
naclSecretBoxOpen
public static Crypto.ResultOfNaclBoxOpen naclSecretBoxOpen(Context ctx, String encrypted, String nonce, String key) throws EverSdkException crypto.nacl_secret_box_open Decrypts and verifies cipher text using `nonce` and secret `key`.- Parameters:
encrypted
- Data that must be decrypted. Encoded with `base64`.nonce
- Nonce in `hex`key
- Secret key - unprefixed 0-padded to 64 symbols hex string- Returns:
Crypto.ResultOfNaclBoxOpen
- Throws:
EverSdkException
-
mnemonicWords
public static Crypto.ResultOfMnemonicWords mnemonicWords(Context ctx, Number dictionary) throws EverSdkException crypto.mnemonic_words Prints the list of words from the specified dictionary- Parameters:
dictionary
- Dictionary identifier- Returns:
Crypto.ResultOfMnemonicWords
- Throws:
EverSdkException
-
mnemonicFromRandom
public static Crypto.ResultOfMnemonicFromRandom mnemonicFromRandom(Context ctx, Number dictionary, Number wordCount) throws EverSdkException crypto.mnemonic_from_random Generates a random mnemonic Generates a random mnemonic from the specified dictionary and word count- Parameters:
dictionary
- Dictionary identifierwordCount
- Mnemonic word count- Returns:
Crypto.ResultOfMnemonicFromRandom
- Throws:
EverSdkException
-
mnemonicFromEntropy
public static Crypto.ResultOfMnemonicFromEntropy mnemonicFromEntropy(Context ctx, String entropy, Number dictionary, Number wordCount) throws EverSdkException crypto.mnemonic_from_entropy Generates mnemonic from pre-generated entropy- Parameters:
entropy
- Entropy bytes. Hex encoded.dictionary
- Dictionary identifierwordCount
- Mnemonic word count- Returns:
Crypto.ResultOfMnemonicFromEntropy
- Throws:
EverSdkException
-
mnemonicVerify
public static Crypto.ResultOfMnemonicVerify mnemonicVerify(Context ctx, String phrase, Number dictionary, Number wordCount) throws EverSdkException crypto.mnemonic_verify Validates a mnemonic phrase The phrase supplied will be checked for word length and validated according to the checksumspecified in BIP0039.- Parameters:
phrase
- Phrasedictionary
- Dictionary identifierwordCount
- Word count- Returns:
Crypto.ResultOfMnemonicVerify
- Throws:
EverSdkException
-
mnemonicDeriveSignKeys
public static Crypto.KeyPair mnemonicDeriveSignKeys(Context ctx, String phrase, String path, Number dictionary, Number wordCount) throws EverSdkException crypto.mnemonic_derive_sign_keys Derives a key pair for signing from the seed phrase Validates the seed phrase, generates master key and then derivesthe key pair from the master key and the specified path- Parameters:
phrase
- Phrasepath
- Derivation path, for instance "m/44'/396'/0'/0/0"dictionary
- Dictionary identifierwordCount
- Word count- Returns:
Crypto.KeyPair
- Throws:
EverSdkException
-
hdkeyXprvFromMnemonic
public static Crypto.ResultOfHDKeyXPrvFromMnemonic hdkeyXprvFromMnemonic(Context ctx, String phrase, Number dictionary, Number wordCount) throws EverSdkException crypto.hdkey_xprv_from_mnemonic Generates an extended master private key that will be the root for all the derived keys- Parameters:
phrase
- String with seed phrasedictionary
- Dictionary identifierwordCount
- Mnemonic word count- Returns:
Crypto.ResultOfHDKeyXPrvFromMnemonic
- Throws:
EverSdkException
-
hdkeyDeriveFromXprv
public static Crypto.ResultOfHDKeyDeriveFromXPrv hdkeyDeriveFromXprv(Context ctx, String xprv, Number childIndex, Boolean hardened) throws EverSdkException crypto.hdkey_derive_from_xprv Returns extended private key derived from the specified extended private key and child index- Parameters:
xprv
- Serialized extended private keychildIndex
- Child index (see BIP-0032)hardened
- Indicates the derivation of hardened/not-hardened key (see BIP-0032)- Returns:
Crypto.ResultOfHDKeyDeriveFromXPrv
- Throws:
EverSdkException
-
hdkeyDeriveFromXprvPath
public static Crypto.ResultOfHDKeyDeriveFromXPrvPath hdkeyDeriveFromXprvPath(Context ctx, String xprv, String path) throws EverSdkException crypto.hdkey_derive_from_xprv_path Derives the extended private key from the specified key and path- Parameters:
xprv
- Serialized extended private keypath
- Derivation path, for instance "m/44'/396'/0'/0/0"- Returns:
Crypto.ResultOfHDKeyDeriveFromXPrvPath
- Throws:
EverSdkException
-
hdkeySecretFromXprv
public static Crypto.ResultOfHDKeySecretFromXPrv hdkeySecretFromXprv(Context ctx, String xprv) throws EverSdkException crypto.hdkey_secret_from_xprv Extracts the private key from the serialized extended private key- Parameters:
xprv
- Serialized extended private key- Returns:
Crypto.ResultOfHDKeySecretFromXPrv
- Throws:
EverSdkException
-
hdkeyPublicFromXprv
public static Crypto.ResultOfHDKeyPublicFromXPrv hdkeyPublicFromXprv(Context ctx, String xprv) throws EverSdkException crypto.hdkey_public_from_xprv Extracts the public key from the serialized extended private key- Parameters:
xprv
- Serialized extended private key- Returns:
Crypto.ResultOfHDKeyPublicFromXPrv
- Throws:
EverSdkException
-
chacha20
public static Crypto.ResultOfChaCha20 chacha20(Context ctx, String data, String key, String nonce) throws EverSdkException crypto.chacha20 Performs symmetric `chacha20` encryption.- Parameters:
data
- Source data to be encrypted or decrypted. Must be encoded with `base64`.key
- 256-bit key. Must be encoded with `hex`.nonce
- 96-bit nonce. Must be encoded with `hex`.- Returns:
Crypto.ResultOfChaCha20
- Throws:
EverSdkException
-
createCryptoBox
public static Crypto.RegisteredCryptoBox createCryptoBox(Context ctx, String secretEncryptionSalt, Crypto.CryptoBoxSecret secretKey) throws EverSdkException crypto.create_crypto_box 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 retrievedfrom `password_provider` callback, implemented on Application side.
When used, decrypted secret shows up in core library's memory for a very short periodof time and then is immediately overwritten with zeroes.
- Parameters:
secretEncryptionSalt
- Salt used for secret encryption. For example, a mobile device can use device ID as salt.secretKey
- Cryptobox secret- Returns:
Crypto.RegisteredCryptoBox
- Throws:
EverSdkException
-
removeCryptoBox
crypto.remove_crypto_box Removes Crypto Box. Clears all secret data.- Parameters:
handle
-- Throws:
EverSdkException
-
getCryptoBoxInfo
public static Crypto.ResultOfGetCryptoBoxInfo getCryptoBoxInfo(Context ctx, Integer handle) throws EverSdkException crypto.get_crypto_box_info Get Crypto Box Info. Used to get `encrypted_secret` that should be used for all the cryptobox initializations except the first one.- Parameters:
handle
-- Returns:
Crypto.ResultOfGetCryptoBoxInfo
- Throws:
EverSdkException
-
getCryptoBoxSeedPhrase
public static Crypto.ResultOfGetCryptoBoxSeedPhrase getCryptoBoxSeedPhrase(Context ctx, Integer handle) throws EverSdkException crypto.get_crypto_box_seed_phrase 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.- Parameters:
handle
-- Returns:
Crypto.ResultOfGetCryptoBoxSeedPhrase
- Throws:
EverSdkException
-
getSigningBoxFromCryptoBox
public static Crypto.RegisteredSigningBox getSigningBoxFromCryptoBox(Context ctx, Number handle, String hdpath, Number secretLifetime) throws EverSdkException crypto.get_signing_box_from_crypto_box Get handle of Signing Box derived from Crypto Box.- Parameters:
handle
- Crypto Box Handle.hdpath
- HD key derivation path. By default, Everscale HD path is used.secretLifetime
- 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.- Returns:
Crypto.RegisteredSigningBox
- Throws:
EverSdkException
-
getEncryptionBoxFromCryptoBox
public static Crypto.RegisteredEncryptionBox getEncryptionBoxFromCryptoBox(Context ctx, Number handle, String hdpath, Crypto.BoxEncryptionAlgorithm algorithm, Number secretLifetime) throws EverSdkException crypto.get_encryption_box_from_crypto_box Gets Encryption Box from Crypto Box. Derives encryption keypair from cryptobox secret and hdpath andstores 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 afterencryption operation.- Parameters:
handle
- Crypto Box Handle.hdpath
- HD key derivation path. By default, Everscale HD path is used.algorithm
- Encryption algorithm.secretLifetime
- 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.- Returns:
Crypto.RegisteredEncryptionBox
- Throws:
EverSdkException
-
clearCryptoBoxSecretCache
crypto.clear_crypto_box_secret_cache Removes cached secrets (overwrites with zeroes) from all signing and encryption boxes, derived from crypto box.- Parameters:
handle
-- Throws:
EverSdkException
-
registerSigningBox
public static Crypto.RegisteredSigningBox registerSigningBox(Context ctx, AppSigningBox appObject) throws EverSdkException crypto.register_signing_box Register an application implemented signing box.- Parameters:
appObject
-- Returns:
Crypto.RegisteredSigningBox
- Throws:
EverSdkException
-
getSigningBox
public static Crypto.RegisteredSigningBox getSigningBox(Context ctx, String publicKey, String secretKey) throws EverSdkException crypto.get_signing_box Creates a default signing box implementation.- Parameters:
publicKey
- Public key - 64 symbols hex stringsecretKey
- Private key - u64 symbols hex string- Returns:
Crypto.RegisteredSigningBox
- Throws:
EverSdkException
-
signingBoxGetPublicKey
public static Crypto.ResultOfSigningBoxGetPublicKey signingBoxGetPublicKey(Context ctx, Integer handle) throws EverSdkException crypto.signing_box_get_public_key Returns public key of signing key pair.- Parameters:
handle
- Handle of the signing box.- Returns:
Crypto.ResultOfSigningBoxGetPublicKey
- Throws:
EverSdkException
-
signingBoxSign
public static Crypto.ResultOfSigningBoxSign signingBoxSign(Context ctx, Integer signingBox, String unsigned) throws EverSdkException crypto.signing_box_sign Returns signed user data.- Parameters:
signingBox
- Signing Box handle.unsigned
- Unsigned user data. Must be encoded with `base64`.- Returns:
Crypto.ResultOfSigningBoxSign
- Throws:
EverSdkException
-
removeSigningBox
crypto.remove_signing_box Removes signing box from SDK.- Parameters:
handle
- Handle of the signing box.- Throws:
EverSdkException
-
registerEncryptionBox
public static Crypto.RegisteredEncryptionBox registerEncryptionBox(Context ctx, AppEncryptionBox appObject) throws EverSdkException crypto.register_encryption_box Register an application implemented encryption box.- Parameters:
appObject
-- Returns:
Crypto.RegisteredEncryptionBox
- Throws:
EverSdkException
-
removeEncryptionBox
crypto.remove_encryption_box Removes encryption box from SDK- Parameters:
handle
- Handle of the encryption box.- Throws:
EverSdkException
-
encryptionBoxGetInfo
public static Crypto.ResultOfEncryptionBoxGetInfo encryptionBoxGetInfo(Context ctx, Integer encryptionBox) throws EverSdkException crypto.encryption_box_get_info Queries info from the given encryption box- Parameters:
encryptionBox
- Encryption box handle- Returns:
Crypto.ResultOfEncryptionBoxGetInfo
- Throws:
EverSdkException
-
encryptionBoxEncrypt
public static Crypto.ResultOfEncryptionBoxEncrypt encryptionBoxEncrypt(Context ctx, Integer encryptionBox, String data) throws EverSdkException crypto.encryption_box_encrypt 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 afterdecryption to retrieve the original data from decrypted data.- Parameters:
encryptionBox
- Encryption box handledata
- Data to be encrypted, encoded in Base64- Returns:
Crypto.ResultOfEncryptionBoxEncrypt
- Throws:
EverSdkException
-
encryptionBoxDecrypt
public static Crypto.ResultOfEncryptionBoxDecrypt encryptionBoxDecrypt(Context ctx, Integer encryptionBox, String data) throws EverSdkException crypto.encryption_box_decrypt 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 afterdecryption to retrieve the original data from decrypted data.- Parameters:
encryptionBox
- Encryption box handledata
- Data to be decrypted, encoded in Base64- Returns:
Crypto.ResultOfEncryptionBoxDecrypt
- Throws:
EverSdkException
-
createEncryptionBox
public static Crypto.RegisteredEncryptionBox createEncryptionBox(Context ctx, Crypto.EncryptionAlgorithm algorithm) throws EverSdkException crypto.create_encryption_box Creates encryption box with specified algorithm- Parameters:
algorithm
- Encryption algorithm specifier including cipher parameters (key, IV, etc)- Returns:
Crypto.RegisteredEncryptionBox
- Throws:
EverSdkException
-