Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 169 additions & 0 deletions honest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Overview: Multiparty transaction construction in honest peer threat model

The following is a concrete description of the honest multiparty PayJoin protocol. To understand why certain choices design were made, it is recommended to read the [overview document](./00_overview.md) first.

## Motivation

This protocol is best understood as a collaborative transaction construction protocol for mutually trusting parties. Its purpose is to let participants jointly build a transaction with potentially better privacy properties and cost savings than a unilateral construction.

## Trust Model

* Liveness: peers are expected to follow the protocol flow and remain reachable long enough for protocol messages to eventually disseminate and for participants to converge. Some deployments may use timeout-based progress under partial synchrony, while others may rely on eventual delivery without strict timing guarantees.

* Privacy: peers are trusted not to leak or retain their sensitive observations learned during the protocol, including timing, message ordering, and transport metadata (for example IP-layer linkability data) beyond what is needed to complete the session.

Importantly, fund safety does not depend on peer honesty. Each participant signs only a transaction they locally validate and accept under `SIGHASH_ALL`. Therefore, malformed or economically unacceptable constructions are treated as liveness failures, not fund-loss safety failures.

## Roles

### Initiator and Responder

The Initiator signals willingness to batch to their counterparty over a bidirectional channel. In this document, signaling `mppj=1` via BIP21 is treated as one practical bootstrap example, not a normative long-term mechanism. Either BIP-77 receiver or sender may be the Initiator.

For multiparty deployments, the preferred direction is richer payment instructions that can support post-quantum HPKE choices, sender-initiated interactions, and long-lived/reusable authenticated channels.
// TODO: elaborate more on payment instructions

The Responder is the counterparty who receives this signal. If a peer does not support the chosen multiparty signaling mechanism, it falls back to standard BIP77 behavior. If it does support the mechanism, it waits for a session to be created.

Two timeouts govern the phase of the whole protocol:

* `T_intent`: the absolute expiration time After which if no session is created within `T_intent`, both parties must fall back to standard BIP77 over their existing bidirectional channel. Since the intent can be delivered over a async. channel this is an absolute expiration not a relative duration.
* `T_session`: the duration of the multiparty session itself, after which the session is considered expired.

`T_session` is defined by the `SessionCreator` while `T_intent` is defined by the `Initiator`.

// TODO: specify a concrete signaling/payment-instructions format once requirements for PQ HPKE, sender initiation, and reusable authenticated channels are finalized

### SessionCreator

Either an `Initiator` or a `Responder` may create the session. The party that does so is the `SessionCreator`.
The `SessionCreator` is responsible to creating session parameters (defined below), bootstrapping the transport mechanism and disseminating session information to the rest of the peers to the best of their capabilities. `SessionCreator` holds no special authority once the session is live. They simply become a participant.

### Participant

Once a party joins a session they become a `Participant`. All participants share the same obligations as outlined below in the phases section.

### Diagrams

Single receiver, two senders. Receiver is `Initiator` for both senders and becomes the `SessionCreator`.

```mermaid
sequenceDiagram
participant R as Receiver (Initiator)
participant S1 as Sender 1 (Responder)
participant S2 as Sender 2 (Responder)

R->>S1: BIP21 URI (mppj=1)
R->>S2: BIP21 URI (mppj=1)

R->>S1: session invitation (s, session params)
R->>S2: session invitation (s, session params)
```

Sender 1 is the `Initiator` to the receiver who is an `Initiator` to sender 2. The receiver at time 3 becomes the `SessionCreator`.

```mermaid
sequenceDiagram
participant S1 as Sender 1 (Initiator)
participant R as Receiver (Responder / Initiator / SessionCreator)
participant S2 as Sender 2 (Responder)

S1->>R: BIP21 URI (mppj=1)
R->>S2: BIP21 URI (mppj=1)

R->>S1: session invitation (s, session params)
R->>S2: session invitation (s, session params)
```

## Session Parameters

