Skip to content

Commit 24c802a

Browse files
authored
Merge pull request #1263 from lightninglabs/group-key-reveal-change
asset: change all-zero hash to empty leaf
2 parents c1badfa + e91cf2c commit 24c802a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

asset/asset.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,8 @@ func NewGKRCustomSubtreeRootRecord(root *chainhash.Hash) tlv.Record {
10401040
// hash may represent either a single leaf or the root hash of an entire
10411041
// subtree.
10421042
//
1043-
// If `custom_root_hash` is not provided, it defaults to a 32-byte zero-filled
1044-
// array. In this case, no valid script spending path can correspond to the
1043+
// If `custom_root_hash` is not provided, it defaults to a bare `[OP_RETURN` as
1044+
// well. In this case, no valid script spending path can correspond to the
10451045
// custom subtree root hash due to the pre-image resistance of SHA-256.
10461046
//
10471047
// A sibling node is included alongside the `custom_root_hash` node. This
@@ -1067,7 +1067,8 @@ func NewGKRCustomSubtreeRootRecord(root *chainhash.Hash) tlv.Record {
10671067
// 1. It cannot be misinterpreted as a genesis asset ID leaf.
10681068
// 2. It optionally includes user-defined script spending leaves.
10691069
// - <custom_root_hash> is the root hash of the custom tapscript subtree.
1070-
// If not specified, it defaults to a 32-byte zero-filled array.
1070+
// If not specified, it defaults to the same [OP_RETURN] that's on the left
1071+
// side.
10711072
// - [OP_RETURN] is a non-spendable script leaf containing the script
10721073
// `OP_RETURN`. Its presence ensures that [tweaked_custom_branch] remains
10731074
// a branch node and cannot be a valid genesis asset ID leaf.
@@ -1108,7 +1109,7 @@ func NewGroupKeyTapscriptRoot(genesisAssetID ID,
11081109
// hash of the custom tapscript subtree.
11091110
//
11101111
// If a custom tapscript subtree root hash is provided, we use it.
1111-
// Otherwise, we default to an empty hash (a zero-filled byte array).
1112+
// Otherwise, we default to an empty non-spendable leaf hash as well.
11121113
emptyNonSpendLeaf, err := NewNonSpendableScriptLeaf(nil)
11131114
if err != nil {
11141115
return GroupKeyRevealTapscript{}, err
@@ -1117,7 +1118,7 @@ func NewGroupKeyTapscriptRoot(genesisAssetID ID,
11171118
// Compute the tweaked custom branch hash.
11181119
tweakedCustomBranchHash := TapBranchHash(
11191120
emptyNonSpendLeaf.TapHash(),
1120-
customRoot.UnwrapOr(chainhash.Hash{}),
1121+
customRoot.UnwrapOr(emptyNonSpendLeaf.TapHash()),
11211122
)
11221123

11231124
// Next, we'll combine the tweaked custom branch hash with the genesis

0 commit comments

Comments
 (0)