PrivMX DOCS
API Reference/Endpoint/Crypto

CryptoApi

'CryptoApi' is a class representing Endpoint's API for cryptographic operations.

Static Methods

create

Creates instance of 'CryptoApi'.

static CryptoApi create()

Returns

CryptoApi · CryptoApi object

Methods

signData

Creates a signature of data using given key.

Params

data

const core::Buffer &

buffer to sign

privateKey

const std::string &

key used to sign data

core::Buffer signData(
const core::Buffer &data
const std::string &privateKey
)

Returns

core::Buffer · signature of data

verifySignature

Validate a signature of data using given key.

Params

data

const core::Buffer &

buffer

signature

const core::Buffer &

signature of data to verify

publicKey

const std::string &

public ECC key in BASE58DER format used to validate data

bool verifySignature(
const core::Buffer &data
const core::Buffer &signature
const std::string &publicKey
)

Returns

bool · data validation result

generatePrivateKey

Generates a new private ECC key.

Params

randomSeed

const std::optional<std::string> &

optional string used as the base to generate the new key

std::string generatePrivateKey(
const std::optional<std::string> &randomSeed
)

Returns

std::string · generated ECC key in WIF format

derivePrivateKey

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

Params

password

const std::string &

the password used to generate the new key

salt

const std::string &

random string (additional input for the hashing function)

std::string derivePrivateKey(
const std::string &password
const std::string &salt
)

Returns

std::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

const std::string &

the password used to generate the new key

salt

const std::string &

random string (additional input for the hashing function)

std::string derivePrivateKey2(
const std::string &password
const std::string &salt
)

Returns

std::string · generated ECC key in WIF format

derivePublicKey

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

Params

privateKey

const std::string &

std::string derivePublicKey(
const std::string &privateKey
)

Returns

std::string · generated ECC key in BASE58DER format

generateKeySymmetric

Generates a new symmetric key.

core::Buffer generateKeySymmetric()

Returns

core::Buffer · generated key

encryptDataSymmetric

Encrypts buffer with a given key using AES.

Params

data

const core::Buffer &

buffer to encrypt

symmetricKey

const core::Buffer &

key used to encrypt data

core::Buffer encryptDataSymmetric(
const core::Buffer &data
const core::Buffer &symmetricKey
)

Returns

core::Buffer · encrypted data buffer

decryptDataSymmetric

Decrypts buffer with a given key using AES.

Params

data

const core::Buffer &

buffer to decrypt

symmetricKey

const core::Buffer &

key used to decrypt data

core::Buffer decryptDataSymmetric(
const core::Buffer &data
const core::Buffer &symmetricKey
)

Returns

core::Buffer · plain (decrypted) data buffer

convertPEMKeytoWIFKey

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

Params

pemKey

const std::string &

private key to convert

std::string convertPEMKeytoWIFKey(
const std::string &pemKey
)

Returns

std::string · private key in WIF format

convertPGPAsn1KeyToBase58DERKey

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

Params

pgpKey

const std::string &

std::string convertPGPAsn1KeyToBase58DERKey(
const std::string &pgpKey
)

Returns

std::string · private key in base58DER format

generateBip39

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

Params

strength

std::size_t

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

password

const std::string &

the password used to generate the Key

BIP39_t generateBip39(std::size_t strength
const std::string &password=std::string())

Returns

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

fromMnemonic

Generates ECC key using BIP-39 mnemonic.

Params

mnemonic

const std::string &

the BIP-39 entropy used to generate the Key

password

const std::string &

the password used to generate the Key

BIP39_t fromMnemonic(const std::string &mnemonic
const std::string &password=std::string())

Returns

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

fromEntropy

Generates ECC key using BIP-39 entropy.

Params

entropy

const core::Buffer &

the BIP-39 entropy used to generate the Key

password

const std::string &

the password used to generate the Key

BIP39_t fromEntropy(const core::Buffer &entropy
const std::string &password=std::string())

Returns

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

entropyToMnemonic

Converts BIP-39 entropy to mnemonic.

Params

entropy

const core::Buffer &

BIP-39 entropy

std::string entropyToMnemonic(
const core::Buffer &entropy
)

Returns

std::string · BIP-39 mnemonic

mnemonicToEntropy

Converts BIP-39 mnemonic to entropy.

Params

mnemonic

const std::string &

BIP-39 mnemonic

core::Buffer mnemonicToEntropy(
const std::string &mnemonic
)

Returns

core::Buffer · BIP-39 entropy

mnemonicToSeed

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

Params

mnemonic

const std::string &

BIP-39 mnemonic

password

const std::string &

the password used to generate the seed

core::Buffer mnemonicToSeed(const std::string &mnemonic
const std::string &password=std::string())

Returns

core::Buffer · generated seed

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.