spec.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <script setup lang="ts">
  2. useHead({
  3. title: `Specification — Hush Your Money`,
  4. meta: [
  5. { name: 'description', content: `Hush Your Money makes spending safu.` }
  6. ],
  7. })
  8. /* Initialize stores. */
  9. import { useSystemStore } from '@/stores/system'
  10. const System = useSystemStore()
  11. // onMounted(() => {
  12. // console.log('Mounted!')
  13. // // Now it's safe to perform setup operations.
  14. // })
  15. // onBeforeUnmount(() => {
  16. // console.log('Before Unmount!')
  17. // // Now is the time to perform all cleanup operations.
  18. // })
  19. </script>
  20. <template>
  21. <main class="max-w-5xl mx-auto py-5 flex flex-col gap-4">
  22. <h1 class="text-5xl font-medium">
  23. HUSH Specification
  24. </h1>
  25. <h4 class="w-2/3 text-xl text-rose-500 font-light italic">
  26. TL;DR — HUSH automagically manages the <span class="text-2xl font-medium">"toxic waste"</span> produced by your CoinJoin transaction;
  27. using a <span class="text-2xl font-medium">"TOR-free"</span> variation of the <NuxtLink to="https://cashfusion.org" target="_blank" class="text-2xl font-medium hover:underline">CashFusion</NuxtLink> protocol running on the <NuxtLink to="https://runonflux.io" target="_blank" class="text-2xl font-medium hover:underline">Flux Cloud</NuxtLink> network.
  28. </h4>
  29. <section class="mt-12 grid grid-cols-3">
  30. <div class="col-span-2 flex flex-col gap-4">
  31. <h2 class="text-3xl font-medium">
  32. Communication
  33. </h2>
  34. <ul class="pl-10 list-disc leading-8">
  35. <li>The server should support TLSv1.2 between the client and server.</li>
  36. <li>
  37. The server should only accept messages on the wire with the following structure:
  38. <ol class="pl-10 list-decimal">
  39. <li>Magic prefix `0x42bcc32669467873`.</li>
  40. <li>4-bytes specifying the length of the message in bytes in big endian order.</li>
  41. <li>The protobuf payload.</li>
  42. </ol>
  43. </li>
  44. </ul>
  45. </div>
  46. <div class="px-3 py-2 col-span-1 h-64 bg-sky-300 border-2 border-sky-500 rounded-xl shadow">
  47. <h3 class="text-xl text-white font-medium opacity-50">
  48. THIS IS A SIDEBAR
  49. </h3>
  50. </div>
  51. </section>
  52. <section class="mt-12 grid grid-cols-3">
  53. <div class="col-span-2 flex flex-col gap-4">
  54. <h2 class="text-3xl font-medium">
  55. Shuffle Transaction
  56. </h2>
  57. <p>
  58. In order to avoid client identification and ensure compatibility:
  59. </p>
  60. <ul class="pl-10 list-disc leading-8">
  61. <li>Transactions should use only ECDSA signing.</li>
  62. <li>Transactions should use `nLockTime = 0`.</li>
  63. <li>Transactions should use `nVersion = 1`.</li>
  64. <li>Each input should use `nSequence = 0xfffffffe`.</li>
  65. </ul>
  66. </div>
  67. <div class="px-3 py-2 col-span-1 h-64 bg-sky-300 border-2 border-sky-500 rounded-xl shadow">
  68. <h3 class="text-xl text-white font-medium opacity-50">
  69. THIS IS A SIDEBAR
  70. </h3>
  71. </div>
  72. </section>
  73. <pre class="p-5 bg-amber-100 text-lg">
  74. ## Protobuf payload
  75. - The client and server should communicate according to the [protobuf specification](https://github.com/Electron-Cash/Electron-Cash/blob/master/plugins/shuffle_deprecated/protobuf/message.proto) for messages.
  76. - The server should only receive messages of the `Packets` type.
  77. Example payload content for client registering with the server:
  78. ```
  79. Packets: [
  80. Signed{
  81. packet: Packet{
  82. registration: Registration{
  83. amount: bch_in_sats
  84. version: latest_version
  85. type: shuffle_type
  86. }
  87. }
  88. }
  89. ]
  90. ```
  91. Example payload serialized bytes:
  92. ```
  93. Work in Progress
  94. ```
  95. ## Flow
  96. [Flowchart (work in progress)](/images/single-player-flowchart.svg)
  97. ### Entering a Shuffle
  98. After the SSL connection is established, the client should send the server a message containing only the `verification key` of the player and the desired amount to shuffle in satoshis, the type of shuffle and the protocol version. This message should be unsigned.
  99. ```
  100. Packets: [
  101. Signed{
  102. packet: Packet{
  103. from_key: VerificationKey{
  104. key: verification_key
  105. }
  106. registration: Registration{
  107. amount: bch_in_sats
  108. version: latest_version
  109. type: shuffle_type
  110. }
  111. }
  112. }
  113. ]
  114. ```
  115. If all is well with the verification key, the server should send back an simple message with a session value and the player's number in the pool.
  116. ```
  117. Packets: [
  118. Signed{
  119. packet: Packet{
  120. session: some_UUID
  121. number: number_in_pool
  122. }
  123. }
  124. ]
  125. ```
  126. If something goes wrong with the handshake, the server should send a blame message and close the connection.
  127. ```
  128. Packets: [
  129. Signed{
  130. packet: Packet{
  131. message: Message{
  132. blame: Blame{
  133. reason: blame_reason_enum
  134. }
  135. }
  136. }
  137. }
  138. ]
  139. ```
  140. ### Forming the pool
  141. The server forms pools of a fixed size `N`. Every player who successfully registers should be added to the current pool and receive a confirmation as above. As long as the pool is not yet full, the server should also broadcast a simple message with the new player's number to all players in the pool, including the new player.
  142. ```
  143. Packets: [
  144. Signed{
  145. packet: Packet{
  146. number: new_player_number_in_pool
  147. }
  148. }
  149. ]
  150. ```
  151. After the pool reaches its limit (`N`), instead of the new player broadcast, the server should broadcast that the pool has entered Phase 1 (Announcement) to all pool participants.
  152. ```
  153. Packets: [
  154. Signed{
  155. packet: Packet{
  156. phase: ANNOUNCEMENT
  157. number: pool_size_N
  158. }
  159. }
  160. ]
  161. ```
  162. ### Player messaging
  163. After the client is registered as a player (it has a session UUID and number in the pool)
  164. it switches to game mode and can send/receive messages. There are two types of messages `broadcast` and
  165. `unicast`. `broadcast` messages are for everyone in the pool and `unicast` messages are only from one player to another.
  166. Every time the server accepts a message from the client it should check if it has:
  167. - A valid session UUID.
  168. - A valid verification key.
  169. - A valid player number.
  170. - A valid `from_key` field.
  171. - A valid or null `to_key` field where `to_key` must be in the same pool.
  172. If the message has a null value for `to_key` field, it means that it should be broadcast to every pool member
  173. If the message does not have a null value for `to_key` it should be unicast to the specified player.
  174. ### Blame messages
  175. In the blame phase, players can exclude unreliable players from the pool.
  176. If server got `N-1` messages from players to exclude a player with verification key `accused_key` then the player with this verification key should be excluded. The message should be in the following form:
  177. ```
  178. packet {
  179. packet {
  180. session: "session"
  181. from_key {
  182. key: "from_key"
  183. }
  184. phase: BLAME
  185. message {
  186. blame {
  187. reason: LIAR
  188. accused {
  189. key: "excluded_key"
  190. }
  191. }
  192. }
  193. }
  194. }
  195. Packets: [
  196. Signed{
  197. packet: Packet{
  198. session: session_id
  199. from_key: VerificationKey{
  200. key: verification_key
  201. }
  202. phase: BLAME
  203. message {
  204. blame Blame{
  205. reason: LIAR
  206. accused VerificationKey{
  207. key: accused_key
  208. }
  209. }
  210. }
  211. }
  212. }
  213. ]
  214. ```
  215. ### Losing the connection
  216. If one of the players closes their connection during a round of shuffling then the shuffle is terminated and a new shuffle should be initiated by reconnecting to the server.
  217. ### Exiting from the Shuffle
  218. If everything goes well, all the clients will disconnect when shuffling is complete.
  219. ## Definitions / Glossary
  220. - CoinJoin: A method by which transactions for a Bitcoin-based blockchain can be built to better protect the privacy of the parties involved. CoinJoin builds a transaction so that it uses identical `input` amounts thus normalizing the uniquely identifiable characteristic which `privacy attackers` rely upon to track the owner's of a particular `coin` over time.
  221. - CoinShuffle: A privacy protocol for Bitcoin based blockchains that attempts to achieve the benefits of the `CoinJoin` protocol in a decentralized way that does not rely on a trusted middle man.
  222. - CashShuffle: A companion to the `CoinShuffle` protocol. CashShuffle adds a low-trust infrastructure layer that allows for the discovery of `CashShuffle` participants as well as facilitating anonymous communication between them as they execute the `CashShuffle` protocol to create trustless `CoinJoin` transactions.
  223. - Blame: This may describe either the `Phase` immediately following a failed `CashShuffle` `Round` or the specific `Protocol Message` that is sent by a `Player` to signal a failed `Round`. The `Blame` `Protocol Message` takes a specific form. See the `Server Message` docs for more info.
  224. - Client: Any device or application that connects to a `CashShuffle` server with the intention and capability of carrying out the steps in the `CashShuffle` protocol. Clients manage most of the shuffling complexity thus minimizing the influence and involvement of the `Server`.
  225. - Coin: Frequently used as shorthand for an `Output` in a Bitcoin transaction.
  226. - Connection: The underlying network socket between `Client` and `Server` used to exchange `Protocol Messages`. Note, `Connections` have a 1:1 relationship with a `Player`.
  227. - Equivocation:
  228. - Packet: A specific data type used in the formation of a `Protocol Message`. See the communication spec for syntax.
  229. - Phase: Describes each of the stages within a `CashShuffle` `Round`. For complete descriptions see the "flow specification"
  230. - Player: The unique representation of a `Client` within a `Pool`. A `Client` may participate simultaneously in multiple `Pools`. It may be helpful to think of a `Player` as being linked to its ephemeral keypair ( `Verification Key` and `Signing Key` ) because all three die at the end of a `Round`, regardless of its outcome.
  231. - Pool: A group of `Players` within the `Server` that participate in a `Round`. `Players` are grouped based on the value of the `Coin` they intend to shuffle and the type of shuffle they intend to perform. While `Clients` may have multiple `Players` in different `Pools`, no client should be allowed in the same `Pool` instance as it would reduce the effectiveness of the `CashShuffle` protocol.
  232. - Protocol Message: A standardized message sent by either the `Server` or a `Player` in a shuffle `Round` containing data relevant to the state of a shuffle `Round`. Protocol messages must adhere to the `Protobuf` communcation spec outlined in this document.
  233. - Round: An abstraction describing the sequence of events that take place in a single attempt by a `Pool` of `Players` to shuffle their coins in adherence to the `CashShuffle` protocol.
  234. - Server: An intentionally minimal server whose primary duties are to put `Clients` into `Pools` and act as a blind ( minimal logs ) and dumb ( minimal complexity ) relay of `Protocol Message` during shuffles.
  235. - Signing Key: The private key portion of the ephemeral keypair created to be used exclusively for signing and verifying protocol messages for a particular `CashShuffle` `Round`. The `Verification Key` and its corresponding `Signing Key` are both intended for one time use.
  236. - Verification Key: The public key portion of the ephemeral keypair created to be used exclusively for signing and verifying protocol messages for a particular `CashShuffle` `Round`. The `Verification Key` and its corresponding `Signing Key` are both intended for one time use.
  237. </pre>
  238. <p>
  239. ONLY the Club Manager will receive BOTH:
  240. <ol>
  241. <li>List of Commitments</li>
  242. <li>List of (blinded) Components</li>
  243. </ol>
  244. </p>
  245. <p>
  246. EARLY Guest will have an advantage for:
  247. <ol>
  248. <li>Greater (component) anonymity against the Club Manager</li>
  249. </ol>
  250. </p>
  251. </main>
  252. </template>