Files
dlcspecs/Messaging.md
Nadav Kohen b0cbed2552 Peer Protocol for Contract Negotiation Specification (#59)
* Added Peer Protocol specification

* Responded to review

* Responded to more review
2020-09-08 16:40:04 -05:00

2.8 KiB

Messaging Protocol

Overview

This protocol assumes an underlying authenticated and ordered transport mechanism that takes care of framing individual messages. BOLT #8 specifies the canonical transport layer used in Lightning, though it can be replaced by any transport that fulfills the above guarantees.

All data fields are unsigned big-endian unless otherwise specified.

Table of Contents

Connection Handling and Multiplexing

Implementations MUST use a single connection per peer; contract messages (which include a contract ID) are multiplexed over this single connection.

Message Format

We reuse the Lightning Message Format and the Type-Length-Value Format

Fundamental Types

Various fundamental types are referred to in the message specifications:

  • byte: an 8-bit byte
  • u16: a 2 byte unsigned integer
  • u32: a 4 byte unsigned integer
  • u64: an 8 byte unsigned integer

Inside TLV records which contain a single value, leading zeros in integers can be omitted:

  • tu16: a 0 to 2 byte unsigned integer
  • tu32: a 0 to 4 byte unsigned integer
  • tu64: a 0 to 8 byte unsigned integer

The following convenience types are also defined:

  • chain_hash: a 32-byte chain identifier (see BOLT #0)
  • contract_id: a 32-byte contract_id (see Protocol Specification)
  • sha256: a 32-byte SHA2-256 hash
  • signature: a 64-byte bitcoin Elliptic Curve signature
  • point: a 33-byte Elliptic Curve point (compressed encoding as per SEC 1 standard)
  • spk: A bitcoin script public key encoded as ASM prefixed with a Bitcoin CompactSize unsigned integer
  • short_contract_id: an 8 byte value identifying a contract funding transaction on-chain (see BOLT #7)
  • bigsize: a variable-length, unsigned integer similar to Bitcoin's CompactSize encoding, but big-endian. Described in BigSize.
  • contract_info: ???
  • oracle_info: ???
  • funding_input: ???
  • cet_signatures: ???
  • funding_signatures: ???

Authors

Nadav Kohen nadavk25@gmail.com

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.