|
| 1 | +# Overview: Semi-honest multiparty PayJoin |
| 2 | + |
| 3 | +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) first. |
| 4 | + |
| 5 | +// TODO: supporting silent payments |
| 6 | +// TODO: interaction / sequence diagram where we make a point of who is the initiator, responder, where they are both. |
| 7 | + |
| 8 | +// TODO: Two phases ?: you cannot add output until every input owner indicated no more OR we just say liveness is weak. |
| 9 | +Since this is semi honest the only thing we need tolerate is crashes: someone has a delay and adds inputs at the last second |
| 10 | + |
| 11 | +## Motivation |
| 12 | + |
| 13 | +Two-party Payjoin preserves privacy of input/output ownership against third-party observers, but it does not preserve privacy from the view of the counterparty itself. 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. |
| 14 | + |
| 15 | +With n > 2, 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. |
| 16 | + |
| 17 | +## Roles |
| 18 | + |
| 19 | +### Initiator and Responder |
| 20 | + |
| 21 | +The Initiator signals willingness to batch to their counterparty over a bidirectional channel. This signal is conveyed by including the mppj=1 parameter in the BIP21 URI. Either the BIP77 sender or receiver may be the Initiator. Parameters for their bi-directional channel may be encoded in the BIP21 (same as BIP77). |
| 22 | + |
| 23 | +The Responder is the counterparty who receives this signal. A Responder that does not support multiparty PayJoin will ignore the mppj=1 parameter and proceed with standard BIP77. A Responder that supports it waits for a session to be created. |
| 24 | + |
| 25 | +Two timeouts govern the phase of the whole protocol: |
| 26 | + |
| 27 | +* T_intent: the duration both parties are willing to wait for a session to be created after the intent to batch is signaled. If no session is created within T_intent, both parties MUST fall back to standard BIP77 over their existing bidirectional channel. |
| 28 | +* T_session: the duration of the multiparty session itself, after which input and output registration closes and the protocol advances to signing. |
| 29 | + |
| 30 | +T_session is defined by the `SessionCreator` while T_intent is defined by the `Initiator`. |
| 31 | + |
| 32 | +// TODO: how do we indicate to sender/recv that we should join a mppj? out of band? New message? mailbox with more payment instructions? |
| 33 | + |
| 34 | +### SessionCreator |
| 35 | + |
| 36 | +Either the `Initiator` or the `Responder` may create the session. The party that does so is the `SessionCreator`. |
| 37 | +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. |
| 38 | + |
| 39 | +### Participant |
| 40 | + |
| 41 | +Once a party joins a session (defined below) they become a `Participant`. All participants share the same obligations as outlined below. |
| 42 | + |
| 43 | +## Threat model |
| 44 | + |
| 45 | +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 in any form. However, they may attempt to learn as much as possible from the messages they observe. |
| 46 | + |
| 47 | +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. |
| 48 | + |
| 49 | +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. |
| 50 | + |
| 51 | +Its possible for some participants to join late. If there are N-1 RTS messages and a participant then registers then inputs and outputs this trivially creates a input-output link. |
| 52 | +Possible mitigation include ignoring this laggard when the effective balance condition and N RTS's have been collected. |
| 53 | + |
| 54 | +## PSBT CRDT |
| 55 | + |
| 56 | +### Session Parameters |
| 57 | + |
| 58 | +The SessionCreator fixes the following parameters before the session opens. All participants MUST verify that the final transaction conforms to these parameters before signing. |
| 59 | + |
| 60 | +* **Global transaction fields**: `nLocktime`, `nVersion` |
| 61 | +* **Feerate**: each participant contributes fees proportional to the weight of their inputs and outputs |
| 62 | +* **Input constraints**: `nSequence`, script type, segwit only |
| 63 | +* **Timeouts**: `T_session` (see Roles) |
| 64 | + |
| 65 | +### Join Semantics |
| 66 | + |
| 67 | +Participants learn transaction fragments in arbitrary order and accumulate them as they arrive. In the semi-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 merged by union. |
| 68 | + |
| 69 | +If the accumulated transaction does not balance, or any fragment violates the session parameters, a participant MUST refuse to sign and abandon the session. |
| 70 | + |
| 71 | +// TODO: sorting semantics under transport option B |
| 72 | +// TODO: refer to nothingmuch's document |
| 73 | + |
| 74 | +## Communication model |
| 75 | + |
| 76 | +### Option A: BIP77 Directory as anonymous broadcast channel |
| 77 | + |
| 78 | +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. |
| 79 | + |
| 80 | +#### Shared session secret |
| 81 | + |
| 82 | +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. |
| 83 | +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. |
| 84 | + |
| 85 | +### Option B: [Iroh Gossip](https://docs.iroh.computer/connecting/gossip) |
| 86 | + |
| 87 | +Iroh supports message dissemination via gossip. Peers subscribe to the a topic id and connect to some subset of endpoints. |
| 88 | +Peers will redundantly relay messages to peers that are not interested in a particular topic. The topic id can be a ephemeral secret embedded in the bip21 along side some bootstrapping endpoints. |
| 89 | + |
| 90 | +Iroh does not provide metadata privacy out the box. TBD when and why this can be problematic. |
| 91 | + |
| 92 | +Integrity and authenticity is provided out the box via TLS. This may be a blocker for TLS-less settings (bitcoin core). Perhaps HPKE (bip77) should be supported since iroh endpoints are just EC points. Some engineering work may be required to support secp256k1 if that is a blocker. |
| 93 | + |
| 94 | +// TODO: how to do discovery of other peers? |
| 95 | +// TODO: yolo RAFT leader based agreement / lattice agreement. Trusted leader = "trusted with liveness". |
| 96 | +// TODO; peers that are offline and missed input / output registration will leak them selves. |
| 97 | +// TODO: peers need reconcile messages that they missed |
| 98 | + |
| 99 | +## Protocol phases |
| 100 | + |
| 101 | +Input and output registration can be sent in any order. Ordering and sorting semantics must be defined a priori. |
| 102 | +One possible definition is to use the hash of the protocol transcript as a salt to sort the inputs and outputs. |
| 103 | + |
| 104 | +All messages are base64 encoded as PSBT fragments. |
| 105 | + |
| 106 | +### Message Timing |
| 107 | + |
| 108 | +To prevent timing correlation between a participant's messages, each message MUST be assigned a randomized delay before posting. |
| 109 | + |
| 110 | +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. If the count is not yet known, sample delays from an exponential distribution instead. |
| 111 | + |
| 112 | +Message publication times are assigned in two phases: |
| 113 | + |
| 114 | +1. Input registration, output registration, and RTS declarations are assigned publication times at the start of the session. |
| 115 | +2. Witness provision messages MUST NOT be assigned publication times until registration closes. |
| 116 | + |
| 117 | +// TODO: coinselection strategy? do peers run their own coinselection based on their own target outputs? What if a recv doesnt have target outputs? |
| 118 | + |
| 119 | +### Input Registration |
| 120 | + |
| 121 | +Each participant submits the transaction inputs they control. Inputs must be posted as independent messages. |
| 122 | +Inputs are not attributed to participants. Global observers should not be able to determine which inputs originate from the same party. |
| 123 | + |
| 124 | +### Psuedo Outputs |
| 125 | + |
| 126 | +A pseudo output is an anonymous 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. |
| 127 | + |
| 128 | +When the global sum of inputs minus outputs minus pseudo outputs reaches zero, every participant can independently verify the transaction is balanced and proceed declare RTS. |
| 129 | + |
| 130 | +### Output Registration |
| 131 | + |
| 132 | +Participants post their desired outputs as independent messages. No explicit linkage between a participant's inputs and outputs is revealed. Output and pseudo output messages MUST carry a unique identifier to prevent double accounting. |
| 133 | + |
| 134 | +A participant who wishes to back out of the session posts an output that causes the transaction balance to overflow. That is, their declared outputs exceed their input contribution. This makes the balance equation unsatisfiable and MUST cause all other participants to refuse to sign. |
| 135 | + |
| 136 | +### Ready-to-sign (RTS) declarations |
| 137 | + |
| 138 | +For each input they control, participants post a ready-to-sign declaration. This signals that they accept the current transaction template and are prepared to sign it. |
| 139 | +Only once all inputs have corresponding ready signals does the protocol advance. This ensures that all participants have finished contributing transaction fragments. |
| 140 | + |
| 141 | +When the global sum of inputs minus outputs minus pseudo outputs fee declarations hits zero, every participant can independently verify the transaction is balanced and sign. |
| 142 | + |
| 143 | +### Witness provision |
| 144 | + |
| 145 | +Participants provide witnesses for the inputs they control. Once all witnesses are available, any participant can assemble the fully signed transaction and broadcast it to the Bitcoin network. |
| 146 | + |
| 147 | +## Risks and limitations |
| 148 | + |
| 149 | +### Liveness fragility |
| 150 | + |
| 151 | +The protocol is fragile with respect to liveness. If even a single participant fails to provide witnesses in the final phase, the transaction cannot be completed. This is the worst-case outcome and is inherent to interactive multiparty transactions requiring unanimous signatures. |
0 commit comments