PrivMX DOCS
API Reference/PrivMX Endpoint Java/Crypto

CryptoApi

Defines cryptographic methods.

Constructors

CryptoApi

Create instance of CryptoApi.

public void CryptoApi()

Methods

close

public void close()

convertPEMKeyToWIFKey

Converts given private key in PEM format to its WIF format.

Params

pemKey

String

private key to convert

public String convertPEMKeyToWIFKey(
String pemKey
)

Returns

String · Private key in WIF format

convertPGPAsn1KeyToBase58DERKey

Converts given public key in PGP format to its base58DER format.

Params

pgpKey

String

public key to convert

public String convertPGPAsn1KeyToBase58DERKey(
String pgpKey
)

Returns

String · public key in base58DER format

decryptDataSymmetric

Decrypts buffer with a given key using AES.

Params

data

byte[]

buffer to decrypt

symmetricKey

byte[]

key used to decrypt data

public byte[] decryptDataSymmetric(
byte[] data,
byte[] symmetricKey
)

Returns

byte[] · Plain (decrypted) data buffer

derivePrivateKey

Generates a new private ECC key from a password using pbkdf2.

Params

password

String

the password used to generate the new key

salt

String

random string (additional input for the hashing function)

public String derivePrivateKey(
String password,
String salt
)

Returns

String · Generated ECC key in WIF format

derivePrivateKey2

Generates a new private ECC key from a password using pbkdf2. This version of the derive function has a rounds count increased to 200k. This makes using this function a safer choice, but it makes the received key different than in the original version.

Params

password

String

the password used to generate the new key

salt

String

random string (additional input for the hashing function)

public String derivePrivateKey2(
String password,
String salt
)

Returns

String · generated ECC key in WIF format

derivePublicKey

Generates a new public ECC key as a pair for an existing private key.

Params

privateKey

String

private ECC key in WIF format

public String derivePublicKey(
String privateKey
)

Returns

String · Generated ECC key in BASE58DER format

encryptDataSymmetric

Encrypts buffer with a given key using AES.

Params

data

byte[]

buffer to encrypt

symmetricKey

byte[]

key used to encrypt data

public byte[] encryptDataSymmetric(
byte[] data,
byte[] symmetricKey
)

Returns

byte[] · Encrypted data buffer

entropyToMnemonic

Converts BIP-39 entropy to mnemonic.

Params

entropy

byte[]

BIP-39 entropy

public String entropyToMnemonic(
byte[] entropy
)

Returns

String · BIP-39 mnemonic

fromEntropy

Generates ECC key using BIP-39 entropy.

Params

entropy

byte[]

the BIP-39 entropy used to generate the Key

password

String

the password used to generate the Key

public BIP39 fromEntropy(
byte[] entropy,
String password
)

Returns

BIP39 · BIP39 object containing ECC Key and associated with it BIP-39 mnemonic and entropy

fromEntropy

Generates ECC key using BIP-39 entropy.

Params

entropy

byte[]

the BIP-39 entropy used to generate the Key

public BIP39 fromEntropy(
byte[] entropy
)

Returns

BIP39 · BIP39 object containing ECC Key and associated with it BIP-39 mnemonic and entropy

fromMnemonic

Generates ECC key using BIP-39 mnemonic.

Params

mnemonic

String

the BIP-39 entropy used to generate the Key

password

String

the password used to generate the Key

public BIP39 fromMnemonic(
String mnemonic,
String password
)

Returns

BIP39 · BIP39 object containing ECC Key and associated with it BIP-39 mnemonic and entropy

fromMnemonic

Generates ECC key using BIP-39 mnemonic.

Params

mnemonic

String

the BIP-39 entropy used to generate the Key

public BIP39 fromMnemonic(
String mnemonic
)

Returns

BIP39 · BIP39 object containing ECC Key and associated with it BIP-39 mnemonic and entropy

generateBip39

Generates ECC key and BIP-39 mnemonic from a password using BIP-39.

Params

strength

long

size of BIP-39 entropy, must be a multiple of 32

password

String

the password used to generate the Key

public BIP39 generateBip39(
long strength,
String password
)

Returns

BIP39 · BIP39 object containing ECC Key and associated with it BIP-39 mnemonic and entropy

generateBip39

Generates ECC key and BIP-39 mnemonic from a password using BIP-39.

Params

strength

long

size of BIP-39 entropy, must be a multiple of 32

public BIP39 generateBip39(
long strength
)

Returns

BIP39 · BIP39 object containing ECC Key and associated with it BIP-39 mnemonic and entropy

generateKeySymmetric

Generates a new symmetric key.

public byte[] generateKeySymmetric()

Returns

byte[] · Generated key

generatePrivateKey

Generates a new private ECC key.

Params

randomSeed

String

optional string used as the base to generate the new key

public String generatePrivateKey(
String randomSeed
)

Returns

String · Generated ECC key in WIF format

mnemonicToEntropy

Converts BIP-39 mnemonic to entropy.

Params

mnemonic

String

BIP-39 mnemonic

public byte[] mnemonicToEntropy(
String mnemonic
)

Returns

byte[] · BIP-39 entropy

mnemonicToSeed

Generates a seed used to generate a key using BIP-39 mnemonic with PBKDF2.

Params

mnemonic

String

BIP-39 mnemonic

password

String

the password used to generate the seed

public byte[] mnemonicToSeed(
String mnemonic,
String password
)

Returns

byte[] · generated seed

mnemonicToSeed

Generates a seed used to generate a key using BIP-39 mnemonic with PBKDF2.

Params

mnemonic

String

BIP-39 mnemonic

public byte[] mnemonicToSeed(
String mnemonic
)

Returns

byte[] · generated seed

signData

Creates a signature of data using given key.

Params

data

byte[]

data the buffer to sign

privateKey

String

the key used to sign data

public byte[] signData(
byte[] data,
String privateKey
)

Returns

byte[] · Signature of data

verifySignature

Validate a signature of data using given key.

Params

data

byte[]

buffer

signature

byte[]

of data

publicKey

String

public ECC key in BASE58DER format used to validate data

public boolean verifySignature(
byte[] data,
byte[] signature,
String publicKey
)

Returns

boolean · data validation result

We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.