java.lang.Object
tech.deplant.java4ever.binding.Crypto
Crypto
Contains methods of "crypto" module of EVER-SDK API
Crypto functions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
static final record
static interface
static final record
static final record
static enum
static interface
Crypto Box Secret.static enum
static interface
static final record
Encryption box information.static final record
static enum
static final record
static final record
static final record
static final record
static interface
Interface for data encryption/decryptionstatic interface
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.static interface
Signing box callbacks.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
Returning values from signing box callbacks.static interface
static interface
Returning values from signing box callbacks.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
chacha20
(EverSdkContext ctx, String data, String key, String nonce) Performs symmetric `chacha20` encryption.static void
Removes cached secrets (overwrites with zeroes) from all signing and encryption boxes, derived from crypto box.convertPublicKeyToTonSafeFormat
(EverSdkContext ctx, String publicKey) Converts public key to ton safe_formatstatic Crypto.RegisteredCryptoBox
createCryptoBox
(EverSdkContext ctx, String secretEncryptionSalt, Crypto.CryptoBoxSecret secretKey, AppSigningBox appObject) 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.createEncryptionBox
(EverSdkContext ctx, Crypto.EncryptionAlgorithm algorithm) Creates encryption box with specified algorithmencryptionBoxDecrypt
(EverSdkContext ctx, Long encryptionBox, String data) Block cipher algorithms pad data to cipher block size so encrypted data can be longer then original data.encryptionBoxEncrypt
(EverSdkContext ctx, Long encryptionBox, String data) Block cipher algorithms pad data to cipher block size so encrypted data can be longer then original data.encryptionBoxGetInfo
(EverSdkContext ctx, Long encryptionBox) Queries info from the given encryption boxstatic Crypto.ResultOfFactorize
factorize
(EverSdkContext ctx, String composite) Performs prime factorization – decomposition of a composite number into a product of smaller prime integers (factors).generateRandomBytes
(EverSdkContext ctx, Long length) Generates random byte array of the specified length and returns it in `base64` formatstatic Crypto.KeyPair
Generates random ed25519 key pair.getCryptoBoxInfo
(EverSdkContext ctx, Crypto.RegisteredCryptoBox params) Get Crypto Box Info.Attention!getEncryptionBoxFromCryptoBox
(EverSdkContext ctx, Long handle, String hdpath, Crypto.BoxEncryptionAlgorithm algorithm, Long secretLifetime) 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.static Crypto.RegisteredSigningBox
getSigningBox
(EverSdkContext ctx, Crypto.KeyPair params) Creates a default signing box implementation.static Crypto.RegisteredSigningBox
getSigningBoxFromCryptoBox
(EverSdkContext ctx, Long handle, String hdpath, Long secretLifetime) Get handle of Signing Box derived from Crypto Box.hdkeyDeriveFromXprv
(EverSdkContext ctx, String xprv, Long childIndex, Boolean hardened) Returns extended private key derived from the specified extended private key and child indexhdkeyDeriveFromXprvPath
(EverSdkContext ctx, String xprv, String path) Derives the extended private key from the specified key and pathhdkeyPublicFromXprv
(EverSdkContext ctx, String xprv) Extracts the public key from the serialized extended private keyhdkeySecretFromXprv
(EverSdkContext ctx, String xprv) Extracts the private key from the serialized extended private keyhdkeyXprvFromMnemonic
(EverSdkContext ctx, String phrase, Crypto.MnemonicDictionary dictionary, Integer wordCount) Generates an extended master private key that will be the root for all the derived keysstatic Crypto.KeyPair
mnemonicDeriveSignKeys
(EverSdkContext ctx, String phrase, String path, Crypto.MnemonicDictionary dictionary, Integer wordCount) Validates the seed phrase, generates master key and then derives the key pair from the master key and the specified path Derives a key pair for signing from the seed phrasemnemonicFromEntropy
(EverSdkContext ctx, String entropy, Crypto.MnemonicDictionary dictionary, Integer wordCount) Generates mnemonic from pre-generated entropymnemonicFromRandom
(EverSdkContext ctx, Crypto.MnemonicDictionary dictionary, Integer wordCount) Generates a random mnemonic from the specified dictionary and word count Generates a random mnemonicmnemonicVerify
(EverSdkContext ctx, String phrase, Crypto.MnemonicDictionary dictionary, Integer wordCount) The phrase supplied will be checked for word length and validated according to the checksum specified in BIP0039.static Crypto.ResultOfMnemonicWords
mnemonicWords
(EverSdkContext ctx, Crypto.MnemonicDictionary dictionary) Prints the list of words from the specified dictionarystatic Crypto.ResultOfModularPower
modularPower
(EverSdkContext ctx, String base, String exponent, String modulus) Performs modular exponentiation for big integers (`base`^`exponent` mod `modulus`).static Crypto.ResultOfNaclBox
Encrypt and authenticate a message using the senders secret key, the receivers public key, and a nonce.static Crypto.KeyPair
Generates a random NaCl key pairstatic Crypto.KeyPair
naclBoxKeypairFromSecretKey
(EverSdkContext ctx, String secretKey) Generates key pair from a secret keystatic Crypto.ResultOfNaclBoxOpen
naclBoxOpen
(EverSdkContext ctx, String encrypted, String nonce, String theirPublic, String secretKey) Decrypt and verify the cipher text using the receivers secret key, the senders public key, and the nonce.static Crypto.ResultOfNaclBox
naclSecretBox
(EverSdkContext ctx, String decrypted, String nonce, String key) Encrypt and authenticate message using nonce and secret key.static Crypto.ResultOfNaclBoxOpen
naclSecretBoxOpen
(EverSdkContext ctx, String encrypted, String nonce, String key) Decrypts and verifies cipher text using `nonce` and secret `key`.static Crypto.ResultOfNaclSign
naclSign
(EverSdkContext ctx, String unsigned, String secretKey) Signs data using the signer's secret key.naclSignDetached
(EverSdkContext ctx, String unsigned, String secretKey) Signs the message `unsigned` using the secret key `secret` and returns a signature `signature`.naclSignDetachedVerify
(EverSdkContext ctx, String unsigned, String signature, String publicKey) Verifies the signature with public key and `unsigned` data.static Crypto.KeyPair
naclSignKeypairFromSecretKey
(EverSdkContext ctx, String secretKey) **NOTE:** In the result the secret key is actually the concatenation of secret and public keys (128 symbols hex string) by design of [NaCL](http://nacl.cr.yp.to/sign.html).static Crypto.ResultOfNaclSignOpen
naclSignOpen
(EverSdkContext ctx, String signed, String publicKey) Verifies the signature in `signed` using the signer's public key `public` and returns the message `unsigned`.registerEncryptionBox
(EverSdkContext ctx, AppSigningBox appObject) Register an application implemented encryption box.static Crypto.RegisteredSigningBox
registerSigningBox
(EverSdkContext ctx, AppSigningBox appObject) Register an application implemented signing box.static void
removeCryptoBox
(EverSdkContext ctx, Crypto.RegisteredCryptoBox params) Removes Crypto Box.static void
Removes encryption box from SDKstatic void
removeSigningBox
(EverSdkContext ctx, Crypto.RegisteredSigningBox params) Removes signing box from SDK.static Crypto.ResultOfScrypt
Derives key from `password` and `key` using `scrypt` algorithm.static Crypto.ResultOfHash
sha256
(EverSdkContext ctx, String data) Calculates SHA256 hash of the specified data.static Crypto.ResultOfHash
sha512
(EverSdkContext ctx, String data) Calculates SHA512 hash of the specified data.static Crypto.ResultOfSign
sign
(EverSdkContext ctx, String unsigned, Crypto.KeyPair keys) Signs a data using the provided keys.Returns public key of signing key pair.signingBoxSign
(EverSdkContext ctx, Long signingBox, String unsigned) Returns signed user data.static Crypto.ResultOfTonCrc16
tonCrc16
(EverSdkContext ctx, String data) Calculates CRC16 using TON algorithm.verifySignature
(EverSdkContext ctx, String signed, String publicKey) Verifies signed data using the provided public key.
-
Constructor Details
-
Crypto
public Crypto()
-
-
Method Details
-
factorize
public static Crypto.ResultOfFactorize factorize(EverSdkContext ctx, String composite) throws EverSdkException Performs prime factorization – decomposition of a composite number into a product of smaller prime integers (factors). See [https://en.wikipedia.org/wiki/Integer_factorization] Integer factorization- Parameters:
composite
- Hexadecimal representation of u64 composite number.- Throws:
EverSdkException
-
modularPower
public static Crypto.ResultOfModularPower modularPower(EverSdkContext ctx, String base, String exponent, String modulus) throws EverSdkException Performs modular exponentiation for big integers (`base`^`exponent` mod `modulus`). See [https://en.wikipedia.org/wiki/Modular_exponentiation] Modular exponentiation- Parameters:
base
- `base` argument of calculation.exponent
- `exponent` argument of calculation.modulus
- `modulus` argument of calculation.- Throws:
EverSdkException
-
tonCrc16
public static Crypto.ResultOfTonCrc16 tonCrc16(EverSdkContext ctx, String data) throws EverSdkException Calculates CRC16 using TON algorithm.- Parameters:
data
- Encoded with `base64`. Input data for CRC calculation.- Throws:
EverSdkException
-
generateRandomBytes
public static Crypto.ResultOfGenerateRandomBytes generateRandomBytes(EverSdkContext ctx, Long length) throws EverSdkException Generates random byte array of the specified length and returns it in `base64` format- Parameters:
length
- Size of random byte array.- Throws:
EverSdkException
-
convertPublicKeyToTonSafeFormat
public static Crypto.ResultOfConvertPublicKeyToTonSafeFormat convertPublicKeyToTonSafeFormat(EverSdkContext ctx, String publicKey) throws EverSdkException Converts public key to ton safe_format- Parameters:
publicKey
- Public key - 64 symbols hex string- Throws:
EverSdkException
-
generateRandomSignKeys
Generates random ed25519 key pair.- Throws:
EverSdkException
-
sign
public static Crypto.ResultOfSign sign(EverSdkContext ctx, String unsigned, Crypto.KeyPair keys) throws EverSdkException Signs a data using the provided keys.- Parameters:
unsigned
- Data that must be signed encoded in `base64`.keys
- Sign keys.- Throws:
EverSdkException
-
verifySignature
public static Crypto.ResultOfVerifySignature verifySignature(EverSdkContext ctx, String signed, String publicKey) throws EverSdkException 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- Throws:
EverSdkException
-
sha256
Calculates SHA256 hash of the specified data.- Parameters:
data
- Encoded with `base64`. Input data for hash calculation.- Throws:
EverSdkException
-
sha512
Calculates SHA512 hash of the specified data.- Parameters:
data
- Encoded with `base64`. Input data for hash calculation.- Throws:
EverSdkException
-
scrypt
public static Crypto.ResultOfScrypt scrypt(EverSdkContext ctx, String password, String salt, Integer logN, Long r, Long p, Long dkLen) throws EverSdkException Derives key from `password` and `key` using `scrypt` algorithm. See [https://en.wikipedia.org/wiki/Scrypt]. # 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` Perform `scrypt` encryption- 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.- Throws:
EverSdkException
-
naclSignKeypairFromSecretKey
public static Crypto.KeyPair naclSignKeypairFromSecretKey(EverSdkContext ctx, String secretKey) throws EverSdkException **NOTE:** In the result the secret key is actually the concatenation of secret and public keys (128 symbols hex string) by design of [NaCL](http://nacl.cr.yp.to/sign.html). See also [the stackexchange question](https://crypto.stackexchange.com/questions/54353/). Generates a key pair for signing from the secret key- Parameters:
secretKey
- Secret key - unprefixed 0-padded to 64 symbols hex string- Throws:
EverSdkException
-
naclSign
public static Crypto.ResultOfNaclSign naclSign(EverSdkContext ctx, String unsigned, String secretKey) throws EverSdkException 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`.- Throws:
EverSdkException
-
naclSignOpen
public static Crypto.ResultOfNaclSignOpen naclSignOpen(EverSdkContext ctx, String signed, String publicKey) throws EverSdkException 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. Verifies the signature and returns the unsigned message- Parameters:
signed
- Encoded with `base64`. Signed data that must be unsigned.publicKey
- Signer's public key - unprefixed 0-padded to 64 symbols hex string- Throws:
EverSdkException
-
naclSignDetached
public static Crypto.ResultOfNaclSignDetached naclSignDetached(EverSdkContext ctx, String unsigned, String secretKey) throws EverSdkException Signs the message `unsigned` using the secret key `secret` and returns a signature `signature`. Signs the message using the secret key and returns a 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`.- Throws:
EverSdkException
-
naclSignDetachedVerify
public static Crypto.ResultOfNaclSignDetachedVerify naclSignDetachedVerify(EverSdkContext ctx, String unsigned, String signature, String publicKey) throws EverSdkException Verifies the signature with public key and `unsigned` data.- Parameters:
unsigned
- Encoded with `base64`. Unsigned data that must be verified.signature
- Encoded with `hex`. Signature that must be verified.publicKey
- Signer's public key - unprefixed 0-padded to 64 symbols hex string.- Throws:
EverSdkException
-
naclBoxKeypair
Generates a random NaCl key pair- Throws:
EverSdkException
-
naclBoxKeypairFromSecretKey
public static Crypto.KeyPair naclBoxKeypairFromSecretKey(EverSdkContext ctx, String secretKey) throws EverSdkException Generates key pair from a secret key- Parameters:
secretKey
- Secret key - unprefixed 0-padded to 64 symbols hex string- Throws:
EverSdkException
-
naclBox
public static Crypto.ResultOfNaclBox naclBox(EverSdkContext ctx, String decrypted, String nonce, String theirPublic, String secretKey) throws EverSdkException Encrypt and authenticate a message using the senders secret key, the receivers public key, and a nonce. Public key authenticated encryption- 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- Throws:
EverSdkException
-
naclBoxOpen
public static Crypto.ResultOfNaclBoxOpen naclBoxOpen(EverSdkContext ctx, String encrypted, String nonce, String theirPublic, String secretKey) throws EverSdkException Decrypt and verify the cipher text using the receivers secret key, the senders public key, and the nonce.- Parameters:
encrypted
- Encoded with `base64`. Data that must be decrypted.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- Throws:
EverSdkException
-
naclSecretBox
public static Crypto.ResultOfNaclBox naclSecretBox(EverSdkContext ctx, String decrypted, String nonce, String key) throws EverSdkException Encrypt and authenticate message using nonce and secret key.- Parameters:
decrypted
- Encoded with `base64`. Data that must be encrypted.nonce
- Nonce in `hex`key
- Secret key - unprefixed 0-padded to 64 symbols hex string- Throws:
EverSdkException
-
naclSecretBoxOpen
public static Crypto.ResultOfNaclBoxOpen naclSecretBoxOpen(EverSdkContext ctx, String encrypted, String nonce, String key) throws EverSdkException Decrypts and verifies cipher text using `nonce` and secret `key`.- Parameters:
encrypted
- Encoded with `base64`. Data that must be decrypted.nonce
- Nonce in `hex`key
- Secret key - unprefixed 0-padded to 64 symbols hex string- Throws:
EverSdkException
-
mnemonicWords
public static Crypto.ResultOfMnemonicWords mnemonicWords(EverSdkContext ctx, Crypto.MnemonicDictionary dictionary) throws EverSdkException Prints the list of words from the specified dictionary- Parameters:
dictionary
- Dictionary identifier- Throws:
EverSdkException
-
mnemonicFromRandom
public static Crypto.ResultOfMnemonicFromRandom mnemonicFromRandom(EverSdkContext ctx, Crypto.MnemonicDictionary dictionary, Integer wordCount) throws EverSdkException Generates a random mnemonic from the specified dictionary and word count Generates a random mnemonic- Parameters:
dictionary
- Dictionary identifierwordCount
- Mnemonic word count- Throws:
EverSdkException
-
mnemonicFromEntropy
public static Crypto.ResultOfMnemonicFromEntropy mnemonicFromEntropy(EverSdkContext ctx, String entropy, Crypto.MnemonicDictionary dictionary, Integer wordCount) throws EverSdkException Generates mnemonic from pre-generated entropy- Parameters:
entropy
- Hex encoded. Entropy bytes.dictionary
- Dictionary identifierwordCount
- Mnemonic word count- Throws:
EverSdkException
-
mnemonicVerify
public static Crypto.ResultOfMnemonicVerify mnemonicVerify(EverSdkContext ctx, String phrase, Crypto.MnemonicDictionary dictionary, Integer wordCount) throws EverSdkException The phrase supplied will be checked for word length and validated according to the checksum specified in BIP0039. Validates a mnemonic phrase- Parameters:
phrase
- Phrasedictionary
- Dictionary identifierwordCount
- Word count- Throws:
EverSdkException
-
mnemonicDeriveSignKeys
public static Crypto.KeyPair mnemonicDeriveSignKeys(EverSdkContext ctx, String phrase, String path, Crypto.MnemonicDictionary dictionary, Integer wordCount) throws EverSdkException Validates the seed phrase, generates master key and then derives the key pair from the master key and the specified path Derives a key pair for signing from the seed phrase- Parameters:
phrase
- Phrasepath
- Derivation path, for instance "m/44'/396'/0'/0/0"dictionary
- Dictionary identifierwordCount
- Word count- Throws:
EverSdkException
-
hdkeyXprvFromMnemonic
public static Crypto.ResultOfHDKeyXPrvFromMnemonic hdkeyXprvFromMnemonic(EverSdkContext ctx, String phrase, Crypto.MnemonicDictionary dictionary, Integer wordCount) throws EverSdkException 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- Throws:
EverSdkException
-
hdkeyDeriveFromXprv
public static Crypto.ResultOfHDKeyDeriveFromXPrv hdkeyDeriveFromXprv(EverSdkContext ctx, String xprv, Long childIndex, Boolean hardened) throws EverSdkException 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)- Throws:
EverSdkException
-
hdkeyDeriveFromXprvPath
public static Crypto.ResultOfHDKeyDeriveFromXPrvPath hdkeyDeriveFromXprvPath(EverSdkContext ctx, String xprv, String path) throws EverSdkException 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"- Throws:
EverSdkException
-
hdkeySecretFromXprv
public static Crypto.ResultOfHDKeySecretFromXPrv hdkeySecretFromXprv(EverSdkContext ctx, String xprv) throws EverSdkException Extracts the private key from the serialized extended private key- Parameters:
xprv
- Serialized extended private key- Throws:
EverSdkException
-
hdkeyPublicFromXprv
public static Crypto.ResultOfHDKeyPublicFromXPrv hdkeyPublicFromXprv(EverSdkContext ctx, String xprv) throws EverSdkException Extracts the public key from the serialized extended private key- Parameters:
xprv
- Serialized extended private key- Throws:
EverSdkException
-
chacha20
public static Crypto.ResultOfChaCha20 chacha20(EverSdkContext ctx, String data, String key, String nonce) throws EverSdkException Performs symmetric `chacha20` encryption.- Parameters:
data
- Must be encoded with `base64`. Source data to be encrypted or decrypted.key
- Must be encoded with `hex`. 256-bit key.nonce
- Must be encoded with `hex`. 96-bit nonce.- Throws:
EverSdkException
-
createCryptoBox
public static Crypto.RegisteredCryptoBox createCryptoBox(EverSdkContext ctx, String secretEncryptionSalt, Crypto.CryptoBoxSecret secretKey, AppSigningBox appObject) throws EverSdkException 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. Creates a Crypto Box instance.- Parameters:
secretEncryptionSalt
- Salt used for secret encryption. For example, a mobile device can use device ID as salt.secretKey
- Cryptobox secret- Throws:
EverSdkException
-
removeCryptoBox
public static void removeCryptoBox(EverSdkContext ctx, Crypto.RegisteredCryptoBox params) throws EverSdkException Removes Crypto Box. Clears all secret data.- Throws:
EverSdkException
-
getCryptoBoxInfo
public static Crypto.ResultOfGetCryptoBoxInfo getCryptoBoxInfo(EverSdkContext ctx, Crypto.RegisteredCryptoBox params) throws EverSdkException Get Crypto Box Info. Used to get `encrypted_secret` that should be used for all the cryptobox initializations except the first one.- Throws:
EverSdkException
-
getCryptoBoxSeedPhrase
public static Crypto.ResultOfGetCryptoBoxSeedPhrase getCryptoBoxSeedPhrase(EverSdkContext ctx, Crypto.RegisteredCryptoBox params) throws EverSdkException Attention! Store this data in your application for a very short period of time and overwrite it with zeroes ASAP. Get Crypto Box Seed Phrase.- Throws:
EverSdkException
-
getSigningBoxFromCryptoBox
public static Crypto.RegisteredSigningBox getSigningBoxFromCryptoBox(EverSdkContext ctx, Long handle, String hdpath, Long secretLifetime) throws EverSdkException Get handle of Signing Box derived from Crypto Box.- Parameters:
handle
- Crypto Box Handle.hdpath
- By default, Everscale HD path is used. HD key derivation path.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.- Throws:
EverSdkException
-
getEncryptionBoxFromCryptoBox
public static Crypto.RegisteredEncryptionBox getEncryptionBoxFromCryptoBox(EverSdkContext ctx, Long handle, String hdpath, Crypto.BoxEncryptionAlgorithm algorithm, Long secretLifetime) throws EverSdkException 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. Gets Encryption Box from Crypto Box.- Parameters:
handle
- Crypto Box Handle.hdpath
- By default, Everscale HD path is used. HD key derivation path.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.- Throws:
EverSdkException
-
clearCryptoBoxSecretCache
public static void clearCryptoBoxSecretCache(EverSdkContext ctx, Crypto.RegisteredCryptoBox params) throws EverSdkException Removes cached secrets (overwrites with zeroes) from all signing and encryption boxes, derived from crypto box.- Throws:
EverSdkException
-
registerSigningBox
public static Crypto.RegisteredSigningBox registerSigningBox(EverSdkContext ctx, AppSigningBox appObject) throws EverSdkException Register an application implemented signing box.- Throws:
EverSdkException
-
getSigningBox
public static Crypto.RegisteredSigningBox getSigningBox(EverSdkContext ctx, Crypto.KeyPair params) throws EverSdkException Creates a default signing box implementation.- Throws:
EverSdkException
-
signingBoxGetPublicKey
public static Crypto.ResultOfSigningBoxGetPublicKey signingBoxGetPublicKey(EverSdkContext ctx, Crypto.RegisteredSigningBox params) throws EverSdkException Returns public key of signing key pair.- Throws:
EverSdkException
-
signingBoxSign
public static Crypto.ResultOfSigningBoxSign signingBoxSign(EverSdkContext ctx, Long signingBox, String unsigned) throws EverSdkException Returns signed user data.- Parameters:
signingBox
- Signing Box handle.unsigned
- Must be encoded with `base64`. Unsigned user data.- Throws:
EverSdkException
-
removeSigningBox
public static void removeSigningBox(EverSdkContext ctx, Crypto.RegisteredSigningBox params) throws EverSdkException Removes signing box from SDK.- Throws:
EverSdkException
-
registerEncryptionBox
public static Crypto.RegisteredEncryptionBox registerEncryptionBox(EverSdkContext ctx, AppSigningBox appObject) throws EverSdkException Register an application implemented encryption box.- Throws:
EverSdkException
-
removeEncryptionBox
public static void removeEncryptionBox(EverSdkContext ctx, Crypto.RegisteredEncryptionBox params) throws EverSdkException Removes encryption box from SDK- Throws:
EverSdkException
-
encryptionBoxGetInfo
public static Crypto.ResultOfEncryptionBoxGetInfo encryptionBoxGetInfo(EverSdkContext ctx, Long encryptionBox) throws EverSdkException Queries info from the given encryption box- Parameters:
encryptionBox
- Encryption box handle- Throws:
EverSdkException
-
encryptionBoxEncrypt
public static Crypto.ResultOfEncryptionBoxEncrypt encryptionBoxEncrypt(EverSdkContext ctx, Long encryptionBox, String data) throws EverSdkException 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. Encrypts data using given encryption box Note.- Parameters:
encryptionBox
- Encryption box handledata
- Data to be encrypted, encoded in Base64- Throws:
EverSdkException
-
encryptionBoxDecrypt
public static Crypto.ResultOfEncryptionBoxDecrypt encryptionBoxDecrypt(EverSdkContext ctx, Long encryptionBox, String data) throws EverSdkException 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. Decrypts data using given encryption box Note.- Parameters:
encryptionBox
- Encryption box handledata
- Data to be decrypted, encoded in Base64- Throws:
EverSdkException
-
createEncryptionBox
public static Crypto.RegisteredEncryptionBox createEncryptionBox(EverSdkContext ctx, Crypto.EncryptionAlgorithm algorithm) throws EverSdkException Creates encryption box with specified algorithm- Parameters:
algorithm
- Encryption algorithm specifier including cipher parameters (key, IV, etc)- Throws:
EverSdkException
-