PrivMX DOCS
API Reference/PrivMX Endpoint Web/Api reference

Crypto

Class representing instance of Crypto API

Fields

native

CryptoApiNative

Methods

signData

Creates a signature of data using given key.

Params

data

Uint8Array

buffer to sign

privateKey

string

key used to sign data

signData(data, privateKey)

Returns

Promise<Uint8Array> · signature

generatePrivateKey

Generates a new private ECC key.

Params

randomSeed

string | undefined

optional string used as the base to generate the new key

generatePrivateKey(randomSeed)

Returns

Promise<string> · generated ECC key in WIF format

derivePrivateKey

(deprecated) 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)

derivePrivateKey(password, salt)

Returns

Promise<string> · generated ECC key in WIF format

derivePrivateKey2

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)

derivePrivateKey2(password, salt)

Returns

Promise<string> · generated ECC key in WIF format

derivePublicKey

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

Params

privateKey

string

private ECC key in WIF format

derivePublicKey(privateKey)

Returns

Promise<string> · generated ECC key in BASE58DER format

generateKeySymmetric

Generates a new symmetric key.

generateKeySymmetric()

Returns

Promise<Uint8Array> · generated key.

encryptDataSymmetric

Encrypts buffer with a given key using AES.

Params

data

Uint8Array

buffer to encrypt

symmetricKey

Uint8Array

key used to encrypt data

encryptDataSymmetric(data, symmetricKey)

Returns

Promise<Uint8Array> · encrypted data buffer

decryptDataSymmetric

Decrypts buffer with a given key using AES.

Params

data

Uint8Array

buffer to decrypt

symmetricKey

Uint8Array

key used to decrypt data

decryptDataSymmetric(data, symmetricKey)

Returns

Promise<Uint8Array> · plain (decrypted) data buffer

convertPEMKeytoWIFKey

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

Params

pemKey

string

private key to convert

convertPEMKeytoWIFKey(pemKey)

Returns

Promise<string> · private key in WIF format

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.