DIP1: Stateless Message Routing in DPSN
Proposal to remove dependencies for topic lookup on chain every time a message is published.
Overview
This document outlines the technical flow for routing messages in the Decentralized Publish-Subscribe Network (DPSN). The proposed system ensures that nodes remain stateless or minimally dependent on external network lookups by leveraging cryptographic signatures for ownership verification and message integrity. This paper details the algorithms and formulas used in the encryption methods employed in the system.
Flow Description
1. Topic Purchase and Address Generation
Publishers can purchase topics identified by a topic name that acts as vanity for the topic.
The topic address is generated using the following components:
Creation Time (T): The timestamp when the topic is created.
Publisher Address (P): The unique blockchain address of the publisher.
Nonce (N): A unique nonce or timestamp to prevent collisions.
Concatenation: These components are concatenated into a single string:
Signature Generation: The publisher signs the concatenated message using their private key (SK). The signature generation process can be represented as:
Topic Address Generation: The topic address (A) is generated by hashing the concatenated message along with the signature using a cryptographic hash function (e.g., SHA-256):
2. On-Chain Storage
All relevant data is stored on-chain, including:
Topic Name
Topic Address (A)
Publisher Address (P)
Creation Time (T)
Signature (S)
3. Message Sending
When a publisher sends a message, they provide:
Topic Name
Topic Address (A)
Message Verification: DPSN nodes reconstruct the original message to verify the publisher's signature:
Reconstruct the original message string:
Signature Verification: The nodes verify the signature using the corresponding public key (PK) of the publisher:
4. Node Broadcasting and Metering
Each node broadcasts the publisher’s data, excluding the actual content of messages sent. This serves multiple purposes:
Metering System: To track usage and validate actions within the network.
Incentive Mechanism: To reward nodes for participation and raise alerts for any potential bad actors by monitoring unusual patterns.
5. SDK Message Verification
The Software Development Kits (SDKs) used by publishers and subscribers perform an additional verification step. Before consuming messages:
Validate the message by checking the signature against the topic address and publisher data:
This ensures a double verification process to maintain the integrity of the messages being processed.
Algorithms and Formulas Used
Cryptographic Hash Function
SHA-256: A cryptographic hash function used to generate the topic address. It takes an input and produces a fixed-size string of bytes. The formula can be expressed as:
Where:
input = concatenated message string and signature
H = 256-bit hash value
Digital Signature Algorithm
Signing:
Given a private key (SK) and a message (M), the signature (S) is generated as:
Verification:
Given a public key (PK), message (M), and signature (S):
Last updated