Skip to content

Commit 2fa1fb5

Browse files
committed
multi: rename asset.GroupPubKey to GroupPubKeyV0
Renamed the function to `GroupPubKeyV0` to allow for the introduction of future versions while maintaining clarity and compatibility.
1 parent 23735cc commit 2fa1fb5

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

asset/asset.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -996,17 +996,18 @@ func (g *GroupKeyRevealV0) GroupPubKey(assetID ID) (*btcec.PublicKey, error) {
996996
return nil, fmt.Errorf("group reveal raw key invalid: %w", err)
997997
}
998998

999-
return GroupPubKey(rawKey, assetID[:], g.TapscriptRoot())
999+
return GroupPubKeyV0(rawKey, assetID[:], g.TapscriptRoot())
10001000
}
10011001

1002-
// GroupPubKey derives a tweaked group key from a public key and two tweaks;
1003-
// the single tweak is the asset ID of the group anchor asset, and the tapTweak
1004-
// is the root of a tapscript tree that commits to script-based conditions for
1005-
// reissuing assets as part of this asset group. The tweaked key is defined by:
1002+
// GroupPubKeyV0 derives a version 0 tweaked group key from a public key and two
1003+
// tweaks; the single tweak is the asset ID of the group anchor asset, and the
1004+
// tapTweak is the root of a tapscript tree that commits to script-based
1005+
// conditions for reissuing assets as part of this asset group. The tweaked key
1006+
// is defined by:
10061007
//
10071008
// internalKey = rawKey + singleTweak * G
10081009
// tweakedGroupKey = TapTweak(internalKey, tapTweak)
1009-
func GroupPubKey(rawKey *btcec.PublicKey, singleTweak, tapTweak []byte) (
1010+
func GroupPubKeyV0(rawKey *btcec.PublicKey, singleTweak, tapTweak []byte) (
10101011
*btcec.PublicKey, error) {
10111012

10121013
if len(singleTweak) != sha256.Size {
@@ -1417,7 +1418,7 @@ func (req *GroupKeyRequest) BuildGroupVirtualTx(genBuilder GenesisTxBuilder) (
14171418
// Compute the tweaked group key and set it in the asset before
14181419
// creating the virtual minting transaction.
14191420
genesisTweak := req.AnchorGen.ID()
1420-
tweakedGroupKey, err := GroupPubKey(
1421+
tweakedGroupKey, err := GroupPubKeyV0(
14211422
req.RawKey.PubKey, genesisTweak[:], req.TapscriptRoot,
14221423
)
14231424
if err != nil {

asset/asset_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,10 @@ func TestAssetGroupKey(t *testing.T) {
920920

921921
// Group key tweaking should fail when given invalid tweaks.
922922
badTweak := test.RandBytes(33)
923-
_, err = GroupPubKey(groupPub, badTweak, badTweak)
923+
_, err = GroupPubKeyV0(groupPub, badTweak, badTweak)
924924
require.Error(t, err)
925925

926-
_, err = GroupPubKey(groupPub, groupTweak[:], badTweak)
926+
_, err = GroupPubKeyV0(groupPub, groupTweak[:], badTweak)
927927
require.Error(t, err)
928928
}
929929

itest/assertions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ func AssertGroupAnchor(t *testing.T, anchorGen *asset.Genesis,
14031403

14041404
// TODO(jhb): add tapscript root support
14051405
anchorTweak := anchorGen.ID()
1406-
computedGroupPubKey, err := asset.GroupPubKey(
1406+
computedGroupPubKey, err := asset.GroupPubKeyV0(
14071407
internalPubKey, anchorTweak[:], nil,
14081408
)
14091409
require.NoError(t, err)

tapgarden/caretaker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ func GenRawGroupAnchorVerifier(ctx context.Context) func(*asset.Genesis,
15621562
groupAnchor, err := groupAnchors.Get(assetGroupKey)
15631563
if err != nil {
15641564
singleTweak := gen.ID()
1565-
tweakedGroupKey, err := asset.GroupPubKey(
1565+
tweakedGroupKey, err := asset.GroupPubKeyV0(
15661566
groupKey.RawKey.PubKey, singleTweak[:],
15671567
groupKey.TapscriptRoot,
15681568
)

0 commit comments

Comments
 (0)