Created
June 4, 2018 16:48
-
-
Save transducer/29ddd0cf73df1c393e3f766015000977 to your computer and use it in GitHub Desktop.
Send encrypted MAM_DATA to a service provider.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Send encrypted MAM data to a service provider. | |
* | |
* @function sendMamData | |
* @param {string} seed IOTA seed of sender | |
* @param {string} address IOTA address of the service provider | |
* @param {string} publicKey Public key of the service provider in trytes | |
* @returns {Promise} containing IOTA transactions | |
*/ | |
async sendMamData(seed, address, publicKey) { | |
const { channel: { side_key, next_root } } = this.mam.getMamState(); | |
const mamData = { | |
root: ntru.encrypt(next_root, publicKey), | |
sideKey: ntru.encrypt(side_key, publicKey), | |
}; | |
logger.info(`Provide service provider ${address} with MAM data ${JSON.stringify(mamData)}`); | |
const message = { type: MAM_DATA_TYPE, root: this.root, mamData }; | |
return iota.send(seed, address, message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment