Messaging
DePIN Messaging is a token-gated, end-to-end encrypted messaging system for the Neurai blockchain. Only holders of a specific asset can submit and decrypt messages in that token pool.

Overview
DePIN Messaging combines three elements:
- Access control via token ownership (asset-gated pools).
- Hybrid encryption using ECIES (secp256k1 ECDH) + AES-256-GCM.
- Message integrity with ECDSA signatures (secp256k1).
Messages are encrypted client-side. Pools validate and store ciphertext, but they cannot know the content of the encrypted messages.
Architecture
Core components
- Local pool: in-memory message storage (
CDepinMsgPool). - Network server: JSON-RPC 2.0 on exclusive DePIN port
19002for remote submission. - Core RPC: standard node RPC on
19001for message retrieval. - Public key index: blockchain-based registry of revealed public keys.
Topology

Message format (technical)
CDepinMessage (outer envelope)
Fields:
token: asset name (string)senderAddress: Neurai addresstimestamp: UNIX time (int64)signature: ECDSA signature over message hashencryptedPayload: serialized ECIES message
Serialization (CompactSize / varint):
[varint token_len][token]
[varint addr_len][address]
[8 bytes timestamp LE]
[varint sig_len][signature]
[varint payload_len][encrypted_payload]
CECIESEncryptedMessage (inner payload)
Fields:
ephemeralPubKey: 33 bytes (compressed secp256k1)encryptedPayload: AES-256-GCM payload (nonce + ciphertext + tag)recipientKeys: map ofhash160(address)-> per-recipient wrapped AES key
encryptedPayload:
[12 bytes nonce][ciphertext][16 bytes GCM tag]
Per-recipient key package (60 bytes):
[12 bytes recipient_nonce][32 bytes encrypted_aes_key][16 bytes recipient_tag]