Skip to content

eostitan/eos-communication

Repository files navigation

EOS TITAN

https://eostitan.com

eos-communication

This node.js module allows on-chain encrypted communication on the EOS platform, using the AES shared key encryption algorithm and the memo field in the "transfer" action to send private messages that can only be decrypted by the recipient.

It combines the sender's private key and the receiver's public key (using the account's active permission) to create a public key for encryption.

Decryption is achieved by combining the receiver's private key and the sender's public key to create the private key necessary to decrypt the message.

This module uses eosjs and eosjs-ecc to communicate with the EOS network and to perform the required cryptographic operations.

Configuration:

Please make sure node.js is installed on your system (tested with version 8.11.3).

Clone the repository and install packages:

git clone https://github.com/eostitan/eos-communication
cd eos-communication
npm install

Usage:

Using constructor parameters

const eosCommunications = require("./index.js");

const opts = {
	network:{
		httpEndpoint: "http://api.eostitan.com",
		chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'
	},
	keys:[
		{
			"account":  "myeosaccount", //account name
			"priv_key": "5.....", //priv key
			"pub_key":  "EOS...." //pub key
		}
	]
}

const eosComm = new eosCommunications(opts);

Functions:

.send : encrypt and send a message in the memo field of a transfer

fromAcct: account you want to send the message from

toAcct: account to which you want to send the message to

message: the message to be encrypted

amount: amount of the transfer (default 0.0001)

eosComm.send(fromAcct, toAcct, message, amount)
	.then(result=>{
		console.log(result);
	})
	.catch(err=>{
		console.log("error sending message:", err);
	});

.scanForMessages : scan a block for any messages addressed to one of your accounts

block_num_or_id: number or hash of block to scan for messages

amount: minimum amount required to include message in results (default 0.0001)

eosComm.scanForMessages(block_num_or_id, amount)
	.then(result=>{
		console.log(result);
	})
	.catch(err=>{
		console.log("error retrieving messages:", err);
	});

Testing

.encrypt : encrypt a message without sending it

fromAcct: account you want to send the message from

toAcct: account to which you want to send the message to

message: the message to be encrypted

eosComm.encrypt(fromAcct, toAcct, message)
	.then(encryptedRes=>{
		console.log(encryptedRes);
	})
	.catch(err=>{
		console.log("encryption error:", err);
	});

.decrypt : decrypt an encrypted message

fromAcct: account from which you received the message

toAcct: account with which you received a message

message: the message to be decrypted

eosComm.decrypt(fromAcct, toAcct, message)
	.then(decryptedRes=>{
		console.log(decryptedRes);
	})
	.catch(err=>{
		console.log("decryption error:", err);
	});

For full example, see example.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published