PrivMX DOCS
API Reference/PrivMX 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](/reference/cpp/endpoint/crypto/crypto-api) · 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

[Buffer](/reference/cpp/endpoint/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

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

[Buffer](/reference/cpp/endpoint/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

[Buffer](/reference/cpp/endpoint/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

[Buffer](/reference/cpp/endpoint/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