This is a beta version to test the capabilities of the DePIN messaging system built into the node.
DO NOT USE IN A WALLET WITH FUNDS!!!
What is DePIN Messaging?
DePIN Messaging is a decentralized encrypted communication system between holders of a specific token on the Neurai blockchain network. With a Neurai node, it is possible to easily create a communication server.
Key Features:
- Token-gated access (only asset holders can participate)
- End-to-end encryption using ECIES hybrid encryption
- Message signing using ECDSA (secp256k1)
- Distributed pool architecture (each node can run a message pool)
- Configurable message expiration (default: 7 days, max: 30 days)
- Configurable message size (default: 1KB, max: 10KB)
- Configurable recipients per message (default: 20, max: 50)
- Configurable pool size limit (default: 100MB, max: 1GB)
- Optional pool persistence to disk
CECIESEncryptedMessage (Encryption Envelope)
class CECIESEncryptedMessage {
CPubKey ephemeralPubKey; // 33 bytes (compressed secp256k1)
std::vector<unsigned char> encryptedPayload; // IV + ciphertext + HMAC
std::map<uint160, std::vector<unsigned char>> recipientKeys; // Per-recipient encrypted AES keys
};
encryptedPayload Structure:
[16 bytes: AES IV]
[variable: AES-256-CBC encrypted message]
[32 bytes: HMAC-SHA256(IV || ciphertext)]
recipientKeys Entry (per recipient):
Key: uint160 (20 bytes) - RIPEMD160(SHA256(recipient_pubkey))
Value: [33 bytes: ephemeral_pubkey_for_recipient]
[32 bytes: encrypted_aes_key]
[32 bytes: HMAC-SHA256(encrypted_aes_key)]
Total: 97 bytes per recipient
CDepinMessage (Core Message Structure)
Configuration File (neurai.conf):
# Mandatory
assetindex=1 # Required for DePIN
depinmsg=1 # Enable DePIN messaging
depinmsgtoken=MYTOKEN # Token that controls access
# Network
depinmsgport=19002 # DePIN server port (default: 19002)
# Message Limits
depinmsgmaxusers=30 # Max recipients per message (default: 20, max: 50)
depinmsgsize=2048 # Max message size in bytes (default: 1024, max: 10240)
depinmsgexpire=336 # Message expiry in hours (default: 168, max: 720)
# Pool Management
depinpoolsize=200 # Max pool size in MB (default: 100, max: 1000)
depinpoolpersist=1 # Save pool to disk on shutdown (default: 0)
Verify Configuration:
neurai-cli depingetmsginfo
Example Output:
{
"enabled": true,
"token": "MYTOKEN",
"port": 19002,
"maxrecipients": 30,
"maxmessagesize": 2048,
"messageexpiryhours": 336,
"maxpoolsizemb": 200,
"messages": 42,
"memoryusage": 1258496,
"memoryusagemb": 1.20,
"oldestmessage": "2025-11-14 10:30:00",
"newestmessage": "2025-11-14 18:45:23"
}
Local RPC Commands
depinsendmsg
Send a message to the pool.
neurai-cli depinsendmsg "TOKEN" "192.168.1.31:19002" "Hello world" "NXsender..."
Parameters:
token(string, required) - Token name
ip[:port](string, required) - Remote node IP and optional port
message(string, required) - Plaintext message (max size configurable via depinmsgsize, default: 1KB)
fromaddress(string, optional) - Sender address
Process:
- Get all token holders from blockchain
- Retrieve public keys for all holders
- Encrypt message using ECIES for all recipients
- Sign message with sender's private key
- Serialize message
- Send to remote node via JSON-RPC (method:
depinsubmitmsg)
Response:
{
"result": "success",
"txid": "<message_hash>"
}
depingetmsg
Retrieve and decrypt messages.
# Local pool
neurai-cli depingetmsg "TOKEN"
# Remote pool (default port 19002)
neurai-cli depingetmsg "TOKEN" "192.168.1.31"
# Remote pool with explicit port
neurai-cli depingetmsg "TOKEN" "192.168.1.31:19002"
# With specific address
neurai-cli depingetmsg "TOKEN" "192.168.1.31:19002" "NXyouraddress..."
Parameters:
token(string, required) - Token name
ip[:port](string, optional) - Remote node IP:PORT or local address
fromaddress(string, optional) - Specific address to decrypt with
Full Changelog: https://github.com/NeuraiProject/Neurai/compare/1.0.5...1.0.6_DepinTest