src/crypto/crypto.js
function(recipientPrivate, senderPublic, _payload) {
    // Errorsp
    if(!recipientPrivate || !senderPublic || !_payload) throw new Error('Missing argument !');
    // Processing
    let binPayload = convert.hexToUint8(_payload);
    let salt = new Uint8Array(binPayload.buffer, 0, 32);
    let iv = new Uint8Array(binPayload.buffer, 32, 16);
    let payload = new Uint8Array(binPayload.buffer, 48);

    let keyPair = createKeyPairFromPrivateKeyString(recipientPrivate);
    let pk = convert.hexToUint8(senderPublic);
    let encKey = deriveSharedKey(keyPair, pk, salt);
    let encIv = {
        iv: ua2words(iv, 16)
    };
    let encrypted = {
        'ciphertext': ua2words(payload, payload.length)
    };
    let plain = CryptoJS.AES.decrypt(encrypted, encKey, encIv);
    // Result
    let hexplain = CryptoJS.enc.Hex.stringify(plain);
    return hexplain;
}
function(recipientPrivate, senderPublic, _payload) {
    // Errorsp
    if(!recipientPrivate || !senderPublic || !_payload) throw new Error('Missing argument !');
    // Processing
    let binPayload = convert.hexToUint8(_payload);
    let salt = new Uint8Array(binPayload.buffer, 0, 32);
    let iv = new Uint8Array(binPayload.buffer, 32, 16);
    let payload = new Uint8Array(binPayload.buffer, 48);

    let keyPair = createKeyPairFromPrivateKeyString(recipientPrivate);
    let pk = convert.hexToUint8(senderPublic);
    let encKey = deriveSharedKey(keyPair, pk, salt);
    let encIv = {
        iv: ua2words(iv, 16)
    };
    let encrypted = {
        'ciphertext': ua2words(payload, payload.length)
    };
    let plain = CryptoJS.AES.decrypt(encrypted, encKey, encIv);
    // Result
    let hexplain = CryptoJS.enc.Hex.stringify(plain);
    return hexplain;
}
Decode an encrypted message payload

@param {string} recipientPrivate - A recipient private key
@param {string} senderPublic - A sender public key
@param {string} _payload - An encrypted message payload

@return {string} - The decoded payload as hex