src/index.js
/**
   * Encrypt transaction payload for given receiver.
   * In most cases you don't have to use it directly as
   * [sendTo]{@link SmartInvoice#sendTo} is taking care of it.
   * @async
   * @ignore
   * @param {String} receiverDID DID of the receiver
   * @param {Object} payload JSON object with additional data
   * @return {Promise} promise with success result object with encryptedMessage
   *                   for sender and recevier
   */
Encrypt transaction payload for given receiver.
In most cases you don't have to use it directly as
[sendTo] SmartInvoice#sendTo is taking care of it.
Encrypt transaction payload for given receiver . In most cases you don ' t have to use it directly as [ sendTo ] SmartInvoice#sendTo is taking care of it .
encryptTransactionPayloadFor(receiverDID, payload) {
    const self = this;
    const { signKey } = this.identity.secret;
    const userKeyPair = sovrinDID.getKeyPairFromSignKey(signKey);
    return this.fetchIdentityFor(receiverDID).then((response) => {
      const sharedSecret = sovrinDID.getSharedSecret(
        response.data.publicKey,
        userKeyPair.secretKey,
      );
      const sharedSecretSender = sovrinDID.getSharedSecret(
        userKeyPair.publicKey,
        userKeyPair.secretKey,
      );
      const transactionPayload = {
        aes: {
          aesSecret: self.aesSecret,
          aesIV: self.aesIv,
        },
        payload,
      };
      const message = JSON.stringify(transactionPayload);
      const encryptedReceiverMessage = sovrinDID.encryptMessage(message, self.nonce, sharedSecret);
      const encryptedSenderMessage = sovrinDID.encryptMessage(
        message,
        self.nonce,
        sharedSecretSender,
      );
      return { encryptedReceiverMessage, encryptedSenderMessage };
    });
  }
encryptTransactionPayloadFor ( receiverDID , payload ) { const self = this ; const { signKey } = this . identity . secret ; const userKeyPair = sovrinDID . getKeyPairFromSignKey ( signKey ) ; return this . fetchIdentityFor ( receiverDID ) . then ( ( response ) => { const sharedSecret = sovrinDID . getSharedSecret ( response . data . publicKey , userKeyPair . secretKey , ) ; const sharedSecretSender = sovrinDID . getSharedSecret ( userKeyPair . publicKey , userKeyPair . secretKey , ) ; const transactionPayload = { aes : { aesSecret : self . aesSecret , aesIV : self . aesIv , } , payload , } ; const message = JSON . stringify ( transactionPayload ) ; const encryptedReceiverMessage = sovrinDID . encryptMessage ( message , self . nonce , sharedSecret ) ; const encryptedSenderMessage = sovrinDID . encryptMessage ( message , self . nonce , sharedSecretSender , ) ; return { encryptedReceiverMessage , encryptedSenderMessage } ; } ) ; }
Encrypt transaction payload for given receiver.
Encrypt transaction payload for given receiver .
// Encrypting for self transaction