From 71c83e5999ef3bd6dea962d691ed3927b36b391e Mon Sep 17 00:00:00 2001 From: Gijs van Dam Date: Wed, 13 Mar 2024 13:38:37 +0100 Subject: [PATCH 1/3] bip-tap: correct `asset_tree_root` usage The field `asset_tree_root` is not 40 bytes long, but 32. This is both consistent with the implementation, and with the definition of the field further down in this bip. Definition: > the asset tree is calculated as either: > * asset_tree_root = sha256(asset_id || left_hash || right_hash > || sum_value) > or > * asset_tree_root = sha256(asset_group_key || left_hash || > right_hash || sum_value) Implementation: ``` leafParts := [][]byte{ {byte(c.Version)}, TaprootAssetsMarker[:], rootHash[:], rootSum[:], } ``` The bip now reflects this. --- bip-tap.mediawiki | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bip-tap.mediawiki b/bip-tap.mediawiki index 65d342b5..1c72e8cb 100644 --- a/bip-tap.mediawiki +++ b/bip-tap.mediawiki @@ -212,12 +212,13 @@ asset ID. A given Taproot Asset tree is composed of two nested MS-SMT instances: The root hash of an asset tree, observing [[../master/bip-0341.mediawiki|BIP-341]] is represented as a Tapscript tree that commits to a single unique leaf of: -* tagged_hash("TapLeaf", leaf_version || taproot_asset_marker || taproot_asset_version || asset_tree_root) +* tagged_hash("TapLeaf", leaf_version || taproot_asset_marker || asset_tree_root || sum_value) where: * taproot_asset_marker is the sha256 hash of the ascii string "taproot-assets". * taproot_asset_version is the version of the Taproot Assets system which defines how the remainder of the commitment value is to be interpreted. -* asset_tree_root is a 40 byte (32 byte for hash, 8 bytes for value) MS-SMT root. +* asset_tree_root is the 32-byte sha256 root hash of the asset tree. +* sum_value is the 8-byte sum of the amt values of each of the asset leaves. A leaf_version of ??? is selected. From the PoV of the Bitcoin @@ -438,7 +439,7 @@ tranches of the same asset) or collectibles. * asset_id is the 32-byte asset ID specified above * left_hash is the hash of the left sub-tree. * right_hash is the hash of the right sub-tree. -* amt_sum is the sum of the amt values of each of the asset leaves (essentially asset UTXOs). +* sum_value is the sum of the amt values of each of the asset leaves (essentially asset UTXOs). Committing to the total sum of the asset values in a given asset sub-tree for a given asset allows asset holders to easily prove how much of a given asset they From deffebf4f70c9e4ce924217301da7076dea98d0d Mon Sep 17 00:00:00 2001 From: Gijs van Dam Date: Mon, 25 Mar 2024 10:00:42 +0100 Subject: [PATCH 2/3] fixup! bip-tap: correct `asset_tree_root` usage --- bip-tap.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bip-tap.mediawiki b/bip-tap.mediawiki index 1c72e8cb..63bc6599 100644 --- a/bip-tap.mediawiki +++ b/bip-tap.mediawiki @@ -212,7 +212,7 @@ asset ID. A given Taproot Asset tree is composed of two nested MS-SMT instances: The root hash of an asset tree, observing [[../master/bip-0341.mediawiki|BIP-341]] is represented as a Tapscript tree that commits to a single unique leaf of: -* tagged_hash("TapLeaf", leaf_version || taproot_asset_marker || asset_tree_root || sum_value) +* tagged_hash("TapLeaf", leaf_version || taproot_asset_marker || taproot_asset_version || asset_tree_root || sum_value) where: * taproot_asset_marker is the sha256 hash of the ascii string "taproot-assets". From 165fab1ce445fa9a629d6e72c90d222a7736ba0a Mon Sep 17 00:00:00 2001 From: Gijs van Dam Date: Mon, 25 Mar 2024 13:48:15 +0100 Subject: [PATCH 3/3] fixup! bip-tap: correct `asset_tree_root` usage --- bip-tap.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bip-tap.mediawiki b/bip-tap.mediawiki index 63bc6599..b3e32911 100644 --- a/bip-tap.mediawiki +++ b/bip-tap.mediawiki @@ -215,7 +215,7 @@ represented as a Tapscript tree that commits to a single unique leaf of: * tagged_hash("TapLeaf", leaf_version || taproot_asset_marker || taproot_asset_version || asset_tree_root || sum_value) where: -* taproot_asset_marker is the sha256 hash of the ascii string "taproot-assets". +* taproot_asset_marker is the sha256 hash of the ascii string "taproot-assets:194243". * taproot_asset_version is the version of the Taproot Assets system which defines how the remainder of the commitment value is to be interpreted. * asset_tree_root is the 32-byte sha256 root hash of the asset tree. * sum_value is the 8-byte sum of the amt values of each of the asset leaves.