The `SessionCreator` fixes the following parameters before the session opens. All participants must verify that the final transaction conforms to the relevant parameters before signing. Size limit cannot be enforced. The `SessionCreator` only knows their immediate neighborhood of peers but those peers may invite others.

* **Global transaction fields**: `nVersion`, `locktype` (time or height based)
* **Feerate**: each participant contributes fees proportional to the weight of their inputs and outputs
* **Input constraints**: `nSequence`
* **Timeout**: `T_session`

## PSBT CRDT

### Join Semantics

Participants learn transaction fragments in arbitrary order and accumulate them as they arrive. In the honest setting there are no conflicting writes: global fields are fixed by the session parameters and each participant controls disjoint inputs and outputs. Any two valid fragments can therefore be always merged.

For this document, `balance` means the running value equation over the accumulated transaction view:

`balance = sum(inputs) - sum(outputs) - sum(pseudo outputs)`

where pseudo outputs default to zero until any are declared.

If the accumulated transaction does not balance, or any fragment violates the session parameters, a participant can refuse to sign and abandon the session.

// TODO: refer to nothingmuch's document

## Communication model

The protocol assumes an abstract session-scoped broadcast channel for disseminating PSBT fragments.

Required channel properties:

All participants can publish protocol messages to the same session channel, with messages authenticated and kept confidential within the participant set. Each participant is able to read and merge messages from all others into their own local transaction view. While message delivery may be delayed or received out of order, the protocol ensures eventual dissemination and reconciliation of all messages within the session window `T_session` if all parties behave honestly.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the protocol ensures eventual dissemination and reconciliation of all messages within the session window T_session if all parties behave honestly.

T_session implies synchronous communication model so "honestly" implies no crash faults, but i think it's perfectly fine to define this in both the sync and async or partial synchrony settings and only require eventual consistency on the set of messages.

also, i now remember why i brought up raft: we can't guarantee termination without ensuring the input set is finalized, which is an agreement/consensus problem. we can only guarantee eventual consistency, and once a balance == condition is reached then signing can proceed, but in principle there may be a whole set of omission faults due to one user getting partitioned, and failing to contribute their inputs, which in the partial synchrony or async setting is not considered faulty


In this honest setting, a separate agreement protocol is not required for the success path. Gossip dissemination plus deterministic transaction construction is sufficient: if participants receive the same valid fragments, they converge to the same unsigned transaction. Any temporary view differences are primarily a liveness concern (delay or retry), not a fund-safety concern.

