From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 60541C002D for ; Sat, 20 Aug 2022 08:20:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2D2928329E for ; Sat, 20 Aug 2022 08:20:07 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2D2928329E Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.a=rsa-sha256 header.s=protonmail3 header.b=HB22EmQS X-Virus-Scanned: amavisd-new at osuosl.org X-Spam-Flag: NO X-Spam-Score: -2.101 X-Spam-Level: X-Spam-Status: No, score=-2.101 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s24PaHDHWvVP for ; Sat, 20 Aug 2022 08:20:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1918683299 Received: from mail-4319.protonmail.ch (mail-4319.protonmail.ch [185.70.43.19]) by smtp1.osuosl.org (Postfix) with ESMTPS id 1918683299 for ; Sat, 20 Aug 2022 08:20:05 +0000 (UTC) Date: Sat, 20 Aug 2022 08:20:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1660983603; x=1661242803; bh=9gWtbGstMZT424NptfxO5AaHy75PQiZz9i2TXWbrN3Y=; h=Date:To:From:Reply-To:Subject:Message-ID:Feedback-ID:From:To:Cc: Date:Subject:Reply-To:Feedback-ID:Message-ID; b=HB22EmQSCGbVHvcGhdGegSs8xo84qMuyQA/S4qMP+pOQg+CMJ45ALr4uuhoeETDZI u9id2/VxxI/PkubwjLrKufntTSV+pc1br0VArSNDFrtRKgR2RTQ9mR7ofw0DhDmIUF 64RMgKdIU/wXwMGUn41OZ+6K4Id0pGFBFwQMKFFO0Cet20L4BPm+roqtLIE5iouXwQ y2fvA96UkMnkWs34wtmxIoIT3tgRm20aFDudobe5V6y5CJj03awhPYaNvsRHICLMyE z5njmMeQAToWfWTX6l3yV2EzJqQuVQGHLVJzBsE+6BRg8/YbA6sQYwZIx0MgPELDCd uHgjpQ/lRIc1w== To: Bitcoin Protocol Discussion From: alicexbt Reply-To: alicexbt Message-ID: <7gXWd6OVJjiW7aCeon8q-xlWfCMJkIEVCaeokjSVI16OvQPkPmEsSeGY0cGu4yVveimNUYsyG18Ro7JgUutfqXv5wKMMgJZD2c8ftAMFcbQ=@protonmail.com> Feedback-ID: 40602938:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Sat, 20 Aug 2022 09:28:32 +0000 Subject: [bitcoin-dev] joinstr: coinjoin implementation using nostr X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Aug 2022 08:20:07 -0000 Hi Bitcoin Developers, I have written a python script as proof of concept for the [coinjoin implem= entation][1] using [nostr][2]. I used a lot of Python scripts created by ot= hers in school, so it feels nice to offer something that could be useful to= others. The implementation uses Bitcoin Core wallet and RPCs: `listunspent`, `getne= waddress`, `scantxoutset`, `createpsbt`, `combinepsbt`, `finalizepsbt` and = `sendrawtransaction`. It requires python-nostr library because nostr is use= d for coordination between peers. Nostr is a decentralized network based on= cryptographic keypairs. It is not peer-to-peer however simple and scalable= . Every step is published as an event using a nostr relay and 5 peers coordin= ate to create, sign and broadcast a coinjoin transaction. I need to write = a NIP that would be an alternative to blind signatures. Relay will share a = random secret with clients for one round which should be present in output = registration request although never gets published. If someone tries to reg= ister an output without registering any inputs, request would not have the = number initially shared with inputs so request would get rejected or publis= hed as unverified. Relay would not be able to link inputs and outputs as th= e number is same for all inputs in a round and they get registered at diffe= rent times with new keys and IP address. Clients can use multiple relays at= the same time to avoid trusting one relay. This would result in different = shared secret number but same process. If a relay tries to cheat, users wil= l not sign the transaction and avoid using it in future. Usage: 1)Run `python coinjoin.py` and enter descriptor for one of the inputs. 2)Script will check inputs for this round in every 30 seconds and register= a new adddress for output once 5 inputs are registered. 3)Similar check happens every 30 seconds for outputs. Last peer should cre= ate a PSBT. 4)Unsigned PSBT will be printed and signed by wallet with `walletprocessps= bt` RPC. 5)Script will check signed PSBTs and last peer to sign should finalize coi= njoin transaction once 5 signed PSBTs are received. 6)Coinjoin transaction will be broadcasted and txid will printed. Example: ``` List of utxos in wallet: wpkh([53830dca/84'/1'/0'/0/0]02449be5fb74725255eeeb50eba930fa87705f21e99d13= cd710cf2c1f21153c808)#x2hyyeg5 Enter descriptor for the input registration: wpkh([53830dca/84'/1'/0'/0/0]0= 2449be5fb74725255eeeb50eba930fa87705f21e99d13cd710cf2c1f21153c808)#x2hyyeg5 event id: bcbbe62d75d99fed73f1e50ac58a38d1840b658951893e63c0322b378d7d56f0 ``` ``` tb1qhxrp4zl54ul0twtyz0gury5399q7z0kvqqrl6m registered for output event id: 9449c9065bef356d21507a98f88b028b17fc1c49eb195c8d4420604fcaaef041 ``` ``` Unsigned PSBT: cHNidP8BAP1yAQIAAAAFtMaoJYcXvOG5L3Yaz3YyS7gIt4h5/zzOrRRS3hrV= vwoAAAAAAP////+o83geaSm4L76KToIUl5MiZqLAUbIDJLq6DWrjP/3b8AEAAAAA/////zEF3CX= IvVHpIa7No1s1yg+KtyOfXTRSyWnOdXMfzcDwAQAAAAD/////wMa4XAgnU+39Ien+KG9rYtv8bL= MNYakmZyY/QFfwLRcAAAAAAP/////5M42ID6uLmQTb2tnFHnN7UMpnDD25uN8ZX7A+GNSM3QEAA= AAA/////wV4xwEAAAAAABYAFLmGGov0rz71uWQT0cGSkSlB4T7MeMcBAAAAAAAWABSc0/FM6Hdb= dxh10IJkYOklVFWqjnjHAQAAAAAAFgAUPSZKe/w6PT6qIF+WhL4wHaFymjd4xwEAAAAAABYAFMx= 0rxYlpPWB3NFry4Ctk2eVi/UNeMcBAAAAAAAWABSzc4xK0VTfvjK0MHXrAUFLYgYnOgAAAAAAAA= AAAAAAAAAAAA=3D=3D event id: 976744b38fa9343fb79e1b5215512ead6ee08e5890d79a201fc5b872f6de4eba ``` ``` Signed PSBT: cHNidP8BAP1yAQIAAAAFtMaoJYcXvOG5L3Yaz3YyS7gIt4h5/zzOrRRS3hrVvw= oAAAAAAP////+o83geaSm4L76KToIUl5MiZqLAUbIDJLq6DWrjP/3b8AEAAAAA/////zEF3CXIv= VHpIa7No1s1yg+KtyOfXTRSyWnOdXMfzcDwAQAAAAD/////wMa4XAgnU+39Ien+KG9rYtv8bLMN= YakmZyY/QFfwLRcAAAAAAP/////5M42ID6uLmQTb2tnFHnN7UMpnDD25uN8ZX7A+GNSM3QEAAAA= A/////wV4xwEAAAAAABYAFLmGGov0rz71uWQT0cGSkSlB4T7MeMcBAAAAAAAWABSc0/FM6Hdbdx= h10IJkYOklVFWqjnjHAQAAAAAAFgAUPSZKe/w6PT6qIF+WhL4wHaFymjd4xwEAAAAAABYAFMx0r= xYlpPWB3NFry4Ctk2eVi/UNeMcBAAAAAAAWABSzc4xK0VTfvjK0MHXrAUFLYgYnOgAAAAAAAQBx= AgAAAAG+qpMXZCy6tBuUlgo8JD0GVXKp60FkhwDeg2sF1fkFkwMAAAAA/f///wLo9wEAAAAAABY= AFFfLA5xarC/w/SxeMDQ5tuXrYJLUWwMAAAAAAAAWABRfPf//hwMjHB4OKj87cU19XOSh7yOWAQ= ABAR/o9wEAAAAAABYAFFfLA5xarC/w/SxeMDQ5tuXrYJLUAQhrAkcwRAIgOIhLoC5348U8YkEr4= GU1K4yWskIOEXgW4Wsk/W2cR7ICIEJXqtOuDJ5CkwrSuwJLWtzab4dslbN3KuL/pyooMnOCASEC= RJvl+3RyUlXu61DrqTD6h3BfIemdE81xDPLB8hFTyAgAAAAAACICA77Cnd6o3kr0yc+91eabpOn= 5igs/MUMbudNYSS6oyMWMGFODDcpUAACAAQAAgAAAAIAAAAAAFAAAAAAAAAAA event id: 5846b6e6902f3c5a43496d7d9785ed62444aa74963f03c33d637d8b09ee7a139 ``` ``` Coinjoin tx: 75e490b10b15a6a0422f25ff66ad98ef70390c8fecaac02712705dce8cc356= 4b event id: 9b5d4bf279b59e2b6e539e683fba83da72dce2b640360aa95db1b1400be93190 ``` There are lot of things that could be improved and a few suggestions are in= the gist that described the [idea][3]. I would love read to any opinions a= bout this experiment and will start working on creating an Android app for = joinstr next week. Credits: - fiatjaf (Nostr) - Andrew Chow (PSBT) - Jeff Thibault (python-nostr) - Existing coinjoin implmentations [1]: https://github.com/1440000bytes/joinstr [2]: https://github.com/nostr-protocol/nostr [3]: https://gist.github.com/1440000bytes/1c305097b070c8374cc3b91f50314a45 /dev/fd0 Sent with Proton Mail secure email.