<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hiroki Gondo on Medium]]></title>
        <description><![CDATA[Stories by Hiroki Gondo on Medium]]></description>
        <link>https://medium.com/@nayuta-gondo?source=rss-ec449712cbf7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*F6dEqi1ydTW6N1ff</url>
            <title>Stories by Hiroki Gondo on Medium</title>
            <link>https://medium.com/@nayuta-gondo?source=rss-ec449712cbf7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 16:25:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nayuta-gondo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[RGB Protocol でアセットを発行し転送する]]></title>
            <link>https://medium.com/nayuta-engineering-blog-ja/rgb-protocol-%E3%81%A7%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%82%92%E7%99%BA%E8%A1%8C%E3%81%97%E8%BB%A2%E9%80%81%E3%81%99%E3%82%8B-061b040a49d2?source=rss-ec449712cbf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/061b040a49d2</guid>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[stable-coin]]></category>
            <category><![CDATA[rgb]]></category>
            <dc:creator><![CDATA[Hiroki Gondo]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 02:20:58 GMT</pubDate>
            <atom:updated>2024-01-29T06:46:11.107Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2jwWEySrFnLv5axo" /><figcaption>Photo by <a href="https://unsplash.com/@theshubhamdhage?utm_source=medium&amp;utm_medium=referral">Shubham Dhage</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>この記事では <a href="https://rgb.info/ja/">RGB Protocol</a>（以下 RGB と略す）で任意のアセット（代替可能トークン）を発行しそれを転送する手順を説明する。実装は <a href="https://github.com/RGB-Tools/rgb-sandbox">rgb-sandbox</a> を用いる。</p><p>rgb-sandbox では自動デモと手動デモを試すことができるが、ここでは各手順の説明のため手動デモで行う。</p><p>いずれのデモも、macOS では一部の shell スクリプトが存在しない、オプションが異なる等の理由でデモが失敗する。<a href="https://github.com/nayutaco/rgb-sandbox">修正版</a>を作ったのそれで確認することができる。</p><h3>環境構築</h3><p>rgb-sandbox リポジトリのクローンを行う。</p><pre>$ git clone https://github.com/RGB-Tools/rgb-sandbox - recurse-submodules - shallow-submodules<br>$ cd rgb-sandbox</pre><p>ワーキングディレクトリを作成し、Docker コンテナで必要なサービスを開始する。２つのサービスが確認できる。</p><pre>$ mkdir data{0,1,core,index}<br>$ docker compose up -d<br>$ docker compose ps<br>NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS<br>rgb-sandbox-bitcoind-1 registry.gitlab.com/hashbeam/docker/bitcoind:25.0 &quot;/usr/local/bin/star…&quot; bitcoind 5 minutes ago Up 5 minutes 8332–8333/tcp, 18332–18333/tcp, 18443–18444/tcp, 28332–28333/tcp<br>rgb-sandbox-electrs-1 registry.gitlab.com/hashbeam/docker/electrs:0.9.14 &quot;/usr/local/bin/star…&quot; electrs 5 minutes ago Up 5 minutes 24224/tcp, 0.0.0.0:50001-&gt;50001/tcp</pre><p>ひとつは bitcoind でこれから作成するテストネットワーク（regtest）を管理する。<a href="https://github.com/romanz/electrs">electrs</a> は Electrum Server というもので、アプリケーションが bitcoind にアクセスするのを便利にする。</p><p>2つの CLI ツールをインストールする。</p><pre>$ cargo install bdk-cli - version &quot;0.27.1&quot; - root &quot;./bdk-cli&quot; - features electrum - locked<br>$ cargo install rgb-contracts - version &quot;0.10.0-rc.5&quot; - root &quot;./rgb-contracts&quot; - all-features - locked</pre><p>bdk-cli で <a href="https://github.com/bitcoindevkit">BDK</a> を使ってBitcoin ウォレットを操作し、rgb-contracts で RGB 機能を操作する。</p><h3>初期設定</h3><p>CLI 呼び出しを容易にするためにエイリアスを設定する。</p><pre>$ alias bcli=&quot;docker compose exec -u blits bitcoind bitcoin-cli -regtest&quot;<br>$ alias bdk=&quot;bdk-cli/bin/bdk-cli&quot;<br>$ alias rgb0=&quot;rgb-contracts/bin/rgb -n regtest -d data0&quot;<br>$ alias rgb1=&quot;rgb-contracts/bin/rgb -n regtest -d data1&quot;</pre><p>それぞれ、以下を行うためのエイリアスである。</p><ul><li>bcli: bitcoind を操作</li><li>bdk: bdk-cli で BDK を操作</li><li>rgb0: アセットの issuer/sender が、rgb を操作</li><li>rgb1: アセットの receiver が、rgb を操作</li></ul><p>いくつかの環境変数を設定する。</p><pre>$ CLOSING_METHOD=&quot;opret1st&quot;<br>$ DERIVE_PATH=&quot;m/86&#39;/1&#39;/0&#39;/9&quot;<br>$ DESC_TYPE=&quot;wpkh&quot;<br>$ ELECTRUM=&quot;localhost:50001&quot;<br>$ ELECTRUM_DOCKER=&quot;electrs:50001&quot;<br>$ CONSIGNMENT=&quot;consignment.rgb&quot;<br>$ PSBT=&quot;tx.psbt&quot;<br>$ IFACE=&quot;RGB20&quot;</pre><h3>Bitcoin ウォレットの準備</h3><p>まず Bitcoin のマイナー用の Bitcoin ウォレットを bitcond に用意し、ブロックを生成して残高を増やしておく。</p><pre>$ bcli createwallet miner<br>bcli -generate 103{<br>&quot;name&quot;: &quot;miner&quot;<br>}<br>$ bcli -generate 103<br>{<br>&quot;address&quot;: &quot;bcrt1qt8z7y9sycmzwp3w8fv4jrqhw8gytamd35yak6r&quot;,<br>&quot;blocks&quot;: [<br>&quot;342d3a9a092ea9a6db7d36428259442e53a58b12dd307a3fb44abb86fac3bfdc&quot;,<br>&quot;1b8376f0e7fe18b55401901a51f938b8b1e92a840b578f6137a660e95dee8bd4&quot;,<br>&quot;580e76c9015bbc59382f6b403c07677a1266ff62d2c6b732fa794a43fa9e2f3d&quot;,<br>…<br>&quot;4162515dd5e9d225785d0f4cc1b97e9aabb4d0fc17efc2518a677479e93a4821&quot;<br>]<br>}</pre><p>次に BDK を使用して、アセットの issuer/sender（同一である）および receiver 用に Bitcoin ウォレットを生成する。それぞれ以下を生成する</p><ul><li>マスター鍵ペア</li><li>マスター鍵から派生した鍵ペア（派生パスは DERIVE_PATH で定義）</li><li>派生した鍵ペアから生成した Bitcoin アドレス</li></ul><p>BDK のデフォルトのワーキングディレクトリを削除しておく必要がある。</p><pre>$ rm -fr ~/.bdk-bitcoin/{issuer,receiver}</pre><p>issuer/sender 用のマスター鍵ペア、マスター鍵から派生した鍵ペアの生成。</p><pre>$ bdk key generate<br>{<br>&quot;fingerprint&quot;: &quot;f0691809&quot;,<br>&quot;mnemonic&quot;: &quot;picnic mirror short notice engage minor lizard task noble behind history thrive coconut stable dismiss text layer ski frown fog chaos regular beef convince&quot;,<br>&quot;xprv&quot;: &quot;tprv8ZgxMBicQKsPdEdsR3deDJyGA1Pc34zMu9HRCfWuY42ooQCiYn24H1jJCk7wsxgxW6nDPVmfFmTw6DU4BdFXpLcnUaZ4x4GiipXbMzCCCDJ&quot;<br>}<br>$ xprv_0=&quot;tprv8ZgxMBicQKsPdEdsR3deDJyGA1Pc34zMu9HRCfWuY42ooQCiYn24H1jJCk7wsxgxW6nDPVmfFmTw6DU4BdFXpLcnUaZ4x4GiipXbMzCCCDJ&quot;<br>$ bdk key derive -p &quot;$DERIVE_PATH&quot; -x &quot;$xprv_0&quot;<br>{<br>&quot;xprv&quot;: &quot;[f0691809/86&#39;/1&#39;/0&#39;/9]tprv8hmhsMtPRFTzCcA9qxqKzHrVFxjC64daRL2ThdUhgEo6UQatVSeBuEnoNqqRAB7JZYj4S5qcUnUf1S1o26nrvQeevRPQ1Dqm255T9pTMXzi/*&quot;,<br>&quot;xpub&quot;: &quot;[f0691809/86&#39;/1&#39;/0&#39;/9]tpubDETk1mvdZd9f65BwjcVvPhWbpzF8FPpUzddEz9X16WbVJtqf7qTn5jQfYyUGCQUD7u1cUpwXqpX4bADA5NLvk7xBzjyRVBsNUbYmtJZaDfK/*&quot;<br>}<br>$ xprv_der_0=&quot;[f0691809/86&#39;/1&#39;/0&#39;/9]tprv8hmhsMtPRFTzCcA9qxqKzHrVFxjC64daRL2ThdUhgEo6UQatVSeBuEnoNqqRAB7JZYj4S5qcUnUf1S1o26nrvQeevRPQ1Dqm255T9pTMXzi/*&quot;<br>$ xpub_der_0=&quot;[f0691809/86&#39;/1&#39;/0&#39;/9]tpubDETk1mvdZd9f65BwjcVvPhWbpzF8FPpUzddEz9X16WbVJtqf7qTn5jQfYyUGCQUD7u1cUpwXqpX4bADA5NLvk7xBzjyRVBsNUbYmtJZaDfK/*&quot;</pre><p>同様に、receiver 用のマスター鍵ペア、マスター鍵から派生した鍵ペアの生成。</p><pre>$ bdk key generate<br>{<br>&quot;fingerprint&quot;: &quot;0dd6a3dc&quot;,<br>&quot;mnemonic&quot;: &quot;sorry express prevent need result cruel fine coconut half hollow service good work aunt suit honey blur buddy danger scrap way crystal wall riot&quot;,<br>&quot;xprv&quot;: &quot;tprv8ZgxMBicQKsPd3Hz9Phd6ixMxWa1jWfpmPGPWx2YmvZAgn8at2UJiLzLwHf73ps7TUHcUQcfBMNvxUp5bEMfSMC8zN6MRKGTsAJxrhLFzcn&quot;<br>}<br>$ xprv_1=&quot;tprv8ZgxMBicQKsPd3Hz9Phd6ixMxWa1jWfpmPGPWx2YmvZAgn8at2UJiLzLwHf73ps7TUHcUQcfBMNvxUp5bEMfSMC8zN6MRKGTsAJxrhLFzcn&quot;<br>$ bdk key derive -p &quot;$DERIVE_PATH&quot; -x &quot;$xprv_1&quot;<br>{<br>&quot;xprv&quot;: &quot;[0dd6a3dc/86&#39;/1&#39;/0&#39;/9]tprv8iHVDsqD9jD6TRePGGB8VFC9vHMp2Q1WYApj8NzgZb2tGRSrzqBjE241WvkKti9YT5fwt5LZZ6f4df5f4LdNnbzLfbYhEEn8VSaQ7rJoeb1/*&quot;,<br>&quot;xpub&quot;: &quot;[0dd6a3dc/86&#39;/1&#39;/0&#39;/9]tpubDEyXNHsTJ6tmLtgB9uqiterGVJskBjCR7URWQu2yyrqH6uhddE1KQWfsh4gYG2f5LP51LopLsaEyZ5e44UAtmMBTo3gioQjtRRqA5w3HVZN/*&quot;<br>}<br>$ xprv_der_1=&quot;[0dd6a3dc/86&#39;/1&#39;/0&#39;/9]tprv8iHVDsqD9jD6TRePGGB8VFC9vHMp2Q1WYApj8NzgZb2tGRSrzqBjE241WvkKti9YT5fwt5LZZ6f4df5f4LdNnbzLfbYhEEn8VSaQ7rJoeb1/*&quot;<br>$ xpub_der_1=&quot;[0dd6a3dc/86&#39;/1&#39;/0&#39;/9]tpubDEyXNHsTJ6tmLtgB9uqiterGVJskBjCR7URWQu2yyrqH6uhddE1KQWfsh4gYG2f5LP51LopLsaEyZ5e44UAtmMBTo3gioQjtRRqA5w3HVZN/*&quot;</pre><p>issuer/sender 用のウォレットにアセット発行用、およびアセットのお釣り受信用のための Bitcoin アドレスをそれぞれ生成する。</p><pre>$ bdk -n regtest wallet -w issuer -d &quot;$DESC_TYPE($xpub_der_0)&quot; get_new_address<br>{<br>&quot;address&quot;: &quot;bcrt1q4sfcr4llr9rrxsx53czx8kn7tsqs2lp85rmjj6&quot;<br>}<br>$ addr_issue=&quot;bcrt1q4sfcr4llr9rrxsx53czx8kn7tsqs2lp85rmjj6&quot;<br>$ bdk -n regtest wallet -w issuer -d &quot;$DESC_TYPE($xpub_der_0)&quot; get_new_address<br>{<br>&quot;address&quot;: &quot;bcrt1qndrr80z5d7v0p490nstszz7fxc0dlrx6yw6tvk&quot;<br>}<br>$ addr_change=&quot;bcrt1qndrr80z5d7v0p490nstszz7fxc0dlrx6yw6tvk&quot;</pre><p>receiver 用のウォレットにアセット受信用のための Bitcoin アドレスを生成する。</p><pre>$ bdk -n regtest wallet -w receiver -d &quot;$DESC_TYPE($xpub_der_1)&quot; get_new_address<br>{<br>&quot;address&quot;: &quot;bcrt1qstx6x794yxc9uny75hawjf5yflplgc6nyaslv5&quot;<br>}<br>$ addr_receive=&quot;bcrt1qstx6x794yxc9uny75hawjf5yflplgc6nyaslv5&quot;</pre><h3>Bitcoin ウォレットに Bitcoin を入金する</h3><p>issuer/sender のアセット発行用アドレス（addr_issue）と、receiver のアセット受信用アドレス（addr_receive）にマイナーから 1 BTC 送信しておく。送信を確定するために１ブロック生成する。</p><pre>$ bcli -rpcwallet=miner sendtoaddress &quot;$addr_issue&quot; 1<br>a03cc554e75471a10c31036136a2457d6f1678eddf0fd8d83cd6a81621bd958b<br>$ bcli -rpcwallet=miner sendtoaddress &quot;$addr_receive&quot; 1<br>9bab29bcb95fb96ecd56126f04d1ae2b0af120c3fbcc937c463fc7e0e544aa81<br>$ bcli -rpcwallet=miner -generate 1<br>{<br>&quot;address&quot;: &quot;bcrt1qgkdws864e4h92exkccyj083pm2fe03ecz888a0&quot;,<br>&quot;blocks&quot;: [<br>&quot;392bda99afb0c7de1c6934359743960fb1c555fc835f1f84608c352f30494f79&quot;<br>]<br>}</pre><p>それぞれのウォレットの状態をブロックチェーン（bitcoind）と同期する。</p><pre>$ bdk -n regtest wallet -w issuer -d &quot;$DESC_TYPE($xpub_der_0)&quot; -s &quot;$ELECTRUM&quot; sync<br>{}<br>$ bdk -n regtest wallet -w receiver -d &quot;$DESC_TYPE($xpub_der_1)&quot; -s &quot;$ELECTRUM&quot; sync<br>{}</pre><p>それぞれのトランザクションの新たな UTXO（outpoint）を環境変数に設定しておく。</p><pre>$ bdk -n regtest wallet -w issuer -d &quot;$DESC_TYPE($xpub_der_0)&quot; list_unspent<br>[<br>{<br>&quot;is_spent&quot;: false,<br>&quot;keychain&quot;: &quot;External&quot;,<br>&quot;outpoint&quot;: &quot;a03cc554e75471a10c31036136a2457d6f1678eddf0fd8d83cd6a81621bd958b:0&quot;,<br>&quot;txout&quot;: {<br>&quot;script_pubkey&quot;: &quot;0014ac1381d7ff19463340d48e0463da7e5c01057c27&quot;,<br>&quot;value&quot;: 100000000<br>}<br>}<br>]<br>$ outpoint_issue=&quot;0014ac1381d7ff19463340d48e0463da7e5c01057c27&quot;<br>$ bdk -n regtest wallet -w receiver -d &quot;$DESC_TYPE($xpub_der_1)&quot; list_unspent<br>[<br>{<br>&quot;is_spent&quot;: false,<br>&quot;keychain&quot;: &quot;External&quot;,<br>&quot;outpoint&quot;: &quot;9bab29bcb95fb96ecd56126f04d1ae2b0af120c3fbcc937c463fc7e0e544aa81:0&quot;,<br>&quot;txout&quot;: {<br>&quot;script_pubkey&quot;: &quot;001482cda378b521b05e4c9ea5fae926844fc3f46353&quot;,<br>&quot;value&quot;: 100000000<br>}<br>}<br>]<br>$ outpoint_receive=&quot;9bab29bcb95fb96ecd56126f04d1ae2b0af120c3fbcc937c463fc7e0e544aa81:0&quot;</pre><h4>なぜアセットの受信側に Bitcoin が必要か？</h4><p>なぜ事前に各アドレスに Bitcoin を入金したのか？</p><p>アセットの発行、送信を行う側（issuer/sender）は、その状態をブロックに書き込むためにBitcoin トランザクションを生成する必要があり、Bitcoin を持っておく必要があるのは理解できるであろう。それではアセットの受信側（receiver）はなぜ事前に Bitcoin を持っておく必要があるのか？</p><p>RGB の従う <a href="https://docs.rgb.info/v/jp/dezain#bittokoinbsuno-single-use-seals">Single-use seals</a> のコンセプトでは、アセットを送信する場合、受信側の Bitcoin UTXO が指定される必要がある。実際にはこの UTXO はプライバシーのため送信側には暗号学的に隠蔽されて渡されるが。この UTXO を消費することができる主体のみが受信したアセットを再送信できる。</p><h3>RGB クライアントの設定</h3><p>RGB クライアントをセットアップし、RGB20 のスキーマをインポートする。</p><p>issuer/sender 側。</p><pre>$ rgb0 import rgb-schemata/schemata/NonInflatableAssets.rgb<br>Stock file not found, creating default stock<br>Wallet file not found, creating new wallet list<br>Schema urn:lnp-bp:sc:BEiLYE-am9WhTW1-oK8cpvw4-FEMtzMrf-mKocuGZn-qWK6YF#ginger-parking-nirvana imported to the stash<br>$ rgb0 import rgb-schemata/schemata/NonInflatableAssets-RGB20.rgb<br>Implementation urn:lnp-bp:im:9EUGHC-wpuiyrQE-NdPBVyiv-VX4sVRBs-9yKfteug-HtqnGb#titanic-easy-citizen of interface urn:lnp-bp:if:48hc4i-m9JRcYQA-uUSzwFCK-VNEa9eZf-nhepU8QJ-pqosXS#laptop-domingo-cool for schema urn:lnp-bp:sc:BEiLYE-am9WhTW1-oK8cpvw4-FEMtzMrf-mKocuGZn-qWK6YF#ginger-parking-nirvana imported to the stash</pre><p>receiver 側。</p><pre>$ rgb1 import rgb-schemata/schemata/NonInflatableAssets.rgb<br>Stock file not found, creating default stock<br>Wallet file not found, creating new wallet list<br>Schema urn:lnp-bp:sc:BEiLYE-am9WhTW1-oK8cpvw4-FEMtzMrf-mKocuGZn-qWK6YF#ginger-parking-nirvana imported to the stash<br>$ rgb1 import rgb-schemata/schemata/NonInflatableAssets-RGB20.rgb<br>Implementation urn:lnp-bp:im:9EUGHC-wpuiyrQE-NdPBVyiv-VX4sVRBs-9yKfteug-HtqnGb#titanic-easy-citizen of interface urn:lnp-bp:if:48hc4i-m9JRcYQA-uUSzwFCK-VNEa9eZf-nhepU8QJ-pqosXS#laptop-domingo-cool for schema urn:lnp-bp:sc:BEiLYE-am9WhTW1-oK8cpvw4-FEMtzMrf-mKocuGZn-qWK6YF#ginger-parking-nirvana imported to the stash</pre><p>スキーマ ID を取得し、それを環境変数に設定しておく。</p><pre>$ rgb0 schemata<br>urn:lnp-bp:sc:BEiLYE-am9WhTW1-oK8cpvw4-FEMtzMrf-mKocuGZn-qWK6YF#ginger-parking-nirvana RGB20<br>$ schema=&quot;urn:lnp-bp:sc:BEiLYE-am9WhTW1-oK8cpvw4-FEMtzMrf-mKocuGZn-qWK6YF#ginger-parking-nirvana&quot;</pre><h3>アセットの発行</h3><p>まずコントラクト定義ファイルを用意する。</p><pre>sed \<br>-e &quot;s/issued_supply/1000/&quot; \<br>-e &quot;s/created_timestamp/$(date +%s)/&quot; \<br>-e &quot;s/closing_method/$CLOSING_METHOD/&quot; \<br>-e &quot;s/txid:vout/$outpoint_issue/&quot; \<br>contracts/usdt.yaml.template &gt; contracts/usdt.yaml</pre><p>アセットを 1000 発行し、コントラクト ID を環境変数に設定しておく。</p><pre>$ rgb0 issue &quot;$schema&quot; &quot;$IFACE&quot; contracts/usdt.yaml<br>A new contract rgb:BLtBXAT-QEwWBdT3y-EFDfYYgfc-jiGCaNXPS-YnoEtZduq-iYfgVa is issued and added to the stash.<br>Use `export` command to export the contract.<br>$ contract_id=&quot;rgb:BLtBXAT-QEwWBdT3y-EFDfYYgfc-jiGCaNXPS-YnoEtZduq-iYfgVa&quot;<br>$ rgb0 contracts<br>rgb:BLtBXAT-QEwWBdT3y-EFDfYYgfc-jiGCaNXPS-YnoEtZduq-iYfgVa<br>$ rgb0 state &quot;$contract_id&quot; &quot;$IFACE&quot;<br>Global:<br>spec := (naming=(ticker=(&quot;USDT&quot;), name=(&quot;USD Tether&quot;), details=~), precision=0)<br>data := (terms=(&quot;demo RGB20 asset&quot;), media=~)<br>issuedSupply := (1000)<br>created := (1705040430)<br>Owned:<br>assetOwner:<br>amount=1000, utxo=a03cc554e75471a10c31036136a2457d6f1678eddf0fd8d83cd6a81621bd958b:0, witness=~ # owner unknown</pre><h3>アセットの転送</h3><p>receiver がアセット 100 を受信するための請求書を生成する。請求書にはアセットを受信するための Bitcoin UTXO（outpoint_receive）が含まれていることに注意（ただし隠蔽されている）。</p><pre>$ rgb1 invoice &quot;$contract_id&quot; &quot;$IFACE&quot; 100 &quot;$CLOSING_METHOD:$outpoint_receive&quot;<br>rgb:BLtBXAT-QEwWBdT3y-EFDfYYgfc-jiGCaNXPS-YnoEtZduq-iYfgVa/RGB20/100+utxob:7QQCWe4-J4byQq6Yy-PMiKCESi8–36CvYt2Vw-XAyzPZdc8-dACwRz<br>$ invoice=&quot;rgb:BLtBXAT-QEwWBdT3y-EFDfYYgfc-jiGCaNXPS-YnoEtZduq-iYfgVa/RGB20/100+utxob:7QQCWe4-J4byQq6Yy-PMiKCESi8–36CvYt2Vw-XAyzPZdc8-dACwRz&quot;</pre><p>sender はアセットの転送を行う PSBT（Partially Signed Bitcoin Transaction）を作成し data0/$PSBT に保存する。PSBT はまだ完全な Bitcoin トランザクションではない。</p><pre>$ bdk -n regtest wallet -w issuer -d &quot;$DESC_TYPE($xpub_der_0)&quot; create_tx -f 5 - send_all - utxos &quot;$outpoint_issue&quot; - to &quot;$addr_change:0&quot; - add_string opret<br>{<br>&quot;details&quot;: {<br>&quot;confirmation_time&quot;: null,<br>&quot;fee&quot;: 630,<br>&quot;received&quot;: 99999370,<br>&quot;sent&quot;: 100000000,<br>&quot;transaction&quot;: null,<br>&quot;txid&quot;: &quot;fccb8d0ff55ad4850c980a00617b914c50c9230edd8ffa031baa7b10e7127dcc&quot;<br>},<br>&quot;psbt&quot;: &quot;cHNidP8BAGIBAAAAAYuVvSEWqNY82NgP3+14Fm99RaI2YQMxDKFxVOdUxTygAAAAAAD+////Aore9QUAAAAAFgAUm0YzvFRvmPDUr5wXAQvJNh7fjNoAAAAAAAAAAAdqBW9wcmV0aAAAAAABAN4CAAAAAAEBP82Zr/19Ae91dSZlsI4+QmPeX/PLOvlg1NIXPM/wjokAAAAAAP3///8CAOH1BQAAAAAWABSsE4HX/xlGM0DUjgRj2n5cAQV8J/wFECQBAAAAFgAUUmfLAke6lA9OeaITZGmmhJ8Le5cCRzBEAiBiqTAAwx0ssyWoca309OWG+uEIJzqHg38px59i+WArrQIgJcOFRmP5SFJMSexsh6PslUfCL56pK+rIE3YIXk9VyJsBIQI4cABOZChQYxszk5BYK0Wayn7TN7DcXytnijUxS9y/aGcAAAABAR8A4fUFAAAAABYAFKwTgdf/GUYzQNSOBGPaflwBBXwnIgYCZU5FdajH25AGZTP1cVeKu0VOfS2xeprkIl5D2LtihBEY8GkYCVYAAIABAACAAAAAgAkAAAAAAAAAACICA42LVQtVBvyt6mGCYi0bOfr6U4DAud5imvgvraYGI8I1GPBpGAlWAACAAQAAgAAAAIAJAAAAAQAAAAAA&quot;<br>}<br>$ echo &quot;cHNidP8BAGIBAAAAAYuVvSEWqNY82NgP3+14Fm99RaI2YQMxDKFxVOdUxTygAAAAAAD+////Aore9QUAAAAAFgAUm0YzvFRvmPDUr5wXAQvJNh7fjNoAAAAAAAAAAAdqBW9wcmV0aAAAAAABAN4CAAAAAAEBP82Zr/19Ae91dSZlsI4+QmPeX/PLOvlg1NIXPM/wjokAAAAAAP3///8CAOH1BQAAAAAWABSsE4HX/xlGM0DUjgRj2n5cAQV8J/wFECQBAAAAFgAUUmfLAke6lA9OeaITZGmmhJ8Le5cCRzBEAiBiqTAAwx0ssyWoca309OWG+uEIJzqHg38px59i+WArrQIgJcOFRmP5SFJMSexsh6PslUfCL56pK+rIE3YIXk9VyJsBIQI4cABOZChQYxszk5BYK0Wayn7TN7DcXytnijUxS9y/aGcAAAABAR8A4fUFAAAAABYAFKwTgdf/GUYzQNSOBGPaflwBBXwnIgYCZU5FdajH25AGZTP1cVeKu0VOfS2xeprkIl5D2LtihBEY8GkYCVYAAIABAACAAAAAgAkAAAAAAAAAACICA42LVQtVBvyt6mGCYi0bOfr6U4DAud5imvgvraYGI8I1GPBpGAlWAACAAQAAgAAAAIAJAAAAAQAAAAAA&quot; | base64 -d &gt; &quot;data0/$PSBT&quot;</pre><p>PSBT に commitment host （OP_RETURN commitment）を設定する。commitment host は RGB のデータが Bitcoin トランザクション出力にどのように埋め込まれているかを示す。</p><pre>$ rgb0 set-host - method &quot;$CLOSING_METHOD&quot; &quot;data0/$PSBT&quot;<br>PSBT file &#39;data0/tx.psbt&#39; is updated with opret1st host now set.</pre><p>PSBT と請求書を提供して転送を作成する（まだトランザクションはブロードキャストされていない）。これにより、consignment が生成される。Bitcoin トランザクション出力には RGB の状態遷移を表現する完全なデータが含まれるのではなく、その暗号学的ハッシュ値のみが含まれる。状態遷移を検証するためには別途 consignment が必要になる。以下の consignment.inspect をエディタで開くと consignment の内容を確認することができる。</p><pre>​​$ rgb0 transfer - method &quot;$CLOSING_METHOD&quot; &quot;data0/$PSBT&quot; &quot;$invoice&quot; &quot;data0/$CONSIGNMENT&quot;<br>Transfer is created and saved into &#39;data0/consignment.rgb&#39;.<br>PSBT file &#39;data0/tx.psbt&#39; is updated with all required commitments and ready to be signed.<br>Stash data are updated.<br>$ rgb0 inspect &quot;data0/$CONSIGNMENT&quot; &gt; consignment.inspect</pre><p>ピア間（sender、receiver）の consignment 受け渡しはここでは単純にファイルをコピーすることによって行うが実際のシナリオでは <a href="https://github.com/grunch/rgb-proxy-server">RGB proxy server</a> などを介して行う必要がある。</p><pre>​​$ cp data{0,1}/&quot;$CONSIGNMENT&quot;</pre><p>receiver は転送を検証することができる。しかしまだトランザクションはブロードキャストされていないのでマイニングされていない。</p><pre>$ rgb1 validate &quot;data1/$CONSIGNMENT&quot;<br>Consignment has non-mined terminal(s)<br>Non-mined terminals:<br>- dd16026a59d0158df88ff787c958df543ffb77661b2106c0fa09f5f645fd821d<br>Validation warnings:<br>- terminal witness transaction dd16026a59d0158df88ff787c958df543ffb77661b2106c0fa09f5f645fd821d is not yet mined.</pre><p>sender がトランザクションに署名してブロードキャストする。macOS では base64 コマンドがエラーになるのでオプションを -w0 から -i に変更する。</p><pre>$ bdk -n regtest wallet -w issuer -d &quot;$DESC_TYPE($xprv_der_0)&quot; sign - psbt $(base64 -w0 &quot;data0/$PSBT&quot;)<br>base64: invalid option - w<br>Usage: base64 [-Ddh] [-b num] [-i in_file] [-o out_file]<br>-b, - break break encoded string into num character lines<br>-Dd, - decode decodes input<br>-h, - help display this message<br>-i, - input input file (default: &quot;-&quot; for stdin)<br>-o, - output output file (default: &quot;-&quot; for stdout)<br>error: The argument &#39; - psbt &lt;BASE64_PSBT&gt;&#39; requires a value but none was supplied<br>For more information try - help<br>$ bdk -n regtest wallet -w issuer -d &quot;$DESC_TYPE($xprv_der_0)&quot; sign - psbt $(base64 -i &quot;data0/$PSBT&quot;)<br>{<br>&quot;is_finalized&quot;: true,<br>&quot;psbt&quot;: &quot;cHNidP8BAH0BAAAAAYuVvSEWqNY82NgP3+14Fm99RaI2YQMxDKFxVOdUxTygAAAAAAD+////Aore9QUAAAAAFgAUm0YzvFRvmPDUr5wXAQvJNh7fjNoAAAAAAAAAACJqIBbkFFUkewef0u8EFClQ6rW7x2KvBZ+I7r9yimSjG1lYaAAAACb8A1JHQgH9hiGkYJbzXZOwdqfwoeVDLjMlktZPn4FT3XalLitqYtYAABd8DlyFdl5XyeYyb3/Z725gn/sdxVvjUn1WP/tfWZfKECcAAAABF3wOXIV2XlfJ5jJvf9nvbmCf+x3FW+NSfVY/+19Zl8qgDwAAAAGgDwECAAIOijEYSJZt8SpkRhvsyXq7cITYkbMyHlkE8lnnVPNpCQhkAAAAAAAAAHPkFH6fJr0MzfiF4p7PcakvAveqkJhkC+iYeGrWVdeDAwAAAAAAAK2pAAtm3jBECIQDAAAAAAAAKOcnvKZoDro7JdraMQ9404QY+DJ868Ed9QRAHcpRi/YAAAEA3gIAAAAAAQE/zZmv/X0B73V1JmWwjj5CY95f88s6+WDU0hc8z/COiQAAAAAA/f///wIA4fUFAAAAABYAFKwTgdf/GUYzQNSOBGPaflwBBXwn/AUQJAEAAAAWABRSZ8sCR7qUD055ohNkaaaEnwt7lwJHMEQCIGKpMADDHSyzJahxrfT05Yb64QgnOoeDfynHn2L5YCutAiAlw4VGY/lIUkxJ7GyHo+yVR8Ivnqkr6sgTdgheT1XImwEhAjhwAE5kKFBjGzOTkFgrRZrKftM3sNxfK2eKNTFL3L9oZwAAAAEBHwDh9QUAAAAAFgAUrBOB1/8ZRjNA1I4EY9p+XAEFfCciBgJlTkV1qMfbkAZlM/VxV4q7RU59LbF6muQiXkPYu2KEERjwaRgJVgAAgAEAAIAAAACACQAAAAAAAAABBwABCGsCRzBEAiBPdeodx3IyxL/+3e8gKq+RwNXdyuGskHDwA7iMJ77zXgIgINpS4zVEc4IoH8WcnBCrQ5bS1l+qlRUjFKdYTPUPh6MBIQJlTkV1qMfbkAZlM/VxV4q7RU59LbF6muQiXkPYu2KEESb8A1JHQgMXfA5chXZeV8nmMm9/2e9uYJ/7HcVb41J9Vj/7X1mXyiD9hiGkYJbzXZOwdqfwoeVDLjMlktZPn4FT3XalLitqYgAiAgONi1ULVQb8rephgmItGzn6+lOAwLneYpr4L62mBiPCNRjwaRgJVgAAgAEAAIAAAACACQAAAAEAAAAAKfwGTE5QQlA0ABd8DlyFdl5XyeYyb3/Z725gn/sdxVvjUn1WP/tfWZfKIHBmA1AJa7+EzOGnG+0HCNHq/8KWSaZfdDC01tbFliplCfwGTE5QQlA0AQhrIAx8E2G5BAj8BU9QUkVUAAAI/AVPUFJFVAEgFuQUVSR7B5/S7wQUKVDqtbvHYq8Fn4juv3KKZKMbWVgA&quot;<br>}<br>$ bdk -n regtest wallet -w issuer -d &quot;$DESC_TYPE($xpub_der_0)&quot; -s &quot;$ELECTRUM&quot; broadcast - psbt &quot;$psbt_signed&quot;<br>{<br>&quot;txid&quot;: &quot;dd16026a59d0158df88ff787c958df543ffb77661b2106c0fa09f5f645fd821d&quot;<br>}</pre><h3>アセット転送の確認</h3><p>トランザクションを確定させるため１ブロック生成する。</p><pre>$ bcli -rpcwallet=miner -generate 1<br>{<br>&quot;address&quot;: &quot;bcrt1qywmx098pamjvl2wupl3ltyqnwglytsw9aw84q4&quot;,<br>&quot;blocks&quot;: [<br>&quot;33091aa9354eefe834a56b9bb0aaacee31f6b0f524818bb2423b5cf6228a43ec&quot;<br>]<br>}</pre><p>receiver はアセットの転送を受け入れる。consignment が検証され、receiver のoutpoint_receive（”9bab29bcb95fb96ecd56126f04d1ae2b0af120c3fbcc937c463fc7e0e544aa81:0&quot;）にアセットが 100 含まれることが確認できる。</p><pre>$ rgb1 accept &quot;data1/$CONSIGNMENT&quot;<br>Consignment is valid<br>Transfer accepted into the stash<br>$ rgb1 state &quot;$contract_id&quot; &quot;$IFACE&quot;<br>Global:<br>spec := (naming=(ticker=(&quot;USDT&quot;), name=(&quot;USD Tether&quot;), details=~), precision=0)<br>data := (terms=(&quot;demo RGB20 asset&quot;), media=~)<br>issuedSupply := (1000)<br>created := (1705040430)<br>Owned:<br>assetOwner:<br>amount=1000, utxo=a03cc554e75471a10c31036136a2457d6f1678eddf0fd8d83cd6a81621bd958b:0, witness=~ # owner unknown<br>amount=100, utxo=9bab29bcb95fb96ecd56126f04d1ae2b0af120c3fbcc937c463fc7e0e544aa81:0, witness=dd16026a59d0158df88ff787c958df543ffb77661b2106c0fa09f5f645fd821d # owner unknown<br>amount=900, utxo=dd16026a59d0158df88ff787c958df543ffb77661b2106c0fa09f5f645fd821d:0, witness=dd16026a59d0158df88ff787c958df543ffb77661b2106c0fa09f5f645fd821d # owner unknown</pre><p>sender 側では転送トランザクションの新しい出力（”dd16026a59d0158df88ff787c958df543ffb77661b2106c0fa09f5f645fd821d:0”）にお釣りのアセットが 900 含まれることがわかる。sender 側の表示では送信した 100 は含まれない。receiver 側の outpoint_receive は隠蔽されて渡されるため、sender は送信先の情報を見ることができない。</p><pre>$ rgb0 state &quot;$contract_id&quot; &quot;$IFACE&quot;<br>Global:<br>spec := (naming=(ticker=(&quot;USDT&quot;), name=(&quot;USD Tether&quot;), details=~), precision=0)<br>data := (terms=(&quot;demo RGB20 asset&quot;), media=~)<br>issuedSupply := (1000)<br>created := (1705040430)<br>Owned:<br>assetOwner:<br>amount=1000, utxo=a03cc554e75471a10c31036136a2457d6f1678eddf0fd8d83cd6a81621bd958b:0, witness=~ # owner unknown<br>amount=900, utxo=dd16026a59d0158df88ff787c958df543ffb77661b2106c0fa09f5f645fd821d:0, witness=dd16026a59d0158df88ff787c958df543ffb77661b2106c0fa09f5f645fd821d # owner unknown</pre><h3>環境の削除</h3><p>最後に、サービスを終了しワーキングディレクトリを削除する。</p><pre>$ docker compose down<br>$ rm -fr data{0,1,core,index}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=061b040a49d2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nayuta-engineering-blog-ja/rgb-protocol-%E3%81%A7%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%82%92%E7%99%BA%E8%A1%8C%E3%81%97%E8%BB%A2%E9%80%81%E3%81%99%E3%82%8B-061b040a49d2">RGB Protocol でアセットを発行し転送する</a> was originally published in <a href="https://medium.com/nayuta-engineering-blog-ja">Nayuta エンジニアブログ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Taproot Assets Protocol #2]]></title>
            <link>https://medium.com/nayuta-engineering-blog-en/understanding-taproot-assets-protocol-2-2abd51d37765?source=rss-ec449712cbf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/2abd51d37765</guid>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[taro]]></category>
            <category><![CDATA[lightning-network]]></category>
            <category><![CDATA[taproot-assets-protocol]]></category>
            <category><![CDATA[taproot]]></category>
            <dc:creator><![CDATA[Hiroki Gondo]]></dc:creator>
            <pubDate>Mon, 10 Jul 2023 03:56:50 GMT</pubDate>
            <atom:updated>2023-07-14T03:03:07.955Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*wIkHm1nqJSeiI6Ukd4jgKQ.jpeg" /></figure><p>In <a href="https://medium.com/nayuta-en/understanding-taproot-assets-protocol-e2dfe3fc1e07">a previous article</a>, the Taproot Assets Protocol (TAP) specifications were explained. This article aims to deepen understanding of the specifications by running the Taproot Assets Protocol Daemon (<a href="https://github.com/lightninglabs/taproot-assets#initialization">tapd</a>) developed by Lightning Labs.</p><p>The steps are the same as those on the <a href="https://github.com/lightninglabs/taproot-assets#initialization">GitHub</a> front page of the tapd but with more detailed explanations and notes.</p><h3>1. Run lnd</h3><p>To run tapd, we need Lightning Network Daemon (lnd). tapd accesses Bitcoin Layer 1 via lnd *. Here we use Bitcoin’s testnet.</p><p>* Lightning Network (Layer 2) functionality for lnd is not required here, but Lightning Network support for TAP would be one of the most important milestones.</p><p>My test environment is as follows.</p><pre>$ sw_vers<br>ProductName:  macOS<br>ProductVersion:  13.2.1<br>BuildVersion:  22D68<br>$ go version<br>go version go1.20.3 darwin/amd64</pre><p>Install and run lnd.</p><pre>$ git clone https://github.com/lightningnetwork/lnd.git<br>$ cd lnd<br>$ git log | head -1<br>commit 8c58730c34022cd9f3c8c7c408c0783a751f2404<br>$ make install tags=&quot;signrpc walletrpc chainrpc invoicesrpc&quot;<br>$ lnd -V<br>lnd version 0.16.99-beta commit=v0.16.0-beta-332-g8c58730c3<br>$ lnd --bitcoin.active --bitcoin.testnet --bitcoin.node=neutrino</pre><p>Create a wallet with a dedicated command line tool (lncli) from another terminal.</p><pre>$ lncli -network=testnet create<br>Input wallet password: <br>Confirm password: <br><br>Do you have an existing cipher seed mnemonic or extended master root key you want to use?<br>Enter &#39;y&#39; to use an existing cipher seed mnemonic, &#39;x&#39; to use an extended master root key <br>or &#39;n&#39; to create a new seed (Enter y/x/n): n<br><br>Your cipher seed can optionally be encrypted.<br>Input your passphrase if you wish to encrypt it (or press enter to proceed without a cipher seed passphrase): <br><br>Generating fresh cipher seed...<br><br>…<br><br>lnd successfully initialized!</pre><p>The wallet must be unlocked to access lnd from outside (from tapd). Immediately after the wallet is created, the wallet is unlocked, but if lnd is rebooted, the wallet must be unlocked by a command.</p><pre>$ lncli --network=testnet unlock<br>Input wallet password: <br>lnd successfully unlocked!</pre><p>Wait until the state becomes SERVER_ACTIVE, as it takes a while to synchronize the chain. Now lnd is ready.</p><pre>$ lncli state<br>{<br>    &quot;state&quot;: &quot;RPC_ACTIVE&quot;<br>}<br><br>…<br><br><br>$ lncli state<br>{<br>    &quot;state&quot;: &quot;SERVER_ACTIVE&quot;<br>}<br>$ lncli --network=testnet getinfo<br>{<br>    …<br>    &quot;block_height&quot;: 2431595,<br>    …<br>    &quot;synced_to_chain&quot;: true,</pre><h3>2. Run tapd</h3><p>Install and run tapd.</p><pre>$ git clone https://github.com/lightninglabs/taproot-assets.git<br>$ cd taproot-assets<br>$ git log | head -1<br>commit 1a3f86c09ac044ff3b9e27cf90a314eecb2e0625<br>$ make install<br>$ tapd --network=testnet</pre><h3>3. Create Asset</h3><p>Create assets with a dedicated command line tool (tapcli) from another terminal.</p><pre>$ tapcli assets mint --type normal --name fantasycoin --supply 100 --meta_bytes &quot;fantastic money&quot;<br>{<br>    &quot;batch_key&quot;: &quot;0326764481f0945fea8cc696a52753d30409026d7dfd5652beb4904dfc44c238d1&quot;<br>}<br>$ tapcli assets mint finalize<br>{<br>    &quot;batch_key&quot;: &quot;0326764481f0945fea8cc696a52753d30409026d7dfd5652beb4904dfc44c238d1&quot;<br>}</pre><p>Error in tapd ;(</p><pre>2023-05-23 17:39:55.398 [ERR] GRDN: unable to advance state machine: unable to advance state machine: unable to fund psbt: unable to fund psbt: rpc error: code = Unknown desc = wallet couldn&#39;t fund PSBT: error creating funding TX: insufficient funds available to construct transaction</pre><p>To create the asset, a lower-tier Bitcoin transaction must be issued. This requires a certain amount of Bitcoin (UTXO) in the wallet.</p><p>Issue an address in lnd and deposit Bitcoin from “somewhere” in “sufficient amount”.</p><pre>$ lncli -network=testnet newaddress p2tr<br>{<br>    &quot;address&quot;:  &quot;tb1pvs0jjwxal4deezmvc0zk7w89n3d44m6f4a3fn3xfxne7as7a9qhq86gj0v&quot;<br>}</pre><p>Bitcoin (Testnet) can be free from a faucet such as Bitcoin Testnet Faucet. To issue a Bitcoin transaction containing an asset requires (in the current tapd implementation) an output of 1000 sats, but the transaction fee maybe 10 times that or more.</p><pre>$ lncli -network=testnet walletbalance<br>{<br>    &quot;total_balance&quot;:  &quot;100000&quot;,<br>    ...<br>}</pre><p>This balance would be enough, but collecting this much is a little hard. tapd also supports simnet (signet), so you may consider using that.</p><p>Reboot tapd, and the asset appears in the list (not yet created).</p><pre>$ tapcli assets list<br>{<br>    &quot;assets&quot;: [<br>        {<br>            &quot;version&quot;: 0,<br>            &quot;asset_genesis&quot;: {<br>                &quot;genesis_point&quot;: &quot;ba779153a792a1d49433fd18e56311f8d212992e7d1405cb14af8dffb34e88ce:0&quot;,<br>                &quot;name&quot;: &quot;fantasycoin&quot;,<br>                &quot;meta_hash&quot;: &quot;04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43&quot;,<br>                &quot;asset_id&quot;: &quot;20cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874&quot;,<br>                &quot;output_index&quot;: 0,<br>                &quot;version&quot;: 0<br>            },<br>            &quot;asset_type&quot;: &quot;NORMAL&quot;,<br>            &quot;amount&quot;: &quot;100&quot;,<br>            &quot;lock_time&quot;: 0,<br>            &quot;relative_lock_time&quot;: 0,<br>            &quot;script_version&quot;: 0,<br>            &quot;script_key&quot;: &quot;02b4c71447e74672f8cd5b50a6b430fc73b3caff7866dc905a502fe8adefad3b31&quot;,<br>            &quot;script_key_is_local&quot;: true,<br>            &quot;asset_group&quot;: null,<br>            &quot;chain_anchor&quot;: {<br>                &quot;anchor_tx&quot;: &quot;02000000000101ce884eb3ff8daf14cb05147d2e9912d2f81163e518fd3394d4a192a7539177ba0000000000ffffffff02e8030000000000002251203ad594d71881fe6b0e35d2e6e40dd9ee67eac616ee38e65aff7fe7e7283af03372640100000000002251206e83207da3b36b5f8e84a55171e2ac6f21d12c5eb0384a157a9bf927fd88bc6401409722a654cd08582fe39fcbe52be917b2bcdf281ad5244bf058562cea07155a7e75ee68dc4be21842296392c22cc7580a6e118d9b38944014667e69455efe10f200000000&quot;,<br>                &quot;anchor_txid&quot;: &quot;ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356&quot;,<br>                &quot;anchor_block_hash&quot;: &quot;0000000000000000000000000000000000000000000000000000000000000000&quot;,<br>                &quot;anchor_outpoint&quot;: &quot;ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356:0&quot;,<br>                &quot;internal_key&quot;: &quot;03d9f42daae1b7832d77d3ec83ddbb62e71266f6aedf6bcceb944e9672177c9301&quot;,<br>                &quot;merkle_root&quot;: &quot;634ff6d86b8889f119f505a9bcba38fe4c6bda4b5a40a439fce37184badff63f&quot;,<br>                &quot;tapscript_sibling&quot;: null<br>            },<br>            &quot;prev_witnesses&quot;: [<br>            ],<br>            &quot;is_spent&quot;: false<br>        }<br>    ]<br>}</pre><p>You will understand most of the elements displayed here if you understand the specs.</p><p>Bitcoin UTXO (<a href="https://mempool.space/testnet/tx/ba779153a792a1d49433fd18e56311f8d212992e7d1405cb14af8dffb34e88ce">ba779153a792a1d49433fd18e56311f8d212992e7d1405cb14af8dffb34e88ce</a>:0) spent in this asset creation is the genesis_point to identify the asset uniquely.</p><p>The new Bitcoin UTXO (anchor_outpoint) of the new Bitcoin transaction (<br><a href="https://mempool.space/testnet/tx/ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356">ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356</a>) that spends this transaction contains the created asset.</p><p>The asset creation is complete when this new transaction is confirmed on the chain.</p><h3>4. Transfer Asset</h3><p>This time, both sender and receiver use the same lnd / tapd so that you will send it to yourself.</p><p>If assets are sent to different tapd, the recipient must first synchronize the sender’s asset creation information using tapcli universe sync.</p><p>Create an address to receive 21 units by specifying the asset_id contained in the result of the tapcli asset list described earlier.</p><pre>$ tapcli addrs new --asset_id 20cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874 --amt 21<br>{<br>    &quot;encoded&quot;: &quot;taptb1qqqsqq3qyr8vmdnzvuzm7f4dqdsgfa6zxzpdkcg57r0ggprwhuhgfa599p6qgggzy56hls2gc3qlh4w9affnl4krx6rxj7t8588ccjfk9pug556lgv7qvggr8epd00wrc5tpctwygpn8kr60efxy5lfj6yl04sf2wxv5v5dsfr8qsqg4nd4u85&quot;,<br>    &quot;asset_id&quot;: &quot;20cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874&quot;,<br>    &quot;asset_type&quot;: &quot;NORMAL&quot;,<br>    &quot;amount&quot;: &quot;21&quot;,<br>    &quot;group_key&quot;: null,<br>    &quot;script_key&quot;: &quot;0225357fc148c441fbd5c5ea533fd6c33686697967a1cf8c493628788a535f433c&quot;,<br>    &quot;internal_key&quot;: &quot;033e42d7bdc3c5161c2dc440667b0f4fca4c4a7d32d13efac12a71994651b048ce&quot;,<br>    &quot;tapscript_sibling&quot;: null,<br>    &quot;taproot_output_key&quot;: &quot;be0db94139918a132eb4821f834efdec4634261997b57d964753d60923be9dee&quot;<br>}</pre><p>Send the asset to the address.</p><pre>$ tapcli assets send --addr taptb1qqqsqq3qyr8vmdnzvuzm7f4dqdsgfa6zxzpdkcg57r0ggprwhuhgfa599p6qgggzy56hls2gc3qlh4w9affnl4krx6rxj7t8588ccjfk9pug556lgv7qvggr8epd00wrc5tpctwygpn8kr60efxy5lfj6yl04sf2wxv5v5dsfr8qsqg4nd4u85<br>{<br>    &quot;transfer&quot;: {<br>        &quot;transfer_timestamp&quot;: &quot;1684836471&quot;,<br>        &quot;anchor_tx_hash&quot;: &quot;e4efa1c3272009193e961f383b29c1bc84cf6ed8eb0806bf94056a41387835b3&quot;,<br>        &quot;anchor_tx_height_hint&quot;: 2434958,<br>        &quot;anchor_tx_chain_fees&quot;: &quot;12725&quot;,<br>        &quot;inputs&quot;: [<br>            {<br>                &quot;anchor_point&quot;: &quot;ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356:0&quot;,<br>                &quot;asset_id&quot;: &quot;20cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874&quot;,<br>                &quot;script_key&quot;: &quot;02b4c71447e74672f8cd5b50a6b430fc73b3caff7866dc905a502fe8adefad3b31&quot;,<br>                &quot;amount&quot;: &quot;100&quot;<br>            }<br>        ],<br>        &quot;outputs&quot;: [<br>            {<br>                &quot;anchor&quot;: {<br>                    &quot;outpoint&quot;: &quot;b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4:0&quot;,<br>                    &quot;value&quot;: &quot;1000&quot;,<br>                    &quot;internal_key&quot;: &quot;024a3cb06616bb1545d3a25417a3fa5ccc70c5fbe9ceed8666410ed83745bbe968&quot;,<br>                    &quot;taproot_asset_root&quot;: &quot;42ac8c2338032a0b0ea9b96916da31a8798eef30cbef2a80b8c6d60249e4698d&quot;,<br>                    &quot;merkle_root&quot;: &quot;42ac8c2338032a0b0ea9b96916da31a8798eef30cbef2a80b8c6d60249e4698d&quot;,<br>                    &quot;tapscript_sibling&quot;: null,<br>                    &quot;num_passive_assets&quot;: 0<br>                },<br>                &quot;script_key&quot;: &quot;02258420ed4cf219965908102c6f8498da274c251a3463880763ba118c2d946c62&quot;,<br>                &quot;script_key_is_local&quot;: true,<br>                &quot;amount&quot;: &quot;79&quot;,<br>                &quot;new_proof_blob&quot;: &quot;00245663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb000000000150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096e88000000000000000002fd0163020000000001025663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb0100000000ffffffff5663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb00000000000000000003e803000000000000225120f036a7c3d36d4459fc4566875b255b80177fee26ea8cb27a1387e38dedee46f8e803000000000000225120be0db94139918a132eb4821f834efdec4634261997b57d964753d60923be9deed52e010000000000225120a0330b1c1bec571ac4e9004cae724380b3acf96a2f88332f4d6bd7136518932c0140db4f7d819f7fe90677c6e0d8355fe2b41f123934a5fb34117377841d3f1f305a82fbe7feea5fb51c2b8f598934027f455fb5d5f12ec6ba5b4538ef8cead916d801407fa2c953e2cbfd8ab9813b06f11919bfc3fba51ef9bac960ae522f9ea2b2f3acfd976dcc31bb49b9c4dc906952ddf7b79c7467a0c1f22ed1d845794adbe558e50000000003010004fd01600001000155ce884eb3ff8daf14cb05147d2e9912d2f81163e518fd3394d4a192a7539177ba000000000b66616e74617379636f696e04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43000000000002010003014f06ad01ab00655663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb0000000020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f685287402b4c71447e74672f8cd5b50a6b430fc73b3caff7866dc905a502fe8adefad3b3101420140013a3f644a0428e3713e8f325b31734ce071fee2a55e3a64a4debd4ef384ba5b340f6b3b9163c5ae37f97aa3a287fd4f1850a3f2a08166568d1a24b2fbda4ece0728fdee0a27d560e5223b5e06b7a61d3df5b405942d21cf887fc96b16088874546a000000000000006408020000092102258420ed4cf219965908102c6f8498da274c251a3463880763ba118c2d946c62059f0004000000000121024a3cb06616bb1545d3a25417a3fa5ccc70c5fbe9ceed8666410ed83745bbe96802740049000100012020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f685287402220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff06f802c70004000000010121033e42d7bdc3c5161c2dc440667b0f4fca4c4a7d32d13efac12a71994651b048ce029c0071000100012020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874024a0001c37d7cb2bb159ad5843a204c210782c937765e0c54e1ac431f5519d0b02b95410000000000000015ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2e0004000000020121026c93d33b5f69084411ffc540db8c0135300fdb4cdae2e5cd6ad1efd27a9d8cc20303020101&quot;,<br>                &quot;split_commit_root_hash&quot;: &quot;fdee0a27d560e5223b5e06b7a61d3df5b405942d21cf887fc96b16088874546a&quot;,<br>                &quot;output_type&quot;: &quot;OUTPUT_TYPE_SPLIT_ROOT&quot;<br>            },<br>            {<br>                &quot;anchor&quot;: {<br>                    &quot;outpoint&quot;: &quot;b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4:1&quot;,<br>                    &quot;value&quot;: &quot;1000&quot;,<br>                    &quot;internal_key&quot;: &quot;033e42d7bdc3c5161c2dc440667b0f4fca4c4a7d32d13efac12a71994651b048ce&quot;,<br>                    &quot;taproot_asset_root&quot;: &quot;8aada842f74c2b11e9b5a0a716baa0c453855ab6ea316222a8a28e7e79506f41&quot;,<br>                    &quot;merkle_root&quot;: &quot;8aada842f74c2b11e9b5a0a716baa0c453855ab6ea316222a8a28e7e79506f41&quot;,<br>                    &quot;tapscript_sibling&quot;: null,<br>                    &quot;num_passive_assets&quot;: 0<br>                },<br>                &quot;script_key&quot;: &quot;0225357fc148c441fbd5c5ea533fd6c33686697967a1cf8c493628788a535f433c&quot;,<br>                &quot;script_key_is_local&quot;: true,<br>                &quot;amount&quot;: &quot;21&quot;,<br>                &quot;new_proof_blob&quot;: &quot;00245663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb000000000150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096e88000000000000000002fd0163020000000001025663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb0100000000ffffffff5663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb00000000000000000003e803000000000000225120f036a7c3d36d4459fc4566875b255b80177fee26ea8cb27a1387e38dedee46f8e803000000000000225120be0db94139918a132eb4821f834efdec4634261997b57d964753d60923be9deed52e010000000000225120a0330b1c1bec571ac4e9004cae724380b3acf96a2f88332f4d6bd7136518932c0140db4f7d819f7fe90677c6e0d8355fe2b41f123934a5fb34117377841d3f1f305a82fbe7feea5fb51c2b8f598934027f455fb5d5f12ec6ba5b4538ef8cead916d801407fa2c953e2cbfd8ab9813b06f11919bfc3fba51ef9bac960ae522f9ea2b2f3acfd976dcc31bb49b9c4dc906952ddf7b79c7467a0c1f22ed1d845794adbe558e50000000003010004fd02a80001000155ce884eb3ff8daf14cb05147d2e9912d2f81163e518fd3394d4a192a7539177ba000000000b66616e74617379636f696e04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43000000000002010003011506fd021d01fd02190065000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002fd01ae4a00014d1b83c6f29417ec329b91f9cc95cb38facb112bf1d12d4ca3c45d5cd3765857000000000000004fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffd01600001000155ce884eb3ff8daf14cb05147d2e9912d2f81163e518fd3394d4a192a7539177ba000000000b66616e74617379636f696e04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43000000000002010003014f06ad01ab00655663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb0000000020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f685287402b4c71447e74672f8cd5b50a6b430fc73b3caff7866dc905a502fe8adefad3b3101420140013a3f644a0428e3713e8f325b31734ce071fee2a55e3a64a4debd4ef384ba5b340f6b3b9163c5ae37f97aa3a287fd4f1850a3f2a08166568d1a24b2fbda4ece0728fdee0a27d560e5223b5e06b7a61d3df5b405942d21cf887fc96b16088874546a000000000000006408020000092102258420ed4cf219965908102c6f8498da274c251a3463880763ba118c2d946c620802000009210225357fc148c441fbd5c5ea533fd6c33686697967a1cf8c493628788a535f433c059f0004000000010121033e42d7bdc3c5161c2dc440667b0f4fca4c4a7d32d13efac12a71994651b048ce02740049000100012020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f685287402220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff06f802c70004000000000121024a3cb06616bb1545d3a25417a3fa5ccc70c5fbe9ceed8666410ed83745bbe968029c0071000100012020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874024a0001979a9f1a4fc2545215daab7876c5e47907a9ff6ed4cd0ca7dcedb6cf3eafc50c000000000000004fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2e0004000000020121026c93d33b5f69084411ffc540db8c0135300fdb4cdae2e5cd6ad1efd27a9d8cc20303020101079f0004000000000121024a3cb06616bb1545d3a25417a3fa5ccc70c5fbe9ceed8666410ed83745bbe96802740049000100012020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f685287402220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff&quot;,<br>                &quot;split_commit_root_hash&quot;: null,<br>                &quot;output_type&quot;: &quot;OUTPUT_TYPE_SIMPLE&quot;<br>            }<br>        ]<br>    }<br>}</pre><p>A new Bitcoin transaction (<a href="https://mempool.space/testnet/tx/b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4">b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4</a>) was issued that spent the Bitcoin UTXO (<a href="https://mempool.space/testnet/tx/ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356">ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356</a>:0) just described, including the created asset.</p><p>Finally, I summarize the Bitcoin transactions, their UTXOs, and changes. Assets do not decrease with each transfer and remain the same before and after the transfer, while Bitcoin (sats) decrease for the transaction fee.</p><ul><li><a href="https://mempool.space/testnet/tx/ba779153a792a1d49433fd18e56311f8d212992e7d1405cb14af8dffb34e88ce">ba779153a792a1d49433fd18e56311f8d212992e7d1405cb14af8dffb34e88ce</a><br>:0 genesis_point（100000 sats）<br>:1 Bitcoin change output（145788 sats）</li><li><a href="https://mempool.space/testnet/tx/ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356">ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356</a><br>:0 Includes 100 of the created asset（1000 sats）<br>:1 Bitcoin change output. The asset not included（91250 sats）</li><li><a href="https://mempool.space/testnet/tx/b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4">b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4</a><br>:0 Includes 79 of the change asset（1000 sats）<br>:1 Includes 21 of the transferred asset（1000 sats）<br>:2 Bitcoin change output. The asset not included（77525 sats）</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2abd51d37765" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nayuta-engineering-blog-en/understanding-taproot-assets-protocol-2-2abd51d37765">Understanding Taproot Assets Protocol #2</a> was originally published in <a href="https://medium.com/nayuta-engineering-blog-en">Nayuta Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Taproot Assets Protocol]]></title>
            <link>https://medium.com/nayuta-engineering-blog-en/understanding-taproot-assets-protocol-e2dfe3fc1e07?source=rss-ec449712cbf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2dfe3fc1e07</guid>
            <category><![CDATA[taproot]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[lightning-network]]></category>
            <category><![CDATA[taro]]></category>
            <category><![CDATA[taproot-assets-protocol]]></category>
            <dc:creator><![CDATA[Hiroki Gondo]]></dc:creator>
            <pubDate>Fri, 09 Jun 2023 09:15:53 GMT</pubDate>
            <atom:updated>2023-06-21T06:42:34.899Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*6jU8wwLxN_69EnXLJ-BpCg.jpeg" /></figure><p>The Taproot Assets Protocol (formerly Taro, hereafter referred to as TAP) is a protocol for representing UTXO-based assets on top of Bitcoin. This article aims to understand how TAP creates and transfers assets.</p><p>The specifications are as follows. Here I will mainly explain bip-tap and bip-tap-ms-smt.</p><ul><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-addr.mediawiki">bip-tap-addr</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-ms-smt.mediawiki">bip-tap-ms-smt</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-proof-file.mediawiki">bip-tap-proof-file</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-psbt.mediawiki">bip-tap-psbt</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-universe.mediawiki">bip-tap-universe</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-vm.mediawiki">bip-tap-vm</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap.mediawiki">bip-tap</a></li></ul><p>The implementation by Lightning Labs is <a href="https://github.com/lightninglabs/taproot-assets">here</a>.</p><h3>What Is Taproot?</h3><p><a href="https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki">Taproot</a> is a new type of Bitcoin output that allows two types of payment conditions to be specified simultaneously: Key Pathand Script Path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*3ZjfJfqZlG3Sr8zCRpDO6g.png" /></figure><p>Key Path, like traditional P2PKH, is spent by the signature of a public key. Key Aggregation (multi-sig) with Schnorr signatures can also be used.</p><p>Script Path, like traditional P2SH, allows complex payment conditions by a scripting language. It also allows multiple scripts to be specified simultaneously. These scripts are not serialized directly into the Taproot output but are structured by a Merkle tree and compressed into its root hash. Individual scripts are published on-chain only if the output is spent under their conditions.</p><p>TAP embeds its data (Asset Tree) in Script Path. This data is uninterpretable and undetectable from a Bitcoin perspective since it is hashed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vHAqoqHoLHQ6DMZ-nFu5Og.png" /></figure><h3>Taproot Asset Representation</h3><h4>Asset Tree</h4><p>An Asset Tree, a two-level Merkle Sum Sparse Merkle Tree structure, represents Taproot Assets. The lower represents the set of UTXOs of a single asset identified by asset_id. The upper aggregates the lowers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*ykcsSYt_mGNy8uhutO7K7g.png" /></figure><p>The value of the upper root hash (asset_tree_root) is embedded in Script Pathof Taproot outputs, and the tree state is committed.</p><p>An asset transfer creates a new Asset Tree, and the previous one is updated. These are accompanied by the issuance of a new Bitcoin transaction that spends the previous Taproot output; unauthorized transfers that do not meet the specifications (e.g., inflation, double-spending) are considered invalid. *</p><p>* This is the so-called <a href="https://scalingbitcoin.org/transcript/milan2016/client-side-validation">Client Side Validation</a> concept; those familiar with Bitcoin’s emergent consensus may be curious about the basis for the correctness of the specifications, but I’ll put that issue on hold here.</p><h4>Merkle Sum Sparse Merkle Tree</h4><p>Merkle Sum Sparse Merkle Tree (hereafter referred to as MS-SMT) is a variant of the Markle tree defined by <a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-ms-smt.mediawiki">bip-tap-ms-smt</a>. Since the key is 256 bits, it has 2 ^ 256 leaves, most of which are empty.</p><p>Each leaf contains an amount, and each branch commits the total amount in the leaves in the subtree. Even if the contents of a subtree are not known, the total amount contained therein can be known just by looking at the branch. The root commits the total amount in the tree.</p><p>Like the Markle Tree in general, a pruned tree containing any leaf can offer the inclusion proof of these leaves (Merkle Proof), but MS-SMT also supports non-inclusion proofs. This is accomplished by the restriction that a non-existent key’s leaf must be explicitly set to a value indicating its non-existence (None) (inclusion proof of “None” = non-inclusion proof). Thus the default tree has 2 ^ 256 “None” leaves.</p><h4>Asset Leaf（Asset UTXO）</h4><p>The lower MS-SMTs of the Asset Tree have asset_script_key as the key, and the Asset Leaf as the value. Each Asset Leaf represents a UTXO of the asset (hereafter referred to as UTXO for simplicity *), and the following items, including optional ones, are serialized in the <a href="https://github.com/lightning/bolts/blob/master/01-messaging.md#type-length-value-format">Type-length-value format</a>.</p><p>* Not that of Bitcoin.</p><ul><li>taproot_asset_version</li><li>asset_genesis</li><li>asset_id</li><li>asset_type</li><li>amt</li><li>lock_time</li><li>relative_lock_time</li><li>prev_asset_witnesses <br>- prev_asset_id <br>- asset_witness <br>- split_commitment_proof</li><li>split_commitment</li><li>asset_script_version</li><li>asset_script_key</li><li>asset_group_key</li><li>canonical_universe</li></ul><p>asset_genesis is a preimage of the data from which asset_idis derived.</p><p>asset_script_key is both the key of the Asset Leaf and the public key of Taproot type (on a virtual <a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-vm.mediawiki">tap-vm</a>, separate from Bitcoin) and is the payment condition for spending the UTXO represented by this Asset Leaf.</p><p>When spending a UTXO, the (external) Bitcoin payment condition must be met as well, as the (internal) TAP payment condition specified in asset_script_key must also be met by prev_asset_id and asset_witness. For example, asset_witness is a signature by asset_script_key of the spent UTXO.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*8yCJofequ55HYKSPG1Gb-Q.png" /></figure><p>If a UTXO is split in a transfer, split_commitment and split_commitment_proof are needed.</p><p>split_commitment is an MS-SMT that refers to all the UTXOs after the split (In this case, Asset Tree has three layers), and the sum value of the root is the total amount of assets transferred.</p><p>split_commitment_proof is a Merkle Proof of split_commitment which proves the existence of a split.</p><p>Only one of all splits has prev_asset_id, asset_witness, and split_commitment. All other splits have onlysplit_commitment_proof. All splits share prev_asset_id and asset_witness.</p><h3>Asset Creation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Tu6LHxuI1gTzOIKHf04zg.png" /></figure><p>An asset is created by embedding a new Asset Tree containing new asset UTXOs into a Taproot output of a Bitcoin transaction (the genesis transaction of the asset). The ID of the asset (asset_id) is defined by the following formula.</p><p>asset_id := sha256(genesis_outpoint || sha256(asset_tag) || asset_meta_hash || output_index || asset_type)</p><p>genesis_outpoint is the output of the previous transaction spent by the transaction, and output_index is the output position of the transaction containing the Asset Tree. These ensure that asset_id is globally unique.</p><p>The newly created UTXO omitsprev_asset_id and asset_witness.</p><h3>Asset Transfer</h3><p>Like Bitcoin UTXOs, a merger and split of UTXOs may occur in a transfer of assets. But we begin with a simple case where none of the above occurs *.</p><p>* Some simplifications have been made in the following explanation. For example, The change outputs of Bitcoin are omitted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k9uQ2Brglnx-HOPaqVTupg.png" /></figure><p>Alice has 10 and transfers all of them to Bob without splitting.</p><p>Alice creates and broadcasts a Bitcoin transaction that spends the Taproot output where the UTXO is embedded. This has two new Taproot outputs. One contains a new Asset Tree containing a new UTXO with 10 that Bob can control (e.g., using Bob’s Bitcoin key). The other includes an Asset Tree from which the asset UTXO has been removed from the original Asset Tree, which Alice can control.</p><p>The new UTXO with 10 for Bob refers to Alice’s previous UTXO by prev_asset_id. In asset_witness, the signature by the previous asset_script_key is placed. In asset_script_key of the new UTXO, a new one given by Bob in advance is placed.</p><p>Bob needs to verify that payment conditions have been met and that the asset has not been inflated after the transfer to confirm receipt of the asset.</p><ul><li>Does the newly created Asset Tree for Bob contain a new UTXO that meets the payment conditions?</li><li>Has the input UTXO been removed from the updated Asset Tree for Alice?</li><li>If there are other Taproot outputs in the transaction, Don’t they contain another Asset Tree? *</li><li>and so on.</li></ul><p>These are proven/verified by the inclusion/non-inclusion proofs of MS-SMT and the preimages and proofs of the Taproot outputs.</p><p>* If a different UTXO is added to such an Asset Tree than the one for Bob that spends the input UTXO, it would result in double-spending.</p><h4>Merger UTXO</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2vwC4q_3DOb0R8fs7RXxJQ.png" /></figure><p>Alice has 3 and 7, transferring all of them to Bob.</p><p>Each input UTXO may belong separately to a different Asset Tree or different keys (asset_script_key) of the same tree. The new UTXO for Bob should include prev_asset_id and asset_witness for each of the two UTXOs spent.</p><h4>Split UTXO</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mmoYchmgOBsa_MUKPOlbwg.png" /></figure><p>Alice has 10 and transfers 7 of them to Bob. As a result, Alice has 3 for change, and Bob has 7.</p><p>Alice’s change UTXO has prev_asset_id, asset_witness, and split_commitment; Bob’s new UTXO only has split_commitment_proof *.</p><p>I will not explain when to merge and split UTXOs simultaneously.</p><p>* This is slightly different from what <a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap.mediawiki">the specification</a> says, but the current <a href="https://github.com/lightninglabs/taproot-assets">implementation</a> probably looks like this.</p><h4>Asset Provenance</h4><p>Although not mentioned previously, each input UTXO must be verified as legitimate before the asset transfer can be verified. For each input UTXO, it must be proved/verified that all transfers along the routes from the genesis transaction of the asset, on which the asset is based, to the new UTXO have been performed correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Z-NG7a7zjf1H7hGekaU6g.png" /></figure><p>The routes are a complex graph from the genesis transaction to the most recent transaction. In the above, at the Tx A, it needs to validate transfers on all blue transactions of its ancestors, and at the Tx B, it needs to validate transfers on all of the blue and red ones. This is a significant scalability challenge because history grows quasi-exponentially.</p><p>Also, since the preimages and proofs required for verification are not published on-chain, how they are passed from the sender to the receiver during asset transfer is an issue.</p><h3>Scalability</h3><p>Increased history is a significant scalability challenge. Several solutions have been proposed, but support for Lightning Network is one of the most promising. Off-chain transactions do not increase history.</p><p>This protocol is still new and the specifications are incomplete. For example, there is <a href="https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-October/021047.html">this issue</a> I pointed out before.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2dfe3fc1e07" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nayuta-engineering-blog-en/understanding-taproot-assets-protocol-e2dfe3fc1e07">Understanding Taproot Assets Protocol</a> was originally published in <a href="https://medium.com/nayuta-engineering-blog-en">Nayuta Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taproot Assets Protocol を理解する（実践編 #2）]]></title>
            <link>https://medium.com/nayuta-engineering-blog-ja/taproot-assets-protocol-%E3%82%92%E7%90%86%E8%A7%A3%E3%81%99%E3%82%8B-%E5%AE%9F%E8%B7%B5%E7%B7%A8-2-9464b00b1246?source=rss-ec449712cbf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/9464b00b1246</guid>
            <category><![CDATA[lightning-network]]></category>
            <category><![CDATA[taro-protocol]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Hiroki Gondo]]></dc:creator>
            <pubDate>Mon, 29 May 2023 08:53:07 GMT</pubDate>
            <atom:updated>2023-05-30T05:14:20.818Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*6jU8wwLxN_69EnXLJ-BpCg.jpeg" /></figure><p><a href="https://medium.com/nayuta-inc/taro-%E3%83%97%E3%83%AD%E3%83%88%E3%82%B3%E3%83%AB%E3%82%92%E7%90%86%E8%A7%A3%E3%81%99%E3%82%8B-%E5%AE%9F%E8%B7%B5%E7%B7%A8-8c9574856c79">以前の記事</a>で Taproot Assets Protocol Daemon（<a href="https://github.com/lightninglabs/taproot-assets">tapd</a>）をインストールしてアセットを生成し、転送した。しかし、単一の tapd で自分から自分にアセットを転送したので、重要な手順が省略されている。</p><p>ここでは 2 台の tapd （とそれぞれと連携する LND）を実行し、片方で生成したアセットをもう一方へ転送する。簡単に複数ノードを実行するために <a href="https://github.com/jamaljsr/polar">Polar</a> を使用して環境を構築する。simnet（regtest）環境で実行するため、どこからか Bitcoin を融通する必要もなくなる :)</p><p><strong>注意！</strong>完全に tapd の実装を確認したわけではないのでこの記事の一部に推測を含みます。内容に誤りがある可能性があります :)</p><h3>環境の構築</h3><p>Polar のインストールは簡単なので特にここで説明はしないが、tapd に対応した<a href="https://github.com/jamaljsr/polar/releases/tag/v2.0.0">最新のリリース</a>をインストールする必要がある。</p><p>Polar を実行したら、Create Network 画面で以下の構成でネットワークを構築する。</p><ul><li>LND 2 台</li><li>Bitcoin Core 1 台</li></ul><p>Bitcoin Core は simnet 環境のマイナーで以降直接触ることはない。</p><p>ネットワークが構築されたら Network Designer からそれぞれの LND に対して Taproot Assets Daemon を追加する。以下のような構成になる。</p><ul><li>alice (LND) + alice-tap (tapd)</li><li>bob (LND) + bob-tap (tapd)</li><li>bakend1 (マイナー)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*--SguAA9d7rX8ehalp9uWg.png" /></figure><p>[Start] ボタンを押して、すべてのノードを起動する。</p><p>アセットの生成、転送には Bitcoin トランザクションの発行が伴うので、LND に幾ばくかの Bitcoin が必要になる。</p><p>それぞれの LND (alice, bob) を選択し、 [Actions] -&gt; [Deposit] を押して Bitcoin を Deposit する。</p><p>環境の構築はこれで終わり。</p><p>以降の手順は、Polar の GUI 上で容易に実行することができるが、今回は何が行われているか理解するために、あえて Terminal からコマンドを発行して行う。</p><h3>アセットの生成</h3><p>alice-tap の [Actions] -&gt; [Terminal] -&gt; [Launch] を押して Terminal を開く。以下のコマンドでアセットを生成する。</p><pre>tap@alice-tap:/$ tapcli --tapddir=~/.tapd/ assets mint --type normal --name fantasycoin --supply 100 --meta_bytes &quot;fantastic money&quot;<br>{<br>    &quot;batch_key&quot;: &quot;0340d50914ac4177066e0729f8c7580eece1abcc5f99e8dc2f72ff3191dd3adb36&quot;<br>}<br>tap@alice-tap:/$ tapcli --tapddir=~/.tapd/ assets mint finalize<br>{<br>    &quot;batch_key&quot;: &quot;0340d50914ac4177066e0729f8c7580eece1abcc5f99e8dc2f72ff3191dd3adb36&quot;<br>}<br>tap@alice-tap:/$ tapcli --tapddir=~/.tapd/ assets list         <br>{<br>    &quot;assets&quot;: [<br>        {<br>            &quot;version&quot;: 0,<br>            &quot;asset_genesis&quot;: {<br>                &quot;genesis_point&quot;: &quot;b0aa68809a3c0e1cef0e818296f5cea549b3e82fb8abeaa5b9a045f2993adcac:1&quot;,<br>                &quot;name&quot;: &quot;fantasycoin&quot;,<br>                &quot;meta_hash&quot;: &quot;04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43&quot;,<br>                &quot;asset_id&quot;: &quot;4c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c&quot;,<br>                &quot;output_index&quot;: 0,<br>                &quot;version&quot;: 0<br>            },<br>            &quot;asset_type&quot;: &quot;NORMAL&quot;,<br>            &quot;amount&quot;: &quot;100&quot;,<br>            &quot;lock_time&quot;: 0,<br>            &quot;relative_lock_time&quot;: 0,<br>            &quot;script_version&quot;: 0,<br>            &quot;script_key&quot;: &quot;0257f1c79e28e5d9e31ec2e90eeacb48abc1db4d94db668c2bfd1e6c52d738b826&quot;,<br>            &quot;script_key_is_local&quot;: true,<br>            &quot;asset_group&quot;: null,<br>            &quot;chain_anchor&quot;: {<br>                &quot;anchor_tx&quot;: &quot;02000000000101acdc3a99f245a0b9a5eaabb82fe8b349a5cef59682810eef1c0e3c9a8068aab00100000000ffffffff02e803000000000000225120abd6ed0b2442e8099ea5208eb28cd5375f96ddc050c36cdae085c9aeb4e565431e1e0f00000000002251206b20afddf11d1e359d7bc205cbc3c52ff5c1bc283c2df69767017edbb030d13c02483045022100806cdf440cf0e0426e8458e663009a5fc0ec89903624ab89af6aee1dbecfa8f10220460befadd971a55e6c51b4755b14abae2d3bb977d85b6a99d0ddd11dd42c2b7e01210286e6439ae6b3d424dbbe2f4c3a5fc15a19aa6d1a54c9a8c4eb8d42f9c2e7a46e00000000&quot;,<br>                &quot;anchor_txid&quot;: &quot;cc845fdf19988f8b89d44c9482af82aef10b15135c2e7bd91fa5d4cff3a15142&quot;,<br>                &quot;anchor_block_hash&quot;: &quot;0000000000000000000000000000000000000000000000000000000000000000&quot;,<br>                &quot;anchor_outpoint&quot;: &quot;cc845fdf19988f8b89d44c9482af82aef10b15135c2e7bd91fa5d4cff3a15142:0&quot;,<br>                &quot;internal_key&quot;: &quot;0340d50914ac4177066e0729f8c7580eece1abcc5f99e8dc2f72ff3191dd3adb36&quot;,<br>                &quot;merkle_root&quot;: &quot;be3431d1aaf341ac5d20f86ceeea2364178e19e57de956c1bf03380f28fd1e2f&quot;,<br>                &quot;tapscript_sibling&quot;: null<br>            },<br>            &quot;prev_witnesses&quot;: [<br>            ],<br>            &quot;is_spent&quot;: false<br>        }<br>    ]<br>}</pre><p>Polar の画面で [Quick Mine] ボタンを押してブロックを生成し、このトランザクションを確定させる。</p><p>これでアセットが生成された。</p><h3>アドレスの生成と Universe の同期</h3><p>同様に bob-tap の Terminal を開き、当該アセットを受け取るためのアドレスを生成する。</p><pre>tap@bob-tap:/$ tapcli --tapddir=~/.tapd/ addrs new --asset_id 4c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c --amt 21<br>[tapcli] unable to make addr: rpc error: code = Unknown desc = unable to make new addr: unable to make address for unknown asset 4c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c: asset group is unknown</pre><p>エラーになる ;(</p><p>bob-tap は指定された assset_id のアセットがオンチェーン上で正しく生成されているか検証できないといけない。そのためにはこのアセットのメタデータや生成トランザクションの Taproot 出力（anchor_outpoint）に埋め込まれたアセットデータの pre-image や proof が必要になる。これらのデータをまとめて発行証明と呼ぼう。</p><p>発行証明は Universe を使用して取得することができる。Universe は 発行証明を保管し、外部に提供するためのサーバである。tapd はそれぞれ内部に Local Universe を持つ。bob-tap の Universe が alice-tap の Universe と同期することにより、発行証明を取得することができる。</p><pre>tap@bob-tap:/$ tapcli --tapddir=~/.tapd/ universe sync --universe_host alice-tap<br>{<br>    &quot;synced_universes&quot;: [<br>        {<br>            &quot;old_asset_root&quot;: {<br>                &quot;id&quot;: null,<br>                &quot;mssmt_root&quot;: null,<br>                &quot;asset_name&quot;: &quot;&quot;<br>            },<br>            &quot;new_asset_root&quot;: {<br>                &quot;id&quot;: {<br>                    &quot;asset_id&quot;: &quot;4c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c&quot;<br>                },<br>                &quot;mssmt_root&quot;: {<br>                    &quot;root_hash&quot;: &quot;fbb1ffde221f2b21d913ff0602fce2feb7fca8f906e6dc9fa38c885c93490b11&quot;,<br>                    &quot;root_sum&quot;: &quot;100&quot;<br>                },<br>                &quot;asset_name&quot;: &quot;&quot;<br>            },<br>            &quot;new_asset_leaves&quot;: [<br>                {<br>                    &quot;asset&quot;: {<br>                        &quot;version&quot;: 0,<br>                        &quot;asset_genesis&quot;: {<br>                            &quot;genesis_point&quot;: &quot;b0aa68809a3c0e1cef0e818296f5cea549b3e82fb8abeaa5b9a045f2993adcac:1&quot;,<br>                            &quot;name&quot;: &quot;fantasycoin&quot;,<br>                            &quot;meta_hash&quot;: &quot;04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43&quot;,<br>                            &quot;asset_id&quot;: &quot;4c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c&quot;,<br>                            &quot;output_index&quot;: 0,<br>                            &quot;version&quot;: 0<br>                        },<br>                        &quot;asset_type&quot;: &quot;NORMAL&quot;,<br>                        &quot;amount&quot;: &quot;100&quot;,<br>                        &quot;lock_time&quot;: 0,<br>                        &quot;relative_lock_time&quot;: 0,<br>                        &quot;script_version&quot;: 0,<br>                        &quot;script_key&quot;: &quot;0257f1c79e28e5d9e31ec2e90eeacb48abc1db4d94db668c2bfd1e6c52d738b826&quot;,<br>                        &quot;script_key_is_local&quot;: false,<br>                        &quot;asset_group&quot;: null,<br>                        &quot;chain_anchor&quot;: null,<br>                        &quot;prev_witnesses&quot;: [<br>                            {<br>                                &quot;prev_id&quot;: {<br>                                    &quot;anchor_point&quot;: &quot;0000000000000000000000000000000000000000000000000000000000000000:0&quot;,<br>                                    &quot;asset_id&quot;: &quot;0000000000000000000000000000000000000000000000000000000000000000&quot;,<br>                                    &quot;script_key&quot;: &quot;000000000000000000000000000000000000000000000000000000000000000000&quot;,<br>                                    &quot;amount&quot;: &quot;0&quot;<br>                                },<br>                                &quot;tx_witness&quot;: [<br>                                ],<br>                                &quot;split_commitment&quot;: null<br>                            }<br>                        ],<br>                        &quot;is_spent&quot;: false<br>                    },<br>                    &quot;issuance_proof&quot;: &quot;0024acdc3a99f245a0b9a5eaabb82fe8b349a5cef59682810eef1c0e3c9a8068aab00000000101500000002013b2469cee9db74d3e96ea21cb543dcc7a954a0849ae86b0107835e5351ea03d15b5d52f07cf3027e7c06db9b9360afbcbcbea3e5939c0702e04217181d1e81b65527464ffff7f200100000002f702000000000101acdc3a99f245a0b9a5eaabb82fe8b349a5cef59682810eef1c0e3c9a8068aab00100000000ffffffff02e803000000000000225120abd6ed0b2442e8099ea5208eb28cd5375f96ddc050c36cdae085c9aeb4e565431e1e0f00000000002251206b20afddf11d1e359d7bc205cbc3c52ff5c1bc283c2df69767017edbb030d13c02483045022100806cdf440cf0e0426e8458e663009a5fc0ec89903624ab89af6aee1dbecfa8f10220460befadd971a55e6c51b4755b14abae2d3bb977d85b6a99d0ddd11dd42c2b7e01210286e6439ae6b3d424dbbe2f4c3a5fc15a19aa6d1a54c9a8c4eb8d42f9c2e7a46e00000000032201fa282b2b3ca0dcbf0a9244761cbd93d09b5e75e8a99d7757b394bd9e6f1549710004f20001000155acdc3a99f245a0b9a5eaabb82fe8b349a5cef59682810eef1c0e3c9a8068aab0000000010b66616e74617379636f696e04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43000000000002010003016406690167006500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000802000009210257f1c79e28e5d9e31ec2e90eeacb48abc1db4d94db668c2bfd1e6c52d738b826059f00040000000001210340d50914ac4177066e0729f8c7580eece1abcc5f99e8dc2f72ff3191dd3adb360274004900010001204c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c02220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0630012e000400000001012102a008a19cdc936b84ace324dcd6afef7798454342a87f460699deb0d3f85640c403030201010814000100010f66616e746173746963206d6f6e6579&quot;<br>                }<br>            ]<br>        }<br>    ]<br>}</pre><p>これでアドレスが発行できるようになった。</p><pre>tap@bob-tap:/$ tapcli --tapddir=~/.tapd/ addrs new --asset_id 4c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c --amt 21<br>{<br>    &quot;encoded&quot;: &quot;taprt1qqqsqq3qf39mp50czy8k94uyt26kleavrrne8j5696mapchm603lvshteawqgggzed59whmcfaz6xdtjqnygvdq9yn23ctx3fx4jvl0zg667kk6ffwxsvggzk48rpyuh22s2hx47nep68athj2ly05lljxfc8dud73uxeueu3afssqg4tslzq5&quot;,<br>    &quot;asset_id&quot;: &quot;4c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c&quot;,<br>    &quot;asset_type&quot;: &quot;NORMAL&quot;,<br>    &quot;amount&quot;: &quot;21&quot;,<br>    &quot;group_key&quot;: null,<br>    &quot;script_key&quot;: &quot;02cb68575f784f45a3357204c886340524d51c2cd149ab267de246b5eb5b494b8d&quot;,<br>    &quot;internal_key&quot;: &quot;02b54e30939752a0ab9abe9e43a3f57792be47d3ff919383b78df4786cf33c8f53&quot;,<br>    &quot;tapscript_sibling&quot;: null,<br>    &quot;taproot_output_key&quot;: &quot;3d55ca36ece1cc057034df880bd8141cd0a61da15dc6e01b812a2dfed5f4cbab&quot;<br>}</pre><h3>アセットの転送</h3><p>生成されたアドレスに対して alice-tap からアセットを送る。</p><pre>tap@alice-tap:/$ tapcli --tapddir=~/.tapd/ assets send --addr taprt1qqqsqq3qf39mp50czy8k94uyt26kleavrrne8j5696mapchm603lvshteawqgggzed59whmcfaz6xdtjqnygvdq9yn23ctx3fx4jvl0zg667kk6ffwxsvggzk48rpyuh22s2hx47nep68athj2ly05lljxfc8dud73uxeueu3afssqg4tslzq5<br>{<br>    &quot;transfer&quot;: {<br>        &quot;transfer_timestamp&quot;: &quot;1685348891&quot;,<br>        &quot;anchor_tx_hash&quot;: &quot;f8e9dabf8b7051246a2f2ef5f978ecf19405802fdc4da2b89fc5d82fa751b0cb&quot;,<br>        &quot;anchor_tx_height_hint&quot;: 120,<br>        &quot;anchor_tx_chain_fees&quot;: &quot;13262&quot;,<br>        &quot;inputs&quot;: [<br>            {<br>                &quot;anchor_point&quot;: &quot;cc845fdf19988f8b89d44c9482af82aef10b15135c2e7bd91fa5d4cff3a15142:0&quot;,<br>                &quot;asset_id&quot;: &quot;4c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c&quot;,<br>                &quot;script_key&quot;: &quot;0257f1c79e28e5d9e31ec2e90eeacb48abc1db4d94db668c2bfd1e6c52d738b826&quot;,<br>                &quot;amount&quot;: &quot;100&quot;<br>            }<br>        ],<br>        &quot;outputs&quot;: [<br>            {<br>                &quot;anchor&quot;: {<br>                    &quot;outpoint&quot;: &quot;cbb051a72fd8c59fb8a24ddc2f800594f1ec78f9f52e2f6a2451708bbfdae9f8:0&quot;,<br>                    &quot;value&quot;: &quot;1000&quot;,<br>                    &quot;internal_key&quot;: &quot;03bf46a593e2c7a1ef99fa07f509c8df0e592eae9e3ff5ccef1bf8ae78674de82d&quot;,<br>                    &quot;taproot_asset_root&quot;: &quot;335a3664200fcd5220d7f343311232ecd3e7182d24f9c183d3ad2be2af00f4c7&quot;,<br>                    &quot;merkle_root&quot;: &quot;335a3664200fcd5220d7f343311232ecd3e7182d24f9c183d3ad2be2af00f4c7&quot;,<br>                    &quot;tapscript_sibling&quot;: null,<br>                    &quot;num_passive_assets&quot;: 0<br>                },<br>                &quot;script_key&quot;: &quot;0261a4ecd533bdc4fd9cf84f62763da4a4414553149d3f6c7c41a5b57ba4e4fd30&quot;,<br>                &quot;script_key_is_local&quot;: true,<br>                &quot;amount&quot;: &quot;79&quot;,<br>                &quot;new_proof_blob&quot;: &quot;00244251a1f3cfd4a51fd97b2e5c13150bf1ae82af82944cd4898b8f9819df5f84cc000000000150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096e88000000000000000002fd018d02000000000102e7494b164d58fc77efa95f0d27663b6aaf3f5e9433c084a8a9718291aca6afb50000000000ffffffff4251a1f3cfd4a51fd97b2e5c13150bf1ae82af82944cd4898b8f9819df5f84cc00000000000000000003e8030000000000002251209771a17c952030b3590d0e66f43323c6459e7083f3c8d248ef352ecae8d32dd8e8030000000000002251203d55ca36ece1cc057034df880bd8141cd0a61da15dc6e01b812a2dfed5f4cbab8a0a0f0000000000225120b1c9eddddc3abde2a4eef330bfdc150ecd4d462099e00927e024fca55752f0dd024830450221008e25d13e80b5406f8ae8c7f30901787d203ab322ef1603d0755c8526c60460f402204d16168ec8017810dcb2480aae655c1c1578d981caed7fecc8dad461e79dd1de0121032759e7ff68ce4cb95cb2a149b66a2fcccd5f2d5c98a9cff3c5d51d45d9e3acdc01408fbc4e62b8eae348f392616bdb19b5f72ff00281a92ca1e8d8ba039e22baf0dc2558d14d76b5d86d17118c671d6eff6653a31b7b1c7d98b2fc4e7ca544f7c4e90000000003010004fd01600001000155acdc3a99f245a0b9a5eaabb82fe8b349a5cef59682810eef1c0e3c9a8068aab0000000010b66616e74617379636f696e04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43000000000002010003014f06ad01ab00654251a1f3cfd4a51fd97b2e5c13150bf1ae82af82944cd4898b8f9819df5f84cc000000004c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c0257f1c79e28e5d9e31ec2e90eeacb48abc1db4d94db668c2bfd1e6c52d738b826014201407ff1d573b6425966961d370b2ea6b6639739f1cde0400257e4231a29069e0327b2880420a0066d3cefaeeef4c7cae114ee4ce1a0bd163c262546dd50ed11ad5b072828d78daa63b031856f1b77928d8b30341068b86bc18961ecd921d00c1b78ef6000000000000000640802000009210261a4ecd533bdc4fd9cf84f62763da4a4414553149d3f6c7c41a5b57ba4e4fd30059f000400000000012103bf46a593e2c7a1ef99fa07f509c8df0e592eae9e3ff5ccef1bf8ae78674de82d0274004900010001204c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c02220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff06f802c7000400000001012102b54e30939752a0ab9abe9e43a3f57792be47d3ff919383b78df4786cf33c8f53029c007100010001204c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c024a000161a674e11bf65860c14acc2d591ad710a045e3ab0f1c0ff277a5410d34a874bf0000000000000015ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2e00040000000201210266ade74a22f176a0f511d65bfe797b8b67b8879f112b1a92619fa3cc37b84c940303020101&quot;,<br>                &quot;split_commit_root_hash&quot;: &quot;28d78daa63b031856f1b77928d8b30341068b86bc18961ecd921d00c1b78ef60&quot;,<br>                &quot;output_type&quot;: &quot;OUTPUT_TYPE_SPLIT_ROOT&quot;<br>            },<br>            {<br>                &quot;anchor&quot;: {<br>                    &quot;outpoint&quot;: &quot;cbb051a72fd8c59fb8a24ddc2f800594f1ec78f9f52e2f6a2451708bbfdae9f8:1&quot;,<br>                    &quot;value&quot;: &quot;1000&quot;,<br>                    &quot;internal_key&quot;: &quot;02b54e30939752a0ab9abe9e43a3f57792be47d3ff919383b78df4786cf33c8f53&quot;,<br>                    &quot;taproot_asset_root&quot;: &quot;1699960e4e44a2a0bfca9b8f9b47a35f189abeea5e772713f1d02dace4613178&quot;,<br>                    &quot;merkle_root&quot;: &quot;1699960e4e44a2a0bfca9b8f9b47a35f189abeea5e772713f1d02dace4613178&quot;,<br>                    &quot;tapscript_sibling&quot;: null,<br>                    &quot;num_passive_assets&quot;: 0<br>                },<br>                &quot;script_key&quot;: &quot;02cb68575f784f45a3357204c886340524d51c2cd149ab267de246b5eb5b494b8d&quot;,<br>                &quot;script_key_is_local&quot;: false,<br>                &quot;amount&quot;: &quot;21&quot;,<br>                &quot;new_proof_blob&quot;: &quot;00244251a1f3cfd4a51fd97b2e5c13150bf1ae82af82944cd4898b8f9819df5f84cc000000000150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096e88000000000000000002fd018d02000000000102e7494b164d58fc77efa95f0d27663b6aaf3f5e9433c084a8a9718291aca6afb50000000000ffffffff4251a1f3cfd4a51fd97b2e5c13150bf1ae82af82944cd4898b8f9819df5f84cc00000000000000000003e8030000000000002251209771a17c952030b3590d0e66f43323c6459e7083f3c8d248ef352ecae8d32dd8e8030000000000002251203d55ca36ece1cc057034df880bd8141cd0a61da15dc6e01b812a2dfed5f4cbab8a0a0f0000000000225120b1c9eddddc3abde2a4eef330bfdc150ecd4d462099e00927e024fca55752f0dd024830450221008e25d13e80b5406f8ae8c7f30901787d203ab322ef1603d0755c8526c60460f402204d16168ec8017810dcb2480aae655c1c1578d981caed7fecc8dad461e79dd1de0121032759e7ff68ce4cb95cb2a149b66a2fcccd5f2d5c98a9cff3c5d51d45d9e3acdc01408fbc4e62b8eae348f392616bdb19b5f72ff00281a92ca1e8d8ba039e22baf0dc2558d14d76b5d86d17118c671d6eff6653a31b7b1c7d98b2fc4e7ca544f7c4e90000000003010004fd02a80001000155acdc3a99f245a0b9a5eaabb82fe8b349a5cef59682810eef1c0e3c9a8068aab0000000010b66616e74617379636f696e04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43000000000002010003011506fd021d01fd02190065000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002fd01ae4a0001844dca2fae6df7e1f190133db1d586629db6ab3fba3192fdd3e5b33fd4188848000000000000004fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbffd01600001000155acdc3a99f245a0b9a5eaabb82fe8b349a5cef59682810eef1c0e3c9a8068aab0000000010b66616e74617379636f696e04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43000000000002010003014f06ad01ab00654251a1f3cfd4a51fd97b2e5c13150bf1ae82af82944cd4898b8f9819df5f84cc000000004c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c0257f1c79e28e5d9e31ec2e90eeacb48abc1db4d94db668c2bfd1e6c52d738b826014201407ff1d573b6425966961d370b2ea6b6639739f1cde0400257e4231a29069e0327b2880420a0066d3cefaeeef4c7cae114ee4ce1a0bd163c262546dd50ed11ad5b072828d78daa63b031856f1b77928d8b30341068b86bc18961ecd921d00c1b78ef6000000000000000640802000009210261a4ecd533bdc4fd9cf84f62763da4a4414553149d3f6c7c41a5b57ba4e4fd3008020000092102cb68575f784f45a3357204c886340524d51c2cd149ab267de246b5eb5b494b8d059f000400000001012102b54e30939752a0ab9abe9e43a3f57792be47d3ff919383b78df4786cf33c8f530274004900010001204c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c02220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff06f802c7000400000000012103bf46a593e2c7a1ef99fa07f509c8df0e592eae9e3ff5ccef1bf8ae78674de82d029c007100010001204c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c024a00013b3f4a2cb4f918aa30216a9af65a932080e8b4f57201bd86e99150b188666d76000000000000004fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2e00040000000201210266ade74a22f176a0f511d65bfe797b8b67b8879f112b1a92619fa3cc37b84c940303020101079f000400000000012103bf46a593e2c7a1ef99fa07f509c8df0e592eae9e3ff5ccef1bf8ae78674de82d0274004900010001204c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c02220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff&quot;,<br>                &quot;split_commit_root_hash&quot;: null,<br>                &quot;output_type&quot;: &quot;OUTPUT_TYPE_SIMPLE&quot;<br>            }<br>        ]<br>    }<br>}</pre><p>Polar の画面で [Quick Mine] ボタンを押してブロックを生成し、このトランザクションを確定させる。</p><p>bob-tap で受信したアセットを確認できた。</p><pre>tap@bob-tap:/$ tapcli --tapddir=~/.tapd/ assets list<br>{<br>    &quot;assets&quot;: [<br>        {<br>            &quot;version&quot;: 0,<br>            &quot;asset_genesis&quot;: {<br>                &quot;genesis_point&quot;: &quot;b0aa68809a3c0e1cef0e818296f5cea549b3e82fb8abeaa5b9a045f2993adcac:1&quot;,<br>                &quot;name&quot;: &quot;fantasycoin&quot;,<br>                &quot;meta_hash&quot;: &quot;04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43&quot;,<br>                &quot;asset_id&quot;: &quot;4c4bb0d1f8110f62d7845ab56fe7ac18e793ca9a2eb7d0e2fbd3e3f642ebcf5c&quot;,<br>                &quot;output_index&quot;: 0,<br>                &quot;version&quot;: 0<br>            },<br>            &quot;asset_type&quot;: &quot;NORMAL&quot;,<br>            &quot;amount&quot;: &quot;21&quot;,<br>            &quot;lock_time&quot;: 0,<br>            &quot;relative_lock_time&quot;: 0,<br>            &quot;script_version&quot;: 0,<br>            &quot;script_key&quot;: &quot;02cb68575f784f45a3357204c886340524d51c2cd149ab267de246b5eb5b494b8d&quot;,<br>            &quot;script_key_is_local&quot;: true,<br>            &quot;asset_group&quot;: null,<br>            &quot;chain_anchor&quot;: {<br>                &quot;anchor_tx&quot;: &quot;02000000000102e7494b164d58fc77efa95f0d27663b6aaf3f5e9433c084a8a9718291aca6afb50000000000ffffffff4251a1f3cfd4a51fd97b2e5c13150bf1ae82af82944cd4898b8f9819df5f84cc00000000000000000003e8030000000000002251209771a17c952030b3590d0e66f43323c6459e7083f3c8d248ef352ecae8d32dd8e8030000000000002251203d55ca36ece1cc057034df880bd8141cd0a61da15dc6e01b812a2dfed5f4cbab8a0a0f0000000000225120b1c9eddddc3abde2a4eef330bfdc150ecd4d462099e00927e024fca55752f0dd024830450221008e25d13e80b5406f8ae8c7f30901787d203ab322ef1603d0755c8526c60460f402204d16168ec8017810dcb2480aae655c1c1578d981caed7fecc8dad461e79dd1de0121032759e7ff68ce4cb95cb2a149b66a2fcccd5f2d5c98a9cff3c5d51d45d9e3acdc01408fbc4e62b8eae348f392616bdb19b5f72ff00281a92ca1e8d8ba039e22baf0dc2558d14d76b5d86d17118c671d6eff6653a31b7b1c7d98b2fc4e7ca544f7c4e900000000&quot;,<br>                &quot;anchor_txid&quot;: &quot;cbb051a72fd8c59fb8a24ddc2f800594f1ec78f9f52e2f6a2451708bbfdae9f8&quot;,<br>                &quot;anchor_block_hash&quot;: &quot;2f1e0a2fb871ba9520eb3f1568335084438426cec6a3de002db26ed32565d446&quot;,<br>                &quot;anchor_outpoint&quot;: &quot;cbb051a72fd8c59fb8a24ddc2f800594f1ec78f9f52e2f6a2451708bbfdae9f8:1&quot;,<br>                &quot;internal_key&quot;: &quot;02b54e30939752a0ab9abe9e43a3f57792be47d3ff919383b78df4786cf33c8f53&quot;,<br>                &quot;merkle_root&quot;: &quot;1699960e4e44a2a0bfca9b8f9b47a35f189abeea5e772713f1d02dace4613178&quot;,<br>                &quot;tapscript_sibling&quot;: null<br>            },<br>            &quot;prev_witnesses&quot;: [<br>            ],<br>            &quot;is_spent&quot;: false<br>        }<br>    ]<br>}</pre><h3>「転送証明」の転送</h3><p>以上で全ての手順を確認したが、ひとつ疑問が残る。</p><p>アセットの転送トランザクションの Taproot 出力（anchor_outpoint）には bob が受け取ったアセットのデータが埋め込まれている。</p><p>しかし、bob が自分のアドレスに支払う転送トランザクションを発見しても、Taproot 出力にはアセットデータのハッシュ値が埋め込まれているだけである。それを確認、検証するためにはそれができるだけの pre-image、proof が必要になる。これらのデータをまとめて転送証明と呼ぼう。</p><p>転送証明はどのようにして alice から bob へ渡されるのだろうか？現在の tapd の実装では、<a href="https://github.com/lightninglabs/lightning-node-connect">lightning-node-connect</a> の mailbox という機能を使用して外部のサーバ経由で渡されている。将来的には生成証明と同じく転送証明も Universe を使用して同期されるようになるかもしれない。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9464b00b1246" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nayuta-engineering-blog-ja/taproot-assets-protocol-%E3%82%92%E7%90%86%E8%A7%A3%E3%81%99%E3%82%8B-%E5%AE%9F%E8%B7%B5%E7%B7%A8-2-9464b00b1246">Taproot Assets Protocol を理解する（実践編 #2）</a> was originally published in <a href="https://medium.com/nayuta-engineering-blog-ja">Nayuta エンジニアブログ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UTXO ベースモデルのアセットプロトコルのスケーラビリティ改善手法]]></title>
            <link>https://medium.com/nayuta-engineering-blog-ja/utxo-%E3%83%99%E3%83%BC%E3%82%B9%E3%83%A2%E3%83%87%E3%83%AB%E3%81%AE%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%83%97%E3%83%AD%E3%83%83%E3%83%88%E3%82%B3%E3%83%AB%E3%81%AE%E3%82%B9%E3%82%B1%E3%83%BC%E3%83%A9%E3%83%93%E3%83%AA%E3%83%86%E3%82%A3%E6%94%B9%E5%96%84%E6%89%8B%E6%B3%95-1f4466dcc649?source=rss-ec449712cbf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f4466dcc649</guid>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[stable-coin]]></category>
            <category><![CDATA[lightning-network]]></category>
            <category><![CDATA[talo-protocol]]></category>
            <dc:creator><![CDATA[Hiroki Gondo]]></dc:creator>
            <pubDate>Tue, 16 May 2023 11:40:35 GMT</pubDate>
            <atom:updated>2023-05-19T07:36:36.071Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*6jU8wwLxN_69EnXLJ-BpCg.jpeg" /></figure><p>Bitcoin の上で Bitcoin 以外のアセットのトークンを発行する UTXO ベースモデルのアセットプロトコルの概要を<a href="https://medium.com/nayuta-inc/bitcoin-%E4%B8%8A%E3%81%AE%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%81%AE%E4%BB%95%E7%B5%84%E3%81%BF-4b78638b75c5">この記事</a>で説明した。</p><p>そのとき、特定のアセット UTXO が正しいものであることをチェックするためには、当該 アセット UTXO から、その起源である genesis output （Bitcoin の coinbase トランザクションと同じ働きをする）までの全てのトランザクションが正しく行われたことを検証しなければいけないことを指摘した。</p><p>（Bitcoin と同じく）アセットの量の分割 / 結合が可能な可分トークンの場合、検証しなければいけない転送履歴は準指数関数的に増加すると考えられ、これはアセットプロトコルの重大なスケーラビリティ上の問題となる。ここではこの問題に対するすでに提案されているいくつかの改善手法（案）について列挙する。</p><h4>Lightning Network 対応</h4><p>アセットプロトコルが Lightning Network に対応すれば、channel を開設する Funding Transaction までは上記の検証を行わないといけないが、channel 内のトランザクションについては転送履歴が増加しない。まだ実現されていないが<a href="https://docs.lightning.engineering/the-lightning-network/taro/taro-on-lightning">例えば</a>。</p><h4><a href="https://scalingbitcoin.org/transcript/milan2016/client-side-validation">確率的検証</a>を行う</h4><p>完全なトランザクショングラフを検証するのではなく、一部のみを検証する。残念ながら私はその手法をちゃんと理解していないし、それが実用的なのか理解していない。</p><h4><a href="https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-April/020204.html">不可分トークンにする</a></h4><p>トークンを不可分にすれば転送履歴の増加は線形になり増加は抑えられる。額面が定まっている硬貨や紙幣のようなものである。</p><p>しかし、一回の支払いで額面を満たすため、多くの不可分トークンを転送しなくてはいけないだろう。</p><h4>検証を信頼できる主体に委譲する</h4><p>軽量なウォレットアプリケーションは転送履歴を自分で検証するのをあきらめて、信頼できる外部の主体に委譲する。例えば、当該アセットの UTXO アキュムレータ（<a href="https://github.com/mit-dci/utreexo">utreexo</a> 等）を運用するサーバに、アセット UTXO が正しいか問い合わせる。</p><p>しかし、<a href="https://scalingbitcoin.org/transcript/milan2016/client-side-validation">Client side validation モデル</a>のプロトコルでは、通常二者間のトランザクションの内容は公開されない。サーバはクライアントからトランザクションの証明を収集する必要がある。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f4466dcc649" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nayuta-engineering-blog-ja/utxo-%E3%83%99%E3%83%BC%E3%82%B9%E3%83%A2%E3%83%87%E3%83%AB%E3%81%AE%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%83%97%E3%83%AD%E3%83%83%E3%83%88%E3%82%B3%E3%83%AB%E3%81%AE%E3%82%B9%E3%82%B1%E3%83%BC%E3%83%A9%E3%83%93%E3%83%AA%E3%83%86%E3%82%A3%E6%94%B9%E5%96%84%E6%89%8B%E6%B3%95-1f4466dcc649">UTXO ベースモデルのアセットプロトコルのスケーラビリティ改善手法</a> was originally published in <a href="https://medium.com/nayuta-engineering-blog-ja">Nayuta エンジニアブログ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bitcoin 上のアセットの仕組み]]></title>
            <link>https://medium.com/nayuta-engineering-blog-ja/bitcoin-%E4%B8%8A%E3%81%AE%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%81%AE%E4%BB%95%E7%B5%84%E3%81%BF-4b78638b75c5?source=rss-ec449712cbf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b78638b75c5</guid>
            <category><![CDATA[lightning-network]]></category>
            <category><![CDATA[taro]]></category>
            <category><![CDATA[stable-coin]]></category>
            <dc:creator><![CDATA[Hiroki Gondo]]></dc:creator>
            <pubDate>Mon, 15 May 2023 07:16:52 GMT</pubDate>
            <atom:updated>2024-01-23T04:03:30.293Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bQ8Ccz_C1_94E3GV" /><figcaption>Photo by <a href="https://unsplash.com/@traxer?utm_source=medium&amp;utm_medium=referral">Traxer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Bitcoin の上で Bitcoin 以外のアセットのトークン（例えばステーブルコイン）を表現するアセットプロトコルがいくつかある（Open Asset Protocol、Omni、Counterparty、RGB、Taproot Assets Protocol 他）。これらがどのような仕組みなのか説明する。</p><h3>シンプルなアセットプロトコル</h3><p>ここではとてもシンプルなアセットプロトコルを再発明する。発行者はアセットを発行する。アセットの所有者は別の人に転送できる。アセットがインフレしたり二重支払いができてはいけない。</p><h4>アセットの発行</h4><p>アセットの発行は Bitcoin トランザクション（以下 Bitcoin Tx） を発行することによって行われる。既存の Bitcoin UTXO TXID_A:0（トランザクション TXID_A の 0 番目の出力を表す）を消費する Bitcoin Tx TXID_B を発行する。TXID_B の新たな UTXO（TXID_B:0）には少量の Bitcoin が含まれる。これは Bitcoin Tx の有効な出力を生成するだけのためのものである。それとは別にこの UTXO にはアセットが 100 単位組み込まれている。</p><pre>TXID_A  :0 (genesis point) -&gt;<br>        :1<br><br>TXID_B  :0 asset_id=XXX, amt=100<br>        :1</pre><p>ここでは UTXO にアセットをどのように組み込むか定義しない（例：<a href="https://github.com/OpenAssets/open-assets-protocol/blob/master/specification.mediawiki#marker-output">OP_RETURN</a>、<a href="https://github.com/Roasbeef/bips/blob/bip-taro/bip-taro.mediawiki#taro-asset-trees">Taproot</a>）。ともかく、UTXO になにか余分なデータを追加することになる。またそのことが Bitcoin Tx の検証には影響しない（検証のルールに抵触しない）ようにする。</p><p>このシンプルなプロトコルでは UTXO にアセットの ID と 量の情報しか載せていない。それでもこのアセットの発行をグローバルに一意に識別することができる。それはグローバルで一意な TXID_A:0（アセットの genesis point）を消費することによって発行されたからである。</p><p>アセット ID は genesis point から導出するように定義するとグローバルに一意であることが保証される。</p><pre>asset_id := sha256(genesis point)</pre><h4>アセットの転送</h4><p>アセットをどこかへ転送する。</p><pre>TXID_B  :0 asset_id=XXX,　amt=100 -&gt;<br>        :1<br><br>TXID_C  :0 asset_id=XXX, amt=100<br>        :1</pre><p>アセットの生成、転送は Bitcoin Tx の発行によって行われるので、UTXO の所有者とアセットの所有者は同じである。</p><p>次に、同じ種類のアセットを分割して送ったり、結合したりできるようにする。つまり Bitcoin と同じことができるようにする。</p><p>アセットの分割。</p><pre>TXID_C  :0 asset_id=XXX, amt=100 -&gt;<br>        :1<br><br>TXID_D  :0 asset_id=XXX, amt=21<br>        :1 asset_id=XXX, amt=79<br>        :2</pre><p>そして結合。</p><pre>TXID_D  :0 asset_id=XXX, amt=21 -&gt;<br>        :1 asset_id=XXX, amt=79 -&gt;<br>        :2<br><br>TXID_E  :0 asset_id=XXX, amt=100<br>        :1</pre><h4>アセットの検証</h4><p>これでアセットの分割と結合ができるようになった。しかし、このプロトコルを実用化するためには解決しなければならない問題がある。次のケースを考えてみる。</p><pre>TXID_D  :0 asset_id=XXX, amt=21 -&gt;<br>        :1 asset_id=XXX, amt=79 -&gt;<br>        :2<br><br>TXID_E2 :0 asset_id=XXX, amt=10<br>        :1 asset_id=XXX, amt=90<br>        :2</pre><p>これは問題ない。アセットの分割と結合が正しく行われた。TXID_D と TXID_E2 それぞれに組みこまれたアセットの総量はともに 100 で変わらない。次のトランザクションは問題がある。</p><pre>TXID_D  :0 asset_id=XXX, amt=21 -&gt;<br>        :1 asset_id=XXX, amt=79 -&gt;<br>        :2<br><br>TXID_E3 :0 asset_id=XXX, amt=10<br>        :1 asset_id=XXX, amt=100<br>        :2</pre><p>総量 110 が入力を上回った。</p><pre>TXID_D  :0 asset_id=XXX, amt=21 -&gt;<br>        :1 asset_id=XXX, amt=79 -&gt;<br>        :2<br><br>TXID_E4 :0 asset_id=XXX, amt=10<br>        :1 asset_id=XXX, amt=90<br>        :2 asset_id=XXX, amt=90</pre><p>総量 190 が入力を上回った。出力 :2 にアセットが含まれていたため。</p><p>アセットの受信者、例えば TXID_E:0 の受信者は、なにをチェックする必要があるか？</p><ul><li>自身へ割り当てられた出力（TXID_E:0）に約束の量（10）が含まれている。</li><li>出力のアセット総量が入力のアセット総量を超えていない（アセットがインフレしていない）。そのためには自身の管理下にない入出力に含まれるアセットの量についてもチェックできなければならない。</li></ul><h4>アセットの出自の検証</h4><p>もう一つ重要なチェックが必要である。入力されたアセットの UTXO（TXID_D に含まれているもの） はそもそも正しいものなのだろうか？従って、以下をチェックする。</p><ul><li>入力されたアセットの UTXO が、目的のアセットのものであること。それは自己申告された asset_id をチェックするだけでは十分ではない。その転送履歴を遡ると目的の genesis point に行き着くことをチェックする必要がある。</li><li>入力されたアセットの UTXO の転送履歴に含まれる全ての Bitcoin Tx が正しいものであること。つまり、全ての地点において上記のアセット転送前後の総量チェックをクリアしていること。</li></ul><p>不可分トークン（硬貨、紙幣など）の場合、転送履歴は genesis point から一直線である。新しい転送が発生した場合、転送履歴にチェックしなければいけない最新の Bitcoin Tx が一つ追加される。</p><p>今回のケースのような、可分トークン（Bitcoin、ステーブルコインなど）の場合だいぶ複雑になる。転送履歴は一直線にはならず分割、結合を含んだ複雑なトランザクショングラフになる。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Tjk7BBhCSYGFar6dMlh-g.png" /></figure><p>このようなアセットを含む Bitcoin Tx のトランザクショングラフがある場合、Tx A ではその祖先の青色のトランザクションを全てチェックする必要がある。Tx B ではそれに加えて赤色のトランザクションを全てチェックする必要がある。履歴は準指数関数的に増加する。これはアセットプロトコルのスケーラビリティについて大きな課題である。</p><p>上記のスケーラビリティの問題について、すでに提案されているいくつかの改善案を<a href="https://medium.com/nayuta-inc/utxo-%E3%83%99%E3%83%BC%E3%82%B9%E3%83%A2%E3%83%87%E3%83%AB%E3%81%AE%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%83%97%E3%83%AD%E3%83%83%E3%83%88%E3%82%B3%E3%83%AB%E3%81%AE%E3%82%B9%E3%82%B1%E3%83%BC%E3%83%A9%E3%83%93%E3%83%AA%E3%83%86%E3%82%A3%E6%94%B9%E5%96%84%E6%89%8B%E6%B3%95-1f4466dcc649">別の記事</a>で挙げる。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b78638b75c5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nayuta-engineering-blog-ja/bitcoin-%E4%B8%8A%E3%81%AE%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%81%AE%E4%BB%95%E7%B5%84%E3%81%BF-4b78638b75c5">Bitcoin 上のアセットの仕組み</a> was originally published in <a href="https://medium.com/nayuta-engineering-blog-ja">Nayuta エンジニアブログ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taproot Assets Protocol を理解する（実践編 #1）]]></title>
            <link>https://medium.com/nayuta-engineering-blog-ja/taro-%E3%83%97%E3%83%AD%E3%83%88%E3%82%B3%E3%83%AB%E3%82%92%E7%90%86%E8%A7%A3%E3%81%99%E3%82%8B-%E5%AE%9F%E8%B7%B5%E7%B7%A8-8c9574856c79?source=rss-ec449712cbf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c9574856c79</guid>
            <category><![CDATA[lightning-network]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[taro]]></category>
            <dc:creator><![CDATA[Hiroki Gondo]]></dc:creator>
            <pubDate>Mon, 08 May 2023 14:07:43 GMT</pubDate>
            <atom:updated>2023-05-29T02:26:35.620Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*6jU8wwLxN_69EnXLJ-BpCg.jpeg" /></figure><p>Taproot Assets Protocol（旧 Taro、以下 TAP と称す）は Bitcoin ネットワークのオーバレイネットワークで Bitcoin とは異なるアセットを表現するためのプロトコルである。TAP の仕様の詳細については、<a href="https://medium.com/nayuta-inc/taro-ed6b93b09a75">以前の記事</a>をご覧いただきたい。</p><p>この記事では実際に TAP デーモン（<a href="https://github.com/lightninglabs/taproot-assets">tapd</a>）を実行し、Taproot Asset の生成と転送を行うことにより仕様の理解を深めることを目的にしている。基本的に Lightning Labs が開発している <a href="https://github.com/lightninglabs/taproot-assets#initialization">tapd 実装の github のフロントページ</a> の手順で行うが、より詳細な説明や注意点を加えている。</p><p><strong>注意！</strong>完全に tapd の実装を確認したわけではないのでこの記事の一部に推測を含みます。内容に誤りがある可能性があります :)</p><h3>1. lnd を動かす</h3><p>tapd を動かすためには、同じく Lightning Labs が開発している Lightning Network デーモンの <a href="https://github.com/lightningnetwork/lnd">lnd</a> が必要になる。TAP のトランザクション発行は Bitcoin の 1st layer 上で行われるので Lightning Network（2nd layer） の機能は必要ないが（TAP の Lightning Network 対応は最も重要なマイルストーンであろう）、lnd を介して Bitcoin の 1st layer にアクセスする。ここでは Bitcoin のテストネットを使用する。</p><p>私のテスト環境は以下の通り。</p><pre>$ sw_vers<br>ProductName:  macOS<br>ProductVersion:  13.2.1<br>BuildVersion:  22D68<br>$ go version<br>go version go1.20.3 darwin/amd64</pre><p>lnd をインストールし実行する。</p><pre>$ git clone https://github.com/lightningnetwork/lnd.git<br>$ cd lnd<br>$ git log | head -1<br>commit 8c58730c34022cd9f3c8c7c408c0783a751f2404<br>$ make install tags=&quot;signrpc walletrpc chainrpc invoicesrpc&quot;<br>$ lnd -V<br>lnd version 0.16.99-beta commit=v0.16.0-beta-332-g8c58730c3<br>$ lnd --bitcoin.active --bitcoin.testnet --bitcoin.node=neutrino</pre><p>別のターミナルから専用のコマンドラインツール（lncli）で wallet を作成する。</p><pre>$ lncli -network=testnet create<br>Input wallet password: <br>Confirm password: <br><br>Do you have an existing cipher seed mnemonic or extended master root key you want to use?<br>Enter &#39;y&#39; to use an existing cipher seed mnemonic, &#39;x&#39; to use an extended master root key <br>or &#39;n&#39; to create a new seed (Enter y/x/n): n<br><br>Your cipher seed can optionally be encrypted.<br>Input your passphrase if you wish to encrypt it (or press enter to proceed without a cipher seed passphrase): <br><br>Generating fresh cipher seed...<br><br>…<br><br>lnd successfully initialized!</pre><p>lnd を外部（tapd）からアクセスするためには wallet が unlock 状態でなければならない。wallet 作成直後は wallet が unlock 状態になっているが、もし lnd を再起動した場合には wallet を unlock する必要がある。</p><pre>$ lncli --network=testnet unlock<br>Input wallet password: <br>lnd successfully unlocked!</pre><p>チェーンの同期にしばらく時間が掛かるため状態が SERVER_ACTIVE になるまで待つ。これで lnd の準備ができた。</p><pre>$ lncli state<br>{<br>    &quot;state&quot;: &quot;RPC_ACTIVE&quot;<br>}<br><br>…<br><br><br>$ lncli state<br>{<br>    &quot;state&quot;: &quot;SERVER_ACTIVE&quot;<br>}<br>$ lncli --network=testnet getinfo<br>{<br>    …<br>    &quot;block_height&quot;: 2431595,<br>    …<br>    &quot;synced_to_chain&quot;: true,</pre><h3>2. tapd を動かす</h3><p>tapd をインストールし、実行する。</p><pre>$ git clone https://github.com/lightninglabs/taproot-assets.git<br>$ cd taproot-assets<br>$ git log | head -1<br>commit 1a3f86c09ac044ff3b9e27cf90a314eecb2e0625<br>$ make install<br>$ tapd --network=testnet</pre><h3>3. Taproot Asset を発行する</h3><p>別のターミナルから専用のコマンドラインツール（tapcli）でアセットを発行する。</p><pre>$ tapcli assets mint --type normal --name fantasycoin --supply 100 --meta_bytes &quot;fantastic money&quot;<br>{<br>    &quot;batch_key&quot;: &quot;0326764481f0945fea8cc696a52753d30409026d7dfd5652beb4904dfc44c238d1&quot;<br>}<br>$ tapcli assets mint finalize<br>{<br>    &quot;batch_key&quot;: &quot;0326764481f0945fea8cc696a52753d30409026d7dfd5652beb4904dfc44c238d1&quot;<br>}</pre><p>tapd でエラー発生！</p><pre>2023-05-23 17:39:55.398 [ERR] GRDN: unable to advance state machine: unable to advance state machine: unable to fund psbt: unable to fund psbt: rpc error: code = Unknown desc = wallet couldn&#39;t fund PSBT: error creating funding TX: insufficient funds available to construct transaction</pre><p>アセットを発行するためには下層の Bitcoin トランザクションを発行する必要がある。そのためには lnd の wallet にある程度の量の Bitcoin が必要になる。</p><p>lnd でアドレスを発行し、「どこか」からか「十分な量」の Bitcoin を入金する。。</p><pre>$ lncli -network=testnet newaddress p2tr<br>{<br>    &quot;address&quot;:  &quot;tb1pvs0jjwxal4deezmvc0zk7w89n3d44m6f4a3fn3xfxne7as7a9qhq86gj0v&quot;<br>}</pre><p>Bitcoin（Testnet）は <a href="https://bitcoinfaucet.uo1.net/">Bitcoin Testnet Faucet</a> などの faucet から無料で貰える。アセットを含んだ Bitcoin トランザクションを発行するためには（現在の tapd の実装では）1000 sats の出力が必要になるが、トランザクション手数料がその 10 倍以上必要になる場合がある。</p><p>このぐらいの量があれば十分だが、集めるのは結構大変だろう ;(</p><pre>$ lncli -network=testnet walletbalance<br>{<br>    &quot;total_balance&quot;:  &quot;100000&quot;,<br>    ...<br>}</pre><p>tapd を再起動するとアセットがリストに表示される（まだ発行は完了していない）。</p><pre>$ tapcli assets list<br>{<br>    &quot;assets&quot;: [<br>        {<br>            &quot;version&quot;: 0,<br>            &quot;asset_genesis&quot;: {<br>                &quot;genesis_point&quot;: &quot;ba779153a792a1d49433fd18e56311f8d212992e7d1405cb14af8dffb34e88ce:0&quot;,<br>                &quot;name&quot;: &quot;fantasycoin&quot;,<br>                &quot;meta_hash&quot;: &quot;04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43&quot;,<br>                &quot;asset_id&quot;: &quot;20cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874&quot;,<br>                &quot;output_index&quot;: 0,<br>                &quot;version&quot;: 0<br>            },<br>            &quot;asset_type&quot;: &quot;NORMAL&quot;,<br>            &quot;amount&quot;: &quot;100&quot;,<br>            &quot;lock_time&quot;: 0,<br>            &quot;relative_lock_time&quot;: 0,<br>            &quot;script_version&quot;: 0,<br>            &quot;script_key&quot;: &quot;02b4c71447e74672f8cd5b50a6b430fc73b3caff7866dc905a502fe8adefad3b31&quot;,<br>            &quot;script_key_is_local&quot;: true,<br>            &quot;asset_group&quot;: null,<br>            &quot;chain_anchor&quot;: {<br>                &quot;anchor_tx&quot;: &quot;02000000000101ce884eb3ff8daf14cb05147d2e9912d2f81163e518fd3394d4a192a7539177ba0000000000ffffffff02e8030000000000002251203ad594d71881fe6b0e35d2e6e40dd9ee67eac616ee38e65aff7fe7e7283af03372640100000000002251206e83207da3b36b5f8e84a55171e2ac6f21d12c5eb0384a157a9bf927fd88bc6401409722a654cd08582fe39fcbe52be917b2bcdf281ad5244bf058562cea07155a7e75ee68dc4be21842296392c22cc7580a6e118d9b38944014667e69455efe10f200000000&quot;,<br>                &quot;anchor_txid&quot;: &quot;ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356&quot;,<br>                &quot;anchor_block_hash&quot;: &quot;0000000000000000000000000000000000000000000000000000000000000000&quot;,<br>                &quot;anchor_outpoint&quot;: &quot;ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356:0&quot;,<br>                &quot;internal_key&quot;: &quot;03d9f42daae1b7832d77d3ec83ddbb62e71266f6aedf6bcceb944e9672177c9301&quot;,<br>                &quot;merkle_root&quot;: &quot;634ff6d86b8889f119f505a9bcba38fe4c6bda4b5a40a439fce37184badff63f&quot;,<br>                &quot;tapscript_sibling&quot;: null<br>            },<br>            &quot;prev_witnesses&quot;: [<br>            ],<br>            &quot;is_spent&quot;: false<br>        }<br>    ]<br>}</pre><p>TAP の仕様を理解していれば、ここに表示されている要素のほとんどを理解することができるだろう。</p><p>このアセット発行で、消費された Bitcoin UTXO<br><a href="https://mempool.space/testnet/tx/ba779153a792a1d49433fd18e56311f8d212992e7d1405cb14af8dffb34e88ce">ba779153a792a1d49433fd18e56311f8d212992e7d1405cb14af8dffb34e88ce</a>:0<br>が、当該アセットを一意に識別するための genesis_point となる。</p><p>これを消費した Bitcoin トランザクション<br><a href="https://mempool.space/testnet/tx/ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356">ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356</a><br>の新たな Bitcoin UTXO（anchor_outpoint）に発行されたアセットの UTXO が含まれる（アンカリングされている）。</p><p>このトランザクションがチェーン上で確認されるとアセットの発行が完了する。</p><h3>4. TAP Asset を転送する</h3><p>今回は送受信側いずれも同じ lnd / tapd を使用するので自分で自分に送ることになる。</p><p>先ほどの tapcli assets list の結果に含まれる asset_id を指定してアセットを 21 単位受信するためのアドレスを生成する。</p><pre>$ tapcli addrs new --asset_id 20cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874 --amt 21<br>{<br>    &quot;encoded&quot;: &quot;taptb1qqqsqq3qyr8vmdnzvuzm7f4dqdsgfa6zxzpdkcg57r0ggprwhuhgfa599p6qgggzy56hls2gc3qlh4w9affnl4krx6rxj7t8588ccjfk9pug556lgv7qvggr8epd00wrc5tpctwygpn8kr60efxy5lfj6yl04sf2wxv5v5dsfr8qsqg4nd4u85&quot;,<br>    &quot;asset_id&quot;: &quot;20cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874&quot;,<br>    &quot;asset_type&quot;: &quot;NORMAL&quot;,<br>    &quot;amount&quot;: &quot;21&quot;,<br>    &quot;group_key&quot;: null,<br>    &quot;script_key&quot;: &quot;0225357fc148c441fbd5c5ea533fd6c33686697967a1cf8c493628788a535f433c&quot;,<br>    &quot;internal_key&quot;: &quot;033e42d7bdc3c5161c2dc440667b0f4fca4c4a7d32d13efac12a71994651b048ce&quot;,<br>    &quot;tapscript_sibling&quot;: null,<br>    &quot;taproot_output_key&quot;: &quot;be0db94139918a132eb4821f834efdec4634261997b57d964753d60923be9dee&quot;<br>}</pre><p>アドレスを指定してアセットを送る。</p><pre>$ tapcli assets send --addr taptb1qqqsqq3qyr8vmdnzvuzm7f4dqdsgfa6zxzpdkcg57r0ggprwhuhgfa599p6qgggzy56hls2gc3qlh4w9affnl4krx6rxj7t8588ccjfk9pug556lgv7qvggr8epd00wrc5tpctwygpn8kr60efxy5lfj6yl04sf2wxv5v5dsfr8qsqg4nd4u85<br>{<br>    &quot;transfer&quot;: {<br>        &quot;transfer_timestamp&quot;: &quot;1684836471&quot;,<br>        &quot;anchor_tx_hash&quot;: &quot;e4efa1c3272009193e961f383b29c1bc84cf6ed8eb0806bf94056a41387835b3&quot;,<br>        &quot;anchor_tx_height_hint&quot;: 2434958,<br>        &quot;anchor_tx_chain_fees&quot;: &quot;12725&quot;,<br>        &quot;inputs&quot;: [<br>            {<br>                &quot;anchor_point&quot;: &quot;ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356:0&quot;,<br>                &quot;asset_id&quot;: &quot;20cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874&quot;,<br>                &quot;script_key&quot;: &quot;02b4c71447e74672f8cd5b50a6b430fc73b3caff7866dc905a502fe8adefad3b31&quot;,<br>                &quot;amount&quot;: &quot;100&quot;<br>            }<br>        ],<br>        &quot;outputs&quot;: [<br>            {<br>                &quot;anchor&quot;: {<br>                    &quot;outpoint&quot;: &quot;b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4:0&quot;,<br>                    &quot;value&quot;: &quot;1000&quot;,<br>                    &quot;internal_key&quot;: &quot;024a3cb06616bb1545d3a25417a3fa5ccc70c5fbe9ceed8666410ed83745bbe968&quot;,<br>                    &quot;taproot_asset_root&quot;: &quot;42ac8c2338032a0b0ea9b96916da31a8798eef30cbef2a80b8c6d60249e4698d&quot;,<br>                    &quot;merkle_root&quot;: &quot;42ac8c2338032a0b0ea9b96916da31a8798eef30cbef2a80b8c6d60249e4698d&quot;,<br>                    &quot;tapscript_sibling&quot;: null,<br>                    &quot;num_passive_assets&quot;: 0<br>                },<br>                &quot;script_key&quot;: &quot;02258420ed4cf219965908102c6f8498da274c251a3463880763ba118c2d946c62&quot;,<br>                &quot;script_key_is_local&quot;: true,<br>                &quot;amount&quot;: &quot;79&quot;,<br>                &quot;new_proof_blob&quot;: &quot;00245663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb000000000150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096e88000000000000000002fd0163020000000001025663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb0100000000ffffffff5663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb00000000000000000003e803000000000000225120f036a7c3d36d4459fc4566875b255b80177fee26ea8cb27a1387e38dedee46f8e803000000000000225120be0db94139918a132eb4821f834efdec4634261997b57d964753d60923be9deed52e010000000000225120a0330b1c1bec571ac4e9004cae724380b3acf96a2f88332f4d6bd7136518932c0140db4f7d819f7fe90677c6e0d8355fe2b41f123934a5fb34117377841d3f1f305a82fbe7feea5fb51c2b8f598934027f455fb5d5f12ec6ba5b4538ef8cead916d801407fa2c953e2cbfd8ab9813b06f11919bfc3fba51ef9bac960ae522f9ea2b2f3acfd976dcc31bb49b9c4dc906952ddf7b79c7467a0c1f22ed1d845794adbe558e50000000003010004fd01600001000155ce884eb3ff8daf14cb05147d2e9912d2f81163e518fd3394d4a192a7539177ba000000000b66616e74617379636f696e04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43000000000002010003014f06ad01ab00655663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb0000000020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f685287402b4c71447e74672f8cd5b50a6b430fc73b3caff7866dc905a502fe8adefad3b3101420140013a3f644a0428e3713e8f325b31734ce071fee2a55e3a64a4debd4ef384ba5b340f6b3b9163c5ae37f97aa3a287fd4f1850a3f2a08166568d1a24b2fbda4ece0728fdee0a27d560e5223b5e06b7a61d3df5b405942d21cf887fc96b16088874546a000000000000006408020000092102258420ed4cf219965908102c6f8498da274c251a3463880763ba118c2d946c62059f0004000000000121024a3cb06616bb1545d3a25417a3fa5ccc70c5fbe9ceed8666410ed83745bbe96802740049000100012020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f685287402220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff06f802c70004000000010121033e42d7bdc3c5161c2dc440667b0f4fca4c4a7d32d13efac12a71994651b048ce029c0071000100012020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874024a0001c37d7cb2bb159ad5843a204c210782c937765e0c54e1ac431f5519d0b02b95410000000000000015ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2e0004000000020121026c93d33b5f69084411ffc540db8c0135300fdb4cdae2e5cd6ad1efd27a9d8cc20303020101&quot;,<br>                &quot;split_commit_root_hash&quot;: &quot;fdee0a27d560e5223b5e06b7a61d3df5b405942d21cf887fc96b16088874546a&quot;,<br>                &quot;output_type&quot;: &quot;OUTPUT_TYPE_SPLIT_ROOT&quot;<br>            },<br>            {<br>                &quot;anchor&quot;: {<br>                    &quot;outpoint&quot;: &quot;b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4:1&quot;,<br>                    &quot;value&quot;: &quot;1000&quot;,<br>                    &quot;internal_key&quot;: &quot;033e42d7bdc3c5161c2dc440667b0f4fca4c4a7d32d13efac12a71994651b048ce&quot;,<br>                    &quot;taproot_asset_root&quot;: &quot;8aada842f74c2b11e9b5a0a716baa0c453855ab6ea316222a8a28e7e79506f41&quot;,<br>                    &quot;merkle_root&quot;: &quot;8aada842f74c2b11e9b5a0a716baa0c453855ab6ea316222a8a28e7e79506f41&quot;,<br>                    &quot;tapscript_sibling&quot;: null,<br>                    &quot;num_passive_assets&quot;: 0<br>                },<br>                &quot;script_key&quot;: &quot;0225357fc148c441fbd5c5ea533fd6c33686697967a1cf8c493628788a535f433c&quot;,<br>                &quot;script_key_is_local&quot;: true,<br>                &quot;amount&quot;: &quot;21&quot;,<br>                &quot;new_proof_blob&quot;: &quot;00245663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb000000000150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096e88000000000000000002fd0163020000000001025663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb0100000000ffffffff5663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb00000000000000000003e803000000000000225120f036a7c3d36d4459fc4566875b255b80177fee26ea8cb27a1387e38dedee46f8e803000000000000225120be0db94139918a132eb4821f834efdec4634261997b57d964753d60923be9deed52e010000000000225120a0330b1c1bec571ac4e9004cae724380b3acf96a2f88332f4d6bd7136518932c0140db4f7d819f7fe90677c6e0d8355fe2b41f123934a5fb34117377841d3f1f305a82fbe7feea5fb51c2b8f598934027f455fb5d5f12ec6ba5b4538ef8cead916d801407fa2c953e2cbfd8ab9813b06f11919bfc3fba51ef9bac960ae522f9ea2b2f3acfd976dcc31bb49b9c4dc906952ddf7b79c7467a0c1f22ed1d845794adbe558e50000000003010004fd02a80001000155ce884eb3ff8daf14cb05147d2e9912d2f81163e518fd3394d4a192a7539177ba000000000b66616e74617379636f696e04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43000000000002010003011506fd021d01fd02190065000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002fd01ae4a00014d1b83c6f29417ec329b91f9cc95cb38facb112bf1d12d4ca3c45d5cd3765857000000000000004fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffd01600001000155ce884eb3ff8daf14cb05147d2e9912d2f81163e518fd3394d4a192a7539177ba000000000b66616e74617379636f696e04e552053fd4c8e2c01bc14cb9a0ce00f07d4ffdffff68fe455c70b934b22a43000000000002010003014f06ad01ab00655663d6bf6a1de069c4562620fa23523cc99c50a0431eed91d199fa0db63fe7eb0000000020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f685287402b4c71447e74672f8cd5b50a6b430fc73b3caff7866dc905a502fe8adefad3b3101420140013a3f644a0428e3713e8f325b31734ce071fee2a55e3a64a4debd4ef384ba5b340f6b3b9163c5ae37f97aa3a287fd4f1850a3f2a08166568d1a24b2fbda4ece0728fdee0a27d560e5223b5e06b7a61d3df5b405942d21cf887fc96b16088874546a000000000000006408020000092102258420ed4cf219965908102c6f8498da274c251a3463880763ba118c2d946c620802000009210225357fc148c441fbd5c5ea533fd6c33686697967a1cf8c493628788a535f433c059f0004000000010121033e42d7bdc3c5161c2dc440667b0f4fca4c4a7d32d13efac12a71994651b048ce02740049000100012020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f685287402220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff06f802c70004000000000121024a3cb06616bb1545d3a25417a3fa5ccc70c5fbe9ceed8666410ed83745bbe968029c0071000100012020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f6852874024a0001979a9f1a4fc2545215daab7876c5e47907a9ff6ed4cd0ca7dcedb6cf3eafc50c000000000000004fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2e0004000000020121026c93d33b5f69084411ffc540db8c0135300fdb4cdae2e5cd6ad1efd27a9d8cc20303020101079f0004000000000121024a3cb06616bb1545d3a25417a3fa5ccc70c5fbe9ceed8666410ed83745bbe96802740049000100012020cecdb6626705bf26ad036084f7423082db6114f0de84046ebf2e84f685287402220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff012700010001220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff&quot;,<br>                &quot;split_commit_root_hash&quot;: null,<br>                &quot;output_type&quot;: &quot;OUTPUT_TYPE_SIMPLE&quot;<br>            }<br>        ]<br>    }<br>}</pre><p>生成されたアセット（100 単位）を含む先ほどの Bitcoin UTXO<br><a href="https://mempool.space/testnet/tx/ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356">ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356</a>:0<br>を消費する新たな Bitcoin トランザクション<br><a href="https://mempool.space/testnet/tx/b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4">b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4</a><br>が発行された。</p><p>最後にBitcoin トランザクションとその UTXO、TAP Asset の UTXO の変化をまとめる。アセットは転送されても目減りせず転送前後で総量が維持される。Bitcoin（sats）はトランザクション手数料の分目減りしていく。</p><ul><li><a href="https://mempool.space/testnet/tx/ba779153a792a1d49433fd18e56311f8d212992e7d1405cb14af8dffb34e88ce">ba779153a792a1d49433fd18e56311f8d212992e7d1405cb14af8dffb34e88ce</a><br>:0 genesis_point（100000 sats）<br>:1 Bitcoin のお釣り出力。（145788 sats）</li><li><a href="https://mempool.space/testnet/tx/ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356">ebe73fb60dfa99d191ed1e43a0509cc93c5223fa202656c469e01d6abfd66356</a><br>:0 新規に生成されたアセット 100 単位を含む（1000 sats）<br>:1 Bitcoin のお釣り出力。アセットは含まれない（91250 sats）</li><li><a href="https://mempool.space/testnet/tx/b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4">b3357838416a0594bf0608ebd86ecf84bcc1293b381f963e19092027c3a1efe4</a><br>:0 お釣りのアセット 79 単位を含む（1000 sats）<br>:1 転送したアセット 21 単位を含む（1000 sats）<br>:2 Bitcoin のお釣り出力。アセットは含まれない（77525 sats）</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c9574856c79" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nayuta-engineering-blog-ja/taro-%E3%83%97%E3%83%AD%E3%83%88%E3%82%B3%E3%83%AB%E3%82%92%E7%90%86%E8%A7%A3%E3%81%99%E3%82%8B-%E5%AE%9F%E8%B7%B5%E7%B7%A8-8c9574856c79">Taproot Assets Protocol を理解する（実践編 #1）</a> was originally published in <a href="https://medium.com/nayuta-engineering-blog-ja">Nayuta エンジニアブログ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SSI を実現する技術]]></title>
            <link>https://medium.com/nayuta-engineering-blog-ja/ssi-%E3%82%92%E5%AE%9F%E7%8F%BE%E3%81%99%E3%82%8B%E6%8A%80%E8%A1%93-d38c5416713?source=rss-ec449712cbf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d38c5416713</guid>
            <category><![CDATA[verifiable-credentials]]></category>
            <category><![CDATA[decentralized-identity]]></category>
            <category><![CDATA[web5]]></category>
            <category><![CDATA[self-sovereign-identity]]></category>
            <dc:creator><![CDATA[Hiroki Gondo]]></dc:creator>
            <pubDate>Thu, 17 Nov 2022 10:26:56 GMT</pubDate>
            <atom:updated>2022-11-22T02:46:41.858Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*GEBmDzb1-0799gYrT3B65Q.png" /></figure><p><a href="https://en.wikipedia.org/wiki/Self-sovereign_identity">Self-sovereign identity</a>（SSI）は、個人が自身の ID とデータ（属性データ（アイデンティティ）、その他のデータ）を管理できるようにするための技術である。<a href="https://www.w3.org/TR/did-core/">Decentralized Identifier</a>（DID）と <a href="https://www.w3.org/TR/vc-data-model/">Verifiable Credential</a>（VC）は SSI を実現するための技術で、W3C で規格化されている。</p><h3>DID</h3><p>個人は DID とそれに紐づく DID Document を生成する。DID Document には、公開鍵やその使用目的、サービスエンドポイントなどが記載される。当該 ID に関わる操作は秘密鍵を知っている個人が証明を作成することにより承認される。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WSy9KKvXaqEOvLYIlQQ-tA.png" /><figcaption>DID の例</figcaption></figure><pre>// DID Document の例<br>{<br>  &quot;@context&quot;: [<br>    &quot;https://www.w3.org/ns/did/v1&quot;,<br>    &quot;https://w3id.org/security/suites/ed25519-2020/v1&quot;<br>  ]<br>  &quot;id&quot;: &quot;did:example:123456789abcdefghi&quot;,<br>  &quot;authentication&quot;: [{ // 使用目的<br>    &quot;id&quot;: &quot;did:example:123456789abcdefghi#keys-1&quot;,<br>    &quot;type&quot;: &quot;Ed25519VerificationKey2020&quot;,<br>    &quot;controller&quot;: &quot;did:example:123456789abcdefghi&quot;,<br>    &quot;publicKeyMultibase&quot;: &quot;zH3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV&quot; // 公開鍵<br>  }]<br>  &quot;service&quot;: [{ // サービス<br>    &quot;id&quot;:&quot;#dwn&quot;,<br>    &quot;type&quot;: &quot;DecentralizedWebNode&quot;,<br>    &quot;serviceEndpoint&quot;: {<br>      &quot;nodes&quot;: [&quot;https://dwn.example.com&quot;, &quot;https://example.org/dwn&quot;]<br>    }<br>  }]<br>}</pre><p>DID と DID Document は一般に公開される。任意の DID から DID Document を求めることを解決という。DID の規格（DID Core）では DID の生成および解決についての汎用的な枠組みのみが定義されており、それを実現する具体的な方法（DID Method）は定義されていない。</p><h4>Sidetree/ION</h4><p>DID Method の一つに <a href="https://github.com/decentralized-identity/ion">ION</a>（did:ion）がある。これは一般的な分散型台帳を利用した <a href="https://identity.foundation/sidetree/spec/">Sidetree</a> プロトコルを、Bitcoin 上に実現したものである。</p><h3>VC</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Kmy2h4EpVti3NruI7K7sQ.png" /></figure><p>ある個人（Holder）の資格情報を、他の主体（Issuer）が保証するために VC を発行する。VC は、Issuer の DID に紐づいた秘密鍵で署名される。Holder から当該 VC を受け取った第三者（Verifer）は、当該資格情報が Issuer から保証されていることを検証することができる。</p><h3>DID の考慮事項</h3><p>DID を使用する際に様々なセキュリティ、プライバシー上の考慮事項がある。</p><ul><li><a href="https://www.w3.org/TR/did-core/#security-considerations">https://www.w3.org/TR/did-core/#security-considerations</a></li><li><a href="https://www.w3.org/TR/did-core/#privacy-considerations">https://www.w3.org/TR/did-core/#privacy-considerations</a></li></ul><h4>DID Method の トラストレス性と分散性</h4><p>使用する DID Method において、トラストレスに、グローバルで一意な DID が生成され、DID Document を解決できないといけない。また、DID Method の実装が規格通りであることを使用者が確認できないといけない。</p><p>DID Method が特定のステークホルダーによって毀損されないために、DID Method の運用や規格策定プロセスは十分に分散化されていないといけない。<a href="https://www.w3.org/TR/did-rubric/">DID Method Rubric</a> は DID Method の分散性評価レポートを作成するための基準である。例えば、<a href="https://didevaluations.com/ion/2022-03-01">ION についての評価レポート</a>がここにある。</p><h4>プライバシー</h4><p>DID Document には、個人情報やそれを推測できるデータを含めてはならない。特にサービスエンドポイントの URL が、既存のサービスに依存して、個人情報を推測できる表現になっていてはいけない（例えば URL にアカウント名や居住地が含まれる）。</p><p>個人が複数の DID を管理している場合、それらを関連付けることができるデータを DID Document に含めてはいけない。あらゆる相関分析手法が適用される可能性がある。</p><h3>SSI の信頼モデル（LESS Identity vs. Trustless Identity）</h3><p><a href="https://ssimeetup.org/how-avoid-another-identity-tragedy-with-ssi-christopher-allen-webinar-53/">Christopher Allen 氏が指摘するように、</a>SSI には <a href="https://trbouma.medium.com/less-identity-65f65d87f56b">LESS Identity</a> と Trustless Identity の２つのトラックがある。LESS Identity は Tim Bouma 氏が主張した概念で、なんらかの法的な裏付けのある SSI のことである。このシステムの信頼モデルは既存の集中型の PKI によるものと基本的に変わらない。Trustless Identity はそのようなものに依存しない、分散型信頼モデル（<a href="https://en.wikipedia.org/wiki/Web_of_trust">Web of Trust</a>）である。</p><h3>Web5</h3><p><a href="https://developer.tbd.website/projects/web5/">Web5</a> は Block 社の TBD 部門が発表した分散 Web プラットフォームで、この上に分散プロトコル/アプリが構築される。Web5 の主要コンポーネントは DID/VC と <a href="https://identity.foundation/decentralized-web-node/spec/">Decentralized Web Node</a>（DWN）である。DWN は DIF で規格化が進んでいる。</p><h4>DWN</h4><p>DWN はデータの保存とメッセージのリレーを行う。VC やその他の個人のデータは DWN に保存され、これらのデータへのアクセス制御権は個人にある。個人は複数の DWN を使用することができ、それらは同期される。DWN のサービスエンドポイントは DID Document に記載される。</p><h4>tbDEX</h4><p><a href="https://tbdex.io/whitepaper.pdf">tbDEX</a> は Web5 上に構築される資産交換プロトコルである。ユーザはアセットの流動性を提供する Participating Financial Institution（PFI）を発見し、取引を交渉（ASK/BID）し、DID/VC で信頼関係を確立する。実際の支払いはプロトコルの範囲外である。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d38c5416713" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nayuta-engineering-blog-ja/ssi-%E3%82%92%E5%AE%9F%E7%8F%BE%E3%81%99%E3%82%8B%E6%8A%80%E8%A1%93-d38c5416713">SSI を実現する技術</a> was originally published in <a href="https://medium.com/nayuta-engineering-blog-ja">Nayuta エンジニアブログ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taproot Assets Protocol を理解する（仕様編）]]></title>
            <link>https://medium.com/nayuta-engineering-blog-ja/taro-ed6b93b09a75?source=rss-ec449712cbf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed6b93b09a75</guid>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[taro]]></category>
            <category><![CDATA[lightning-network]]></category>
            <dc:creator><![CDATA[Hiroki Gondo]]></dc:creator>
            <pubDate>Wed, 12 Oct 2022 08:08:32 GMT</pubDate>
            <atom:updated>2024-01-19T09:45:16.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*8enLRAO-kgSGjgCDHCPnSw.jpeg" /></figure><p>Taproot Assets Protocol（旧名 Taro。以下、TAP と称す） はビットコインネットワークのオーバレイネットワークでビットコインとは異なる UTXO ベースモデルのアセットを表現するためのプロトコルである。この記事では、TAP によるアセットの生成と転送の仕組みの理解を目的としている。</p><p>仕様は以下であるが、ここではもっぱら bip-tap と bip-tap-ms-smt について説明する。</p><ul><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-addr.mediawiki">bip-tap-addr</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-ms-smt.mediawiki">bip-tap-ms-smt</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-proof-file.mediawiki">bip-tap-proof-file</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-psbt.mediawiki">bip-tap-psbt</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-universe.mediawiki">bip-tap-universe</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-vm.mediawiki">bip-tap-vm</a></li><li><a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap.mediawiki">bip-tap</a></li></ul><p>Lightning Labs による実装は<a href="https://github.com/lightninglabs/taproot-assets">こちら</a>。</p><h4>Taproot とは？</h4><p><a href="https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki">Taproot</a> とは Bitcoin の新しい出力のタイプで、Key PathとScript Pathという２通りの支払い条件を同時に指定することができる。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*3ZjfJfqZlG3Sr8zCRpDO6g.png" /></figure><p>Key Pathは従来の P2PKH のように公開鍵が指定され、その署名によって支払われる。シュノア署名による鍵集約（マルチシグ）も使用できる。</p><p>Script Pathは従来の P2SH のようにスクリプト言語によって複雑な支払い条件を指定できる。また、複数のスクリプトを同時に指定できる。これらのスクリプトは Taproot 出力に直接シリアライズされて組み込まれるのではなく、マークルツリーによって構造化されそのルートハッシュに圧縮される。個々のスクリプトはその支払い条件で支払われる場合にのみオンチェーンで公開される。</p><p>TAP では、Script Pathに独自のデータ（Asset Tree）を埋め込む。このデータは Bitcoin の観点からは解釈できないものであるが、ハッシュ化されているのでそのようなデータが埋め込まれていることも感知されない。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vHAqoqHoLHQ6DMZ-nFu5Og.png" /></figure><h4>Asset Tree</h4><p>Taproot Asset は、２階層の Merkle Sum Sparse Merkle Tree（以下、MS-SMT と称す）構造の Asset Tree で表現される。下位の MS-SMT はasset_idで識別される単一のアセットの UTXO の集合を表す。上位の MS-SMT は下位の MS-SMT を集約する。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*zy2iNYATe_rct44uVF6ZJg.png" /></figure><p>上位の MS-SMT のルートの値（asset_tree_root）が Taproot 出力のScript Pathに埋め込まれ、ツリーの状態がコミットされる。</p><p>アセットの転送に伴い、新たな Asset Tree が生成されたり、元のものが更新されたりする。これらには Taproot 出力を消費する新たな Bitcoin トランザクション の発行が伴う。TAP の仕様を満たしていない不正な転送（例えばインフレや二重支払い）は端的に無効なものとみなされる。*</p><p>* これはいわゆる <a href="https://scalingbitcoin.org/transcript/milan2016/client-side-validation">Client side validation</a> と呼ばれるコンセプトである。Bitcoin の創発的コンセンサスを知っている人は検証される仕様の正しさの根拠が気になるかもしれないが、今は問題にしない。</p><h4>Merkle Sum Sparse Merkle Tree</h4><p>Merkle Sum Sparse Merkle Tree（以下、MS-SMT と呼ぶ）は <a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-ms-smt.mediawiki">bip-tap-ms-smt</a> で定義されるマークルツリーの変種である。キーが 256 bit なので、2 ^ 256 個のリーフを持つがそのほとんどは空である。</p><p>各リーフには数値が含まれ、各ブランチには、そこのサブツリーのリーフの合計値が記録される。サブツリーの中身がわからなくても、ブランチを見るだけでそこに含まれる合計値を知ることができるようになっている。ルートにはそのツリーの合計値が記録される。</p><p>一般的なマークルツリーのように、任意のリーフを含むサブツリー（Merkle Proof）によってそのリーフの包含証明が表現できるが、MS-SMT では非包含証明もサポートしている。これは存在しないキーのリーフを明示的に非存在を示す値（None）にしなくてはいけないという制約によって実現される（None の包含証明 = 非包含証明）。従ってデフォルトのツリーは 2 ^ 256 個 の None リーフを持つ。</p><h4>Asset Leaf（Asset UTXO）</h4><p>Asset Tree の下位の MS-SMT はasset_script_keyをキーとして、Asset Leaf を値として持つ。個々のAsset Leaf は アセットの UTXO （以下簡単のため UTXO と称す * ）を表す。Asset Leaf にはオプショナルなものも含め、以下の項目が <a href="https://github.com/lightning/bolts/blob/master/01-messaging.md#type-length-value-format">Type-length-value フォーマット</a>でシリアライズされる。</p><p>* Bitcoin のそれではなく。</p><ul><li>taproot_asset_version</li><li>asset_genesis</li><li>asset_id</li><li>asset_type</li><li>amt</li><li>lock_time</li><li>relative_lock_time</li><li>prev_asset_witnesses<br>-prev_asset_id<br>-asset_witness<br>-split_commitment_proof</li><li>split_commitment</li><li>asset_script_version</li><li>asset_script_key</li><li>asset_group_key</li><li>canonical_universe</li></ul><p>asset_genesisにはasset_idを導出するためのデータの preimage が含まれる。</p><p>asset_script_keyはこの Asset Leaf のキーであると同時に、（Bitcoin とは別のバーチャルな <a href="https://github.com/Roasbeef/bips/blob/bip-tap/bip-tap-vm.mediawiki">tap-vm</a> 上の）Taproot タイプの公開鍵となっており、この Asset Leaf が表現する UTXO を消費するときの支払い条件となっている。</p><p>UTXO を消費するとき、（外部の）Bitcoin の支払い条件を満たすとともに、prev_asset_idとasset_witnessによって（内部の）TAP のasset_script_keyによる支払い条件も満たさないといけない。asset_witnessは、例えば消費した UTXO のためのasset_script_keyによる署名である。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*8yCJofequ55HYKSPG1Gb-Q.png" /></figure><p>転送で UTXO が分割される場合、split_commitmentとsplit_commitment_proof必要になる。</p><p>split_commitmentは、分割後の全ての UTXO の参照を含む MS-SMT で（このケースでは Asset Tree は３層になる）、ルートの合計値は転送されたアセットの合計値になる。</p><p>split_commitment_proofは、分割の存在を証明するsplit_commitmentの Merkle Proof である。</p><p>全ての分割のうち、ひとつだけがprev_asset_id、 asset_witness、 split_commitmentを持つ。それ以外の分割はsplit_commitment_proofを持つ。全ての分割はprev_asset_id、asset_witnessを共有する。</p><h3>アセットの生成</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xWTHW5-K8xjTSI62qr7qXA.png" /></figure><p>アセットの生成は、生成される UTXO を含む新規の Asset Tree を Bitcoin トランザクション（アセットの生成トランザクション）の Taproot 出力に埋め込むことによって行われる。アセットの ID（asset_id）の定義は次の式である。</p><pre>asset_id := sha256(genesis_outpoint || sha256(asset_tag) || asset_meta_hash || output_index || asset_type)</pre><p>genesis_outpointは当該トランザクションが消費する前のトランザクションの出力を示し、output_indexは当該 Asset Tree が含まれる当該トランザクションの出力位置を示す。これらを含むことによりasset_idはグローバルに一意の値になることが保証される。</p><p>新規に生成された UTXO には、prev_asset_id、asset_witnessは含まれない。</p><h3>アセットの転送</h3><p>アセットの転送では、Bitcoin と同じく、UTXO のマージ／分割が発生する場合がある。まずは、いずれも発生しない単純なケースからはじめる *。</p><p>* 以下の説明ではいくつか簡略化している。例えば Bitcoin のお釣り出力は省略している。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JzXDvl9v5zgyZ2JHvvAZlw.png" /></figure><p>Alice が、10 単位の UTXO を持っていて、そのまま分割なしに 10 単位を Bob に転送する。</p><p>Alice は UTXO が保存されている Taproot 出力を消費する Bitcoin トランザクションを作りブロードキャストする。これは、新たに２つの Taproot 出力を持つ。一つは Bob がコントロールできる（例えば、Bob の Bitcoin 公開鍵によって）10 単位の UTXO を含んだ新規の Asset Tree を含む。もう一つは Alice がコントロールできる元の Asset Tree から当該 アセット UTXO が取り除かれた Asset Tree を含む。</p><p>Bob のための新しい UTXO は、amtが 10 で、prev_asset_idは Alice の前の UTXO を参照する。asset_witnessには、前のasset_script_keyによる署名が配置される。当該 UTXO のasset_script_keyには、事前に Bob から貰った新しいそれが配置され、これは下位の MS-SMT のキーでもある。</p><p>Bob はアセットの受け取りを確認するために、支払い条件が満たされ、転送の前後でアセットがインフレしていないか検証する必要がある。</p><ul><li>新しく作成された Bob の Asset Tree に、支払い条件を満たした新しい UTXO が存在するか？</li><li>更新された Alice の Asset Tree から、元の UTXO が取り除かれたか？</li><li>トランザクションに他の Taproot 出力が存在する場合には、そこに別の Asset Tree が含まれていないか？*</li><li>等々。</li></ul><p>これらが MS-SMT の包含／非包含証明および Taproot の preimage と包含／非包含証明によって証明／検証される。</p><p>*このような Asset Tree に、元の UTXO を消費する Bob に対するものとは別の UTXO が追加されていた場合、二重支払いになってしまう。</p><h4>UTXO のマージ</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*486gBr8XN0wZz4SMDfDrBg.png" /></figure><p>Alice が３単位と７単位の UTXO を持っていて、合わせて 10 単位を Bob に転送する。</p><p>各入力 UTXO は異なる Asset Tree に別々に属するかもしれないし、同じツリーの異なるキー（asset_script_key）に属するかもしれない。Bob の新しい UTXO に、二つの UTXO を消費するそれぞれのprev_asset_idとasset_witnessを含めればいい。</p><h4>UTXO の分割</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HSuWXEI00OqLDFFMPizhEQ.png" /></figure><p>Alice が 10 単位の UTXO を持っていて、そのうち 7 単位を Bob に転送する。結果として Alice がお釣りの 3 単位、Bob が 7 単位の UTXO を持つことになる。</p><p>Alice のお釣り UTXO には、prev_asset_idとasset_witness、あとsplit_commitmentが配置される。Bob の新たな UTXO にはsplit_commitment_proofが含まれる。</p><p>UTXO のマージと分割が同時に行われるケースの説明はいらないだろう。</p><p>* 仕様の記述と若干異なると思うが、おそらく現在の実装ではこうなっている。</p><h4>UTXO の出自の検証</h4><p>ここまでの説明で言及しなかったが、アセットの転送が検証される前に、各入力 UTXO が有効なものであるのか検証されなければならない。そのためには、各入力 UTXO について、アセットの根拠となる生成トランザクションからその UTXO までのルートにおける全ての転送が正しく行われたことが検証されなければならない。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Z-NG7a7zjf1H7hGekaU6g.png" /></figure><p>生成トランザクションから最新のトランザクションまで、そのルートは複雑なトランザクショングラフを描く。上図のTx Aではその祖先の青色のトランザクションを全て検証する必要がある。Tx Bではそれに加えて赤色のトランザクションも検証する必要がある。履歴は準指数関数的に増加するためスケーラビリティの大きな課題である。</p><p>また検証に必要な preimage や証明はオンチェーンに公開されないので、アセット転送時に送信者から受信者にどのようにして受け渡すかも課題である。</p><h3>スケーラビリティ</h3><p>履歴の増加はスケーラビリティの大きな課題である。いくつか解決策が提案されているが Lightning Network への対応は最も期待されているものの一つである。オフチェーントランザクションでは履歴が増加しない。</p><p>このプロトコルはまだ新しく、仕様は不完全な部分がある。例えば、以前私が指摘した<a href="https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-October/021047.html">この問題</a>がある。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed6b93b09a75" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nayuta-engineering-blog-ja/taro-ed6b93b09a75">Taproot Assets Protocol を理解する（仕様編）</a> was originally published in <a href="https://medium.com/nayuta-engineering-blog-ja">Nayuta エンジニアブログ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>