Version: 1.0 Last Updated: 2025-01-27 Status: Active
- Overview
- Message Format
- Message Types
- Relay Rules
- Cryptographic Requirements
- Security Policies
- Network Behavior
- Compliance
This document defines the messaging rules and relay policies for the Fabric Protocol. All peers in the Fabric network MUST comply with these policies to ensure network integrity, security, and proper message propagation.
- Cryptographic Integrity: All messages MUST be signed using BIP-340 Schnorr signatures
- Type-Based Routing: Message relay decisions are based on message type
- Privacy Preservation: Identity and session messages are handled locally
- Network Propagation: Network-critical messages are relayed to all peers
- Performance: High-throughput relay with minimal latency
All Fabric messages consist of two components:
magic— 4 bytes:0xC0D3F33D(constant)version— 4 bytes:0x00000001(protocol version)parent— 32 bytes: Parent state identifierauthor— 32 bytes: X-only public key (BIP-340) of message authortype— 4 bytes: Message type codesize— 4 bytes: Payload size in byteshash— 32 bytes: SHA256 hash of payloadsignature— 64 bytes: BIP-340 Schnorr signature
- Optional payload data as specified by
sizefield
- Author Field: Set to x-only public key (32 bytes) BEFORE signing
- Hash Computation:
- Create buffer:
header (with zeroed signature) + body - Compute tagged hash:
SHA256(SHA256("Fabric/Message") || SHA256("Fabric/Message") || data)
- Create buffer:
- Signature: Sign the tagged hash using BIP-340 Schnorr
- Verification: Verify signature using author's x-only public key
| Range | Category | Description |
|---|---|---|
0x00-0x7F |
Core Network Protocol | Network management and peer communication |
0x80-0xFF |
Application Layer | Application-specific messages |
0x1000-0x1FFF |
Bitcoin Integration | Bitcoin protocol messages |
0x2000-0x2FFF |
Lightning Network | Lightning protocol messages |
0x8000-0xFFFF |
Experimental | Development and testing |
| Type | Code | Name | Description | Relay |
|---|---|---|---|---|
0x00 |
0 | RESERVED | Reserved for future use | N/A |
0x01 |
1 | PING | Network heartbeat | ✅ Yes |
0x02 |
2 | PONG | Ping response | ✅ Yes |
0x03 |
3 | IDENT_REQUEST | Identity request | ❌ No |
0x04 |
4 | IDENT_RESPONSE | Identity response | ❌ No |
0x05 |
5 | PEER_ANNOUNCE | Peer announcement | ✅ Yes |
0x06 |
6 | STATE_REQUEST | State synchronization request | |
0x07 |
7 | STATE_RESPONSE | State synchronization response | |
0x08 |
8 | TRANSACTION | Transaction data | ✅ Yes |
0x09 |
9 | INVENTORY_REQUEST | Inventory request | |
0x0A |
10 | INVENTORY_RESPONSE | Inventory response | |
0x0B |
11 | SESSION_START | Start session | ❌ No |
0x0C |
12 | SESSION_ACK | Session acknowledgment | ❌ No |
0x0D |
13 | ERROR | Error message | ✅ Yes |
0x0E |
14 | WARNING | Warning message | ✅ Yes |
0x0F |
15 | HEARTBEAT | Heartbeat (keepalive) | ❌ No |
0x10-0x7F |
16-127 | RESERVED | Reserved for core protocol extensions | N/A |
| Type | Code | Name | Description | Relay |
|---|---|---|---|---|
0x80 |
128 | GENERIC | Generic application message (UTF-8 JSON) | ✅ Yes |
0x81 |
129 | CHAT_MESSAGE | Chat/messaging | ✅ Yes |
0x82 |
130 | DOCUMENT_REQUEST | Document request | |
0x83 |
131 | DOCUMENT_RESPONSE | Document response | |
0x84 |
132 | DOCUMENT_PUBLISH | Document publish | ✅ Yes |
0x85 |
133 | JSON_CALL | JSON function call | ✅ Yes |
0x86 |
134 | JSON_PATCH | JSON patch operation | ✅ Yes |
0x87 |
135 | LOG_MESSAGE | Log message (debugging) | ❌ No |
0x88 |
136 | STATE_DELTA | State delta (JSON-PATCH) | ✅ Yes |
0x89 |
137 | STATE_SNAPSHOT | State snapshot | ✅ Yes |
0x8A |
138 | CONTRACT_PROPOSAL | Contract proposal | ✅ Yes |
0x8B |
139 | CONTRACT_ACCEPT | Contract acceptance | ✅ Yes |
0x8C |
140 | CONTRACT_REJECT | Contract rejection | ✅ Yes |
0x8D |
141 | PAYMENT_REQUEST | Payment request (ASK) | ✅ Yes |
0x8E |
142 | PAYMENT_RESPONSE | Payment response (BID) | ✅ Yes |
0x8F |
143 | LOCK_MESSAGE | Lock message (halt forward movement) | ✅ Yes |
0x90-0xFF |
144-255 | RESERVED | Reserved for application extensions | N/A |
| Type | Code | Name | Description | Relay |
|---|---|---|---|---|
0x1000 |
4096 | BITCOIN_BLOCK | Bitcoin block | ✅ Yes |
0x1001 |
4097 | BITCOIN_BLOCK_HASH | Bitcoin block hash | ✅ Yes |
0x1002 |
4098 | BITCOIN_TRANSACTION | Bitcoin transaction | ✅ Yes |
0x1003 |
4099 | BITCOIN_TX_HASH | Bitcoin transaction hash | ✅ Yes |
0x1004 |
4100 | BITCOIN_UTXO | Bitcoin UTXO | ✅ Yes |
0x1005 |
4101 | BITCOIN_HEADER | Bitcoin block header | ✅ Yes |
0x1006-0x1FFF |
4102-8191 | RESERVED | Reserved for Bitcoin protocol extensions | N/A |
| Type | Code | Name | Description | Relay |
|---|---|---|---|---|
0x2000 |
8192 | LIGHTNING_INIT | Lightning initialization | ❌ No |
0x2001 |
8193 | LIGHTNING_ERROR | Lightning error | ❌ No |
0x2002 |
8194 | LIGHTNING_OPEN_CHANNEL | Open channel | ❌ No |
0x2003 |
8195 | LIGHTNING_ACCEPT_CHANNEL | Accept channel | ❌ No |
0x2004 |
8196 | LIGHTNING_FUNDING_CREATED | Funding created | ❌ No |
0x2005 |
8197 | LIGHTNING_FUNDING_SIGNED | Funding signed | ❌ No |
0x2006 |
8198 | LIGHTNING_CHANNEL_READY | Channel ready | ❌ No |
0x2007 |
8199 | LIGHTNING_SHUTDOWN | Channel shutdown | ❌ No |
0x2008 |
8200 | LIGHTNING_CLOSING_SIGNED | Closing signed | ❌ No |
0x2009 |
8201 | LIGHTNING_UPDATE_ADD_HTLC | Add HTLC | ❌ No |
0x200A |
8202 | LIGHTNING_UPDATE_FULFILL_HTLC | Fulfill HTLC | ❌ No |
0x200B |
8203 | LIGHTNING_UPDATE_FAIL_HTLC | Fail HTLC | ❌ No |
0x200C |
8204 | LIGHTNING_COMMITMENT_SIGNED | Commitment signed | ❌ No |
0x200D |
8205 | LIGHTNING_REVOKE_AND_ACK | Revoke and acknowledge | ❌ No |
0x200E |
8206 | LIGHTNING_CHANNEL_ANNOUNCEMENT | Channel announcement | ✅ Yes |
0x200F |
8207 | LIGHTNING_NODE_ANNOUNCEMENT | Node announcement | ✅ Yes |
0x2010 |
8208 | LIGHTNING_CHANNEL_UPDATE | Channel update | ✅ Yes |
0x2011-0x2FFF |
8209-12287 | RESERVED | Reserved for Lightning protocol extensions | N/A |
| Type | Code | Name | Description | Relay |
|---|---|---|---|---|
0x8000-0xFFFF |
32768-65535 | EXPERIMENTAL | Development and testing use |
Messages are categorized into three relay behaviors:
Purpose: Messages that need network-wide distribution for consensus, connectivity, or application functionality.
Types:
- Network management: PING, PONG, PEER_ANNOUNCE, ERROR, WARNING
- Consensus: TRANSACTION, STATE_DELTA, STATE_SNAPSHOT
- Application: GENERIC, CHAT_MESSAGE, DOCUMENT_PUBLISH, JSON_CALL, JSON_PATCH
- Contracts: CONTRACT_PROPOSAL, CONTRACT_ACCEPT, CONTRACT_REJECT
- Payments: PAYMENT_REQUEST, PAYMENT_RESPONSE, LOCK_MESSAGE
- Bitcoin: All Bitcoin integration types
- Lightning: Channel and node announcements only
Behavior:
- Forward to ALL connected peers
- Maintain cryptographic integrity across hops
- No TTL or hop limit (subject to future policy updates)
Purpose: Messages that contain sensitive information or are peer-to-peer only.
Types:
- Identity: IDENT_REQUEST, IDENT_RESPONSE
- Session: SESSION_START, SESSION_ACK
- Debugging: LOG_MESSAGE, HEARTBEAT
- Lightning: All channel management messages (except announcements)
Behavior:
- Process locally only
- Do NOT forward to other peers
- Respond directly to sender if appropriate
Purpose: Messages that may or may not need relay based on local state or content.
Types:
- STATE_REQUEST: Relay if not cached locally
- STATE_RESPONSE: Relay if not the intended recipient
- INVENTORY_REQUEST: Relay if inventory not available locally
- INVENTORY_RESPONSE: Relay if not the intended recipient
- DOCUMENT_REQUEST: Relay if document not available locally
- DOCUMENT_RESPONSE: Relay if not the intended recipient
Behavior:
- Check local state/cache
- If available locally: Handle locally, do not relay
- If not available: Relay to connected peers
- Update local state upon receipt
-
Cryptographic Verification:
- Verify message signature BEFORE relaying
- Reject and do not relay invalid messages
-
Deduplication:
- Track message IDs to prevent duplicate relay
- Use message hash as unique identifier
-
Origin Tracking:
- Track message origin to prevent loops
- Do not relay back to origin peer
-
Performance:
- Relay should be non-blocking
- Batch relay operations when possible
- Prioritize critical message types
-
Error Handling:
- Log relay failures
- Continue processing other messages
- Do not crash on relay errors
- Algorithm: BIP-340 Schnorr signatures
- Curve: secp256k1
- Hash Function: SHA256 (for tagged hash)
- Tag: "Fabric/Message"
- Extract x-only public key (32 bytes) from signing key
- Set
authorfield to x-only public key - Create data buffer:
header (signature zeroed) + body - Compute tagged hash:
SHA256(SHA256("Fabric/Message") || SHA256("Fabric/Message") || data) - Sign tagged hash using BIP-340 Schnorr
- Set
signaturefield (64 bytes)
- Extract x-only public key from
authorfield (32 bytes) - Create data buffer:
header (signature zeroed) + body - Compute tagged hash:
SHA256(SHA256("Fabric/Message") || SHA256("Fabric/Message") || data) - Verify signature using x-only public key and tagged hash
- Reject message if verification fails
- All messages MUST be signed: Unsigned messages are rejected
- Signature verification is mandatory: No exceptions
- Author field validation: Must be valid 32-byte x-only public key
- Hash integrity: Payload hash must match computed hash
- No signature replay: Implement message deduplication
All messages MUST pass the following validation checks:
-
Format Validation:
- Magic bytes:
0xC0D3F33D - Version:
0x00000001 - Header size: 176 bytes
- Payload size matches
sizefield
- Magic bytes:
-
Cryptographic Validation:
- Signature is valid BIP-340 Schnorr signature
- Author field contains valid x-only public key
- Payload hash matches computed hash
-
Type Validation:
- Message type is in valid range
- Message type is not reserved
- Message type matches payload format
Messages are REJECTED if:
- Invalid magic bytes or version
- Invalid signature (cryptographic verification fails)
- Invalid author field (not 32 bytes, invalid format)
- Payload hash mismatch
- Message type out of range or reserved
- Payload size exceeds maximum allowed
- Message is duplicate (already processed)
- Identity Messages: Never relayed, processed locally only
- Session Messages: Peer-to-peer only, not relayed
- Log Messages: Local processing only, never relayed
- Channel Management: Lightning channel messages are peer-to-peer only
Peers SHOULD implement rate limiting to prevent:
- Message flooding
- Denial of service attacks
- Resource exhaustion
Recommended limits:
- Per-peer message rate: 1000 messages/second
- Network-wide message rate: 10,000 messages/second
- Burst allowance: 2x normal rate for 1 second
- Origin: Message created and signed by origin peer
- First Hop: Origin peer sends to directly connected peers
- Relay Decision: Each peer decides whether to relay based on type
- Propagation: Relayed messages forwarded to all connected peers (except origin)
- Verification: Each peer verifies signature before processing/relaying
- Mesh Network: Peers connect in mesh topology
- No Central Authority: Fully decentralized
- Peer Discovery: Via PEER_ANNOUNCE messages
- Connection Management: Via PING/PONG messages
- Relay Throughput: 20,000+ messages/second
- Average Latency: < 1ms per hop
- Success Rate: 100% for valid messages
- Cryptographic Overhead: < 5% of total processing time
All Fabric Protocol implementations MUST:
- ✅ Implement BIP-340 Schnorr signature signing and verification
- ✅ Use tagged hash "Fabric/Message" for message signing
- ✅ Enforce relay rules based on message type
- ✅ Validate all messages before processing or relaying
- ✅ Handle identity and session messages locally
- ✅ Relay network-critical messages to all peers
- ✅ Implement message deduplication
- ✅ Track message origin to prevent loops
Implementations SHOULD:
- Test message signing and verification
- Test relay behavior for all message types
- Test cryptographic integrity across multiple hops
- Test rejection of invalid messages
- Test performance under load
- Test network topology scenarios
- Protocol Version:
0x00000001 - Backward Compatibility: Not guaranteed for future versions
- Forward Compatibility: Unknown message types should be rejected
Always Relay: PING, PONG, PEER_ANNOUNCE, TRANSACTION, GENERIC, CHAT_MESSAGE, DOCUMENT_PUBLISH, JSON_CALL, JSON_PATCH, STATE_DELTA, STATE_SNAPSHOT, CONTRACT_, PAYMENT_, LOCK_MESSAGE, BITCOIN_, LIGHTNING__ANNOUNCEMENT
Never Relay: IDENT_REQUEST, IDENT_RESPONSE, SESSION_START, SESSION_ACK, HEARTBEAT, LOG_MESSAGE, LIGHTNING_INIT, LIGHTNING_ERROR, LIGHTNING_CHANNEL, LIGHTNING_HTLC, LIGHTNING_COMMITMENT_SIGNED, LIGHTNING_REVOKE_AND_ACK
Conditional Relay: STATE_REQUEST, STATE_RESPONSE, INVENTORY_REQUEST, INVENTORY_RESPONSE, DOCUMENT_REQUEST, DOCUMENT_RESPONSE
PROTOCOL.md: Core protocol specificationMESSAGING_PROTOCOL_COMPLETION.md: Implementation detailsFABRIC_MESSAGE_TYPE_CONSOLIDATION.md: Type system designFABRIC_MESSAGE_RELAY_BEHAVIOR.md: Relay behavior analysis
End of Policy Document