# How does it work?

Joinstr protocol uses ALL| ANYONECANPAY SIGHASH flag and outputs are registered first. This reduces some steps in coordination required for coinjoin.

> Coinjoin with less steps using ALL|ANYONECANPAY
>
> <https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2023-May/021696.html>

<img src="/files/HyTk9Fl0LwtNv6Ji2hGS" alt="" class="gitbook-drawing">

The process is simple and involves only 3 steps. All the users publish a new address in the first step for output registration. It is followed by publishing PSBT which has 1 input and all outputs signed with ALL | ANYONECANPAY. These PSBTs are combined, finalized and broadcasted.&#x20;

Users can decide the denomination, number of peers and nostr relays by creating pools.&#x20;

See NIP for details about pools used in joinstr: [https://gitlab.com/invincible-privacy/joinstr/-/blob/main/NIP.md](https://gitlab.com/invincible-privacy/joinstr/-/blob/main/NIP.md?ref_type=heads)

#### Costs

All users pay equal fees in every round which in total is used for transaction fees. Only 1 transaction is required for coinjoin and fees depends on the mempool when pool is created. Each user would pay approximately 2000 sats if 10 sat/vbyte fee rate is used for the coinjoin transaction. Participants can also use paid nostr relays although there needs to be at least 1 common relay between the participants for coordination to work properly.

Read more about [market making in joinstr](https://uncensoredtech.substack.com/p/market-makers-in-joinstr) to earn fees from pools.

#### Privacy

A new public/private key pair is used for creating pools and sending join request. Everything else is communicated using an encrypted channel in which all peers use the same key. All peers in a pool use the same IP address for a coinjoin round and its implemented using Riseup VPN. However, the protocol also supports Tor in which clients can refresh Tor circuits to avoid links between inputs and outputs.

Sybil Resistance: [AUT-CT](https://github.com/AdamISZ/aut-ct) is used to increase the cost of sybil attacks.&#x20;

#### Security

DoS vectors are reduced by using basic checks, ring signatures, encrypted nostr channels for each round and encouraging users to try paid, private, custom nostr relays.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.joinstr.xyz/overview/how-does-it-work.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