Candidate instantiations include [Iroh documents](https://docs.iroh.computer/protocols/documents), [MDK](https://github.com/marmot-protocol/mdk), or a shared append-only mailbox like a [BIP-77 Directory](https://github.com/bitcoin/bips/blob/master/bip-0077.md). These are examples, not normative requirements.

This setting does not require transport-layer metadata privacy as a protocol requirement. Participants are already mutually trusted with privacy in the honest model, including trust not to retain or misuse linkability information learned during the session. As a result, unlike the [semi-honest](./semi-honest.md) setting, the protocol does not depend on anonymous transport primitives to maintain the intended privacy properties within the participant set.

Note that encryption alone does not prevent traffic analysis, so an external passive adversary, and in particular a global passive adversary, may be able to infer the use of this protocol, potentially correlate its use to a transaction broadcast and even attribute particular inputs and outputs to the specific participants based on metadata such as message sizes.

### Message Delivery

The channel must provide reliable delivery at the session level: every valid protocol message must eventually be delivered to every participant within `T_session`, so all honest participants converge on the same message set before signing.

Different instantiations can satisfy this in different ways. Unordered gossip-style channels may use set reconciliation. The protocol specifies only the delivery/convergence property, not the mechanism.

### Network Partitions

Network disruptions can partition the broadcast channel. If a partition occurs before session creation, each component can treat its activity as an independent session.

The critical failure case is a partition during an active session. Disconnected components can each converge to a locally balanced transaction and sign independently. In arbitrary transaction construction, one component may temporarily over-declare outputs while waiting for missing inputs, or abort and restart after timeout. If value flows happen to balance differently across components, one branch may finalize while another stalls, and a sender can pay an unintended receiver. This is a safety failure.

A global consensus protocol over the inputs set could prevent this class of error, but the honest setting does not assume a pre-established participant set or PKI needed to bootstrap that mechanism.

To reduce partition-induced mispayment risk, require explicit receiver confirmation before any sender signs. Once a receiver gets a zero balance the send an acklowedgement to the sender including the hash of the canonical record of outputs. If the sender's hash matches they proceed to signing.

// TODO should the reciever also include their output PSBT fragment in the same message?

## Protocol Phases

Inputs and outputs can be sent in any order. Ordering semantics must be defined a priori.
One possible definition is to use the hash of the protocol transcript as a salt to sort the inputs and outputs.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can be more normative about this, with details in the unordered PSBT writeup...

in this protocol this could be done either with explicit sort keys per input/output (and thus maintaining some compatibility with lightning interactive-tx, so long as only monotone operations are used there) or by defining a procedure for contributing entropy to a sorting seed, let's discuss options in a call there's a few i can think of


All messages are raw binary encoded PSBT fragments.

### Input Registration

Each participant submits the transaction inputs they control. Inputs must be posted as independent messages.
Global passive observers should not be able to determine which inputs originate from the same party.

### Psuedo Outputs

A pseudo output is an declaration of fee contribution above the session-mandated minimum. It participates in the balance equation like a real output but does not appear in the final transaction. Participants must post a pseudo output only when their intended fee contribution exceeds what the session parameters require. Peers must be careful to exclude such outputs from size and fee calculations. And exclude them from the final serialized transaction to sign.

### Output Registration

Both output and pseudo output messages must carry a unique identifier to prevent double accounting. E.g a peer may read an output message multiple times. Since `TxOut`'s are not uniquely indentifiable that peer would have no ability to de-duplicate.

To signal their intent to back out of the session, a participant can deliberately post outputs that exceed their input contribution, causing the transaction balance to overflow. This action makes the balance equation unsatisfiable and prompts all other participants to refuse to sign.

When the `balance` reaches zero, every participant can independently verify the transaction is balanced and proceed to witness provision.

This honest variant does not require an explicit Ready-to-Sign declaration on the success path. With pseudo-output accounting, readiness is implicit once participants converge on the same message set and each participant has contributed at least one input before final output/pseudo-output closure.

### Witness provision

Participants provide [finalized](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#user-content-Input_Finalizer) witnesses for the inputs they control. Once all witnesses are available, any participant can serve as the [BIP-174 combiner role](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#user-content-Combiner), assemble the fully signed transaction and broadcast it to the Bitcoin network.

## Silent Payments

To support Silent Payments, the recipient broadcasts its [BIP 352 scan public key](https://github.com/bitcoin/bips/blob/master/bip-0352.mediawiki) as a independent message. Each participant derives the Silent Payment `scriptPubKey` from the shared transaction inputs and recipient scan public key. When the input set changes, all participants recompute the Silent Payment output before signing.
64 changes: 64 additions & 0 deletions semi-honest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Overview: Multiparty PayJoin for semi-honest peer threat model

The following is a concrete description of the semi-honest multiparty PayJoin protocol. To understand why certain choices design were made, it is recommended to read the [overview document](./00_overview.md) and [honest protocol document](./honest.md) first.

// TODO: supporting silent payments
// TODO: Two phases ?: you cannot add output until every input owner indicated no more OR we just say liveness is weak.
Since this is semi honest the only thing we need tolerate is crashes: someone has a delay and adds inputs at the last second

## Motivation

Two-party and honest versions of the multi party Payjoin protocol preserves privacy of input/output ownership against third-party observers, but it does not preserve privacy from the view of the counterparty itself. E.g In a two-party protocol, each participant can trivially attribute all unknown inputs and outputs to the other party. This reveals cluster information and requires counterparty trust.

With n > 2 and metadata privacy, this privileged view is reduced. Payments and change outputs become ambiguous within the participant set. As a result, participants do not need to trust any specific counterparty with their clustering information. Increasing the number of parties therefore reduces counterparty trust and weakens clustering inferences.

## Threat model

This protocol operates in a semi-honest (honest-but-curious) model. All participants are assumed to economically proximate and thus follow the protocol as specified. They are not expected to deviate from the rules or misbehave. However, they may attempt to learn as much as possible from the messages they observe and the final transaction.

Concretely, if any party learns the full plaintext transcript of messages, they should not be able to determine which inputs or outputs belong to which of the other participants.

The protocol does not assume Byzantine robustness, and it does not attempt to detect or punish misbehavior. If a participant fails to follow through, the protocol may fail, but safety is not compromised - i.e participants will only provide witness if their expected outputs are included in the final transaction.

Its possible for some participants to join late. If there are N RTS messages and a participant then registers then inputs and outputs this trivially creates a input-output link.
Possible mitigation include ignoring the laggard when the effective balance condition and N RTS's have been collected.

## Roles

The roles defined in the [honest protocol](./honest.md#roles) apply here without modification. The semi-honest model does not change who the Initiator, Responder, SessionCreator, or Participant are, nor how sessions are initiated. The only difference is that participants in this model are curious and may attempt to infer ownership links from observed messages and the final transaction. The communication model is therefore strengthened to prevent this.

## Communication model

In the semi-honest model, participants follow protocol rules but are still curious and may try to infer ownership links from any side channel available to them. For that reason, content encryption alone is not sufficient: if transport metadata reveals who posted which message and when, peers can correlate messages into participant-level clusters.

Metadata privacy is therefore a protocol requirement in this setting. The communication layer must hide sender network identity and reduce linkability across messages, so that learning the transcript does not trivially reveal input-output ownership.

This is why iroh gossip is not sufficient here as the primary transport. While iroh provides efficient dissemination, it does not by itself provide the metadata-hiding guarantees this threat model requires.

Separately, dissemination and agreement should be distinguished. Gossip is enough to disseminate messages and can still provide eventual convergence when deterministic merge rules are used. A separate agreement mechanism (some specific instantiation of a lattice agreement protocol) is only needed when stronger guarantees are required for intermediate consistency, timely termination, (crashes?) or recovery under communication disruptions.

Given those tradeoffs, using the BIP77 directory for total order is a simpler direction. A shared append-only mailbox gives participants a practical, common message order to process, which reduces the need to deploy and tune a separate distributed agreement layer. In other words, it combines the metadata privacy this model requires with a straightforward coordination primitive that is easier to implement and operate.

### BIP77 Directory as anonymous broadcast channel

Communication is mediated by a PayJoin directory accessed via OHTTP, following the same metadata privacy model as BIP77. For multiparty use, the directory mailbox supports append semantics. Multiple participants write to the same mailbox, and peers poll and retrieve all appended messages. The mailbox functions as an anonymous broadcast log of encrypted payloads.

#### Shared session secret

A session is defined by a single ephemeral shared secret s. Any participant who learns s can join the session. Knowledge of this secret is the only admission control mechanism.
Participants derive mailbox identifiers and initialize their HPKE context with s. The shared secret is distributed via the existing bidirectional channel. Parties who learn s can both read and write to the mailbox. All payloads are encrypted using HPKE, so the directory only handles opaque ciphertext blobs and cannot link messages to participants.

## Protocol phases

For the canonical phase-by-phase flow, see the honest protocol document: [Overview: Honest multiparty PayJoin](./honest.md#protocol-phases).

### Message Timing

To prevent timing correlation between a participant's messages, each message must be assigned a randomized delay before posting.

If the total number of messages is known in advance, sample n uniform random times within the session window and post each message at its assigned time.

Message publication times are assigned in two phases:

1. Input registration, output registration, and RTS declarations are assigned publication times at the start of the session.
2. Witness provision messages must not be assigned publication times until registration closes.