Skip to content

Commit 5652fb0

Browse files
authored
Merge pull request #35 from MostroP2P/docs/update-dispute-chat
Docs/update dispute chat
2 parents 8157c1c + be8e459 commit 5652fb0

File tree

3 files changed

+50
-33
lines changed

3 files changed

+50
-33
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44

55
---
66

7-
- [User Guide (English)](https://mostro.network/docs-english/)
8-
- [Guía de Usuario (Español)](https://mostro.network/docs-spanish/)
9-
- [Run Your Own Node](https://mostro.community/guide)
10-
11-
---
12-
137
- [Keys management](./key_management.md)
148
- [Creating a Sell order](./new_sell_order.md)
159
- [Creating a Sell range order](./new_sell_range_order.md)
@@ -27,9 +21,9 @@
2721
- [Release](./release.md)
2822
- [Rate user](./user_rating.md)
2923
- [Cancel](./cancel.md)
24+
- [Peer-to-peer Chat](./chat.md)
3025
- [Dispute](./dispute.md)
3126
- [Dispute Chat](./dispute_chat.md)
32-
- [Peer-to-peer Chat](./chat.md)
3327
- [List disputes](./list_disputes.md)
3428
- [Admin Settle order](./admin_settle_order.md)
3529
- [Admin Cancel order](./admin_cancel_order.md)

src/dispute_chat.md

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,70 @@
11
# Dispute Chat
22

3-
Once an admin takes a dispute, both the admin and the involved parties (buyer and seller) can communicate through an encrypted chat using Gift Wrap messages (NIP-59).
3+
The dispute chat uses the same shared key encryption scheme as the [Peer-to-peer Chat](./chat.md). Instead of computing a shared key between buyer and seller, each party computes an independent shared key with the admin who took the dispute.
44

5-
## Sending a message
5+
## Establishing the shared key
66

7-
Users and admins send messages using action `send-dm`. The message content is wrapped in a Gift Wrap event (kind 1059) to ensure privacy and encryption.
8-
9-
### User sending a message
10-
11-
Here is an example of a user sending a message to the admin:
7+
When an admin takes a dispute, Mostro sends an `admin-took-dispute` message to each party (buyer and seller) containing the admin's pubkey:
128

139
```json
1410
[
1511
{
16-
"dm": {
12+
"order": {
1713
"version": 1,
18-
"action": "send-dm",
14+
"id": "<Order Id>",
15+
"action": "admin-took-dispute",
1916
"payload": {
20-
"text_message": "Hello, I need help with this order"
17+
"peer": {
18+
"pubkey": "<Admin's pubkey>"
19+
}
2120
}
2221
}
2322
},
2423
null
2524
]
2625
```
2726

28-
### Admin sending a message
27+
Upon receiving this message, the client computes the shared key using ECDH:
2928

30-
Admins use the same format to send messages to users:
29+
```
30+
Shared Key = ECDH(tradeKey.private, adminPubkey)
31+
```
32+
33+
The admin computes the same shared key from their side:
34+
35+
```
36+
Shared Key = ECDH(adminPrivateKey, tradeKey.public)
37+
```
38+
39+
Each party (buyer and seller) has its own independent shared key with the admin. A session can have both a peer shared key (for the P2P chat) and an admin shared key (for the dispute chat) simultaneously.
40+
41+
## Sending and receiving messages
42+
43+
Messages are wrapped and unwrapped using the same simplified NIP-59 scheme described in [Peer-to-peer Chat](./chat.md#example). The inner event is a kind 1 event signed by the sender's key, encrypted with NIP-44 and placed inside a kind 1059 Gift Wrap event.
44+
45+
The `p` tag in the wrapper event points to the **admin shared key's pubkey**, not the trade key:
3146

3247
```json
33-
[
34-
{
35-
"dm": {
36-
"version": 1,
37-
"action": "send-dm",
38-
"payload": {
39-
"text_message": "I'm reviewing the evidence, please wait"
40-
}
41-
}
42-
},
43-
null
44-
]
48+
{
49+
"content": "<Encrypted content>",
50+
"kind": 1059,
51+
"created_at": 1703021488,
52+
"pubkey": "<Ephemeral pubkey>",
53+
"id": "<Event Id>",
54+
"sig": "<Ephemeral key signature>",
55+
"tags": [["p", "<Admin Shared Pubkey>"]]
56+
}
4557
```
4658

47-
## Receiving messages
59+
## Subscribing to messages
60+
61+
Clients subscribe to kind 1059 events filtered by the admin shared key's pubkey:
62+
63+
```json
64+
{
65+
"kinds": [1059],
66+
"#p": ["<Admin Shared Pubkey>"]
67+
}
68+
```
4869

49-
Clients must subscribe to kind 1059 events with a `p` tag matching their pubkey. The Gift Wrap protocol (NIP-59) ensures that only the intended recipient can decrypt and read the messages, while preserving the sender's identity through the SEAL layer
70+
Clients should discard any messages received from pubkeys other than the Mostro node or the dispute solver.

src/overview.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Overview
22

3+
**See also:** [User Guide (English)](https://mostro.network/docs-english/) | [Guía de Usuario (Español)](https://mostro.network/docs-spanish/) | [Run Your Own Node](https://mostro.community/guide)
4+
35
Mostro uses [Addressable Events](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds) to publish different types of information. Each event type has its own `kind`:
46

57
| Event Type | Kind | Description |

0 commit comments

Comments
 (0)