@@ -918,49 +918,96 @@ type GroupVirtualTx struct {
918918 TweakedKey btcec.PublicKey
919919}
920920
921- // GroupKeyReveal is a type for representing the data used to derive the tweaked
922- // key used to identify an asset group. The final tweaked key is the result of:
923- // TapTweak(groupInternalKey, tapscriptRoot)
924- type GroupKeyReveal struct {
921+ // GroupKeyReveal represents the data used to derive the adjusted key that
922+ // uniquely identifies an asset group.
923+ type GroupKeyReveal interface {
924+ // RawKey returns the raw key of the group key reveal.
925+ RawKey () SerializedKey
926+
927+ // SetRawKey sets the raw key of the group key reveal.
928+ SetRawKey (SerializedKey )
929+
930+ // TapscriptRoot returns the tapscript root of the group key reveal.
931+ TapscriptRoot () []byte
932+
933+ // SetTapscriptRoot sets the tapscript root of the group key reveal.
934+ SetTapscriptRoot ([]byte )
935+
936+ // GroupPubKey returns the group public key derived from the group key
937+ // reveal.
938+ GroupPubKey (assetID ID ) (* btcec.PublicKey , error )
939+ }
940+
941+ // GroupKeyRevealV0 is a version 0 group key reveal type for representing the
942+ // data used to derive the tweaked key used to identify an asset group. The
943+ // final tweaked key is the result of: TapTweak(groupInternalKey, tapscriptRoot)
944+ type GroupKeyRevealV0 struct {
925945 // RawKey is the public key that is tweaked twice to derive the final
926946 // tweaked group key. The final tweaked key is the result of:
927947 // internalKey = rawKey + singleTweak * G
928948 // tweakedGroupKey = TapTweak(internalKey, tapTweak)
929- RawKey SerializedKey
949+ rawKey SerializedKey
930950
931951 // TapscriptRoot is the root of the Tapscript tree that commits to all
932952 // script spend conditions for the group key. Instead of spending an
933953 // asset, these scripts are used to define witnesses more complex than
934954 // a Schnorr signature for reissuing assets. This is either empty/nil or
935955 // a 32-byte hash.
936- TapscriptRoot []byte
956+ tapscriptRoot []byte
937957}
938958
939- // PendingGroupWitness specifies the asset group witness for an asset seedling
940- // in an unsealed minting batch.
941- type PendingGroupWitness struct {
942- GenID ID
943- Witness wire.TxWitness
959+ // Ensure that GroupKeyRevealV0 implements the GroupKeyReveal interface.
960+ var _ GroupKeyReveal = (* GroupKeyRevealV0 )(nil )
961+
962+ // NewGroupKeyRevealV0 creates a new version 0 group key reveal instance.
963+ func NewGroupKeyRevealV0 (rawKey SerializedKey ,
964+ tapscriptRoot []byte ) GroupKeyReveal {
965+
966+ return & GroupKeyRevealV0 {
967+ rawKey : rawKey ,
968+ tapscriptRoot : tapscriptRoot ,
969+ }
970+ }
971+
972+ // RawKey returns the raw key of the group key reveal.
973+ func (g * GroupKeyRevealV0 ) RawKey () SerializedKey {
974+ return g .rawKey
975+ }
976+
977+ // SetRawKey sets the raw key of the group key reveal.
978+ func (g * GroupKeyRevealV0 ) SetRawKey (rawKey SerializedKey ) {
979+ g .rawKey = rawKey
980+ }
981+
982+ // TapscriptRoot returns the tapscript root of the group key reveal.
983+ func (g * GroupKeyRevealV0 ) TapscriptRoot () []byte {
984+ return g .tapscriptRoot
985+ }
986+
987+ // SetTapscriptRoot sets the tapscript root of the group key reveal.
988+ func (g * GroupKeyRevealV0 ) SetTapscriptRoot (tapscriptRoot []byte ) {
989+ g .tapscriptRoot = tapscriptRoot
944990}
945991
946992// GroupPubKey returns the group public key derived from the group key reveal.
947- func (g * GroupKeyReveal ) GroupPubKey (assetID ID ) (* btcec.PublicKey , error ) {
948- rawKey , err := g .RawKey .ToPubKey ()
993+ func (g * GroupKeyRevealV0 ) GroupPubKey (assetID ID ) (* btcec.PublicKey , error ) {
994+ rawKey , err := g .RawKey () .ToPubKey ()
949995 if err != nil {
950996 return nil , fmt .Errorf ("group reveal raw key invalid: %w" , err )
951997 }
952998
953- return GroupPubKey (rawKey , assetID [:], g .TapscriptRoot )
999+ return GroupPubKeyV0 (rawKey , assetID [:], g .TapscriptRoot () )
9541000}
9551001
956- // GroupPubKey derives a tweaked group key from a public key and two tweaks;
957- // the single tweak is the asset ID of the group anchor asset, and the tapTweak
958- // is the root of a tapscript tree that commits to script-based conditions for
959- // 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:
9601007//
9611008// internalKey = rawKey + singleTweak * G
9621009// tweakedGroupKey = TapTweak(internalKey, tapTweak)
963- func GroupPubKey (rawKey * btcec.PublicKey , singleTweak , tapTweak []byte ) (
1010+ func GroupPubKeyV0 (rawKey * btcec.PublicKey , singleTweak , tapTweak []byte ) (
9641011 * btcec.PublicKey , error ) {
9651012
9661013 if len (singleTweak ) != sha256 .Size {
@@ -1371,7 +1418,7 @@ func (req *GroupKeyRequest) BuildGroupVirtualTx(genBuilder GenesisTxBuilder) (
13711418 // Compute the tweaked group key and set it in the asset before
13721419 // creating the virtual minting transaction.
13731420 genesisTweak := req .AnchorGen .ID ()
1374- tweakedGroupKey , err := GroupPubKey (
1421+ tweakedGroupKey , err := GroupPubKeyV0 (
13751422 req .RawKey .PubKey , genesisTweak [:], req .TapscriptRoot ,
13761423 )
13771424 if err != nil {
@@ -1491,6 +1538,13 @@ func DeriveGroupKey(genSigner GenesisSigner, genTx GroupVirtualTx,
14911538 }, nil
14921539}
14931540
1541+ // PendingGroupWitness specifies the asset group witness for an asset seedling
1542+ // in an unsealed minting batch.
1543+ type PendingGroupWitness struct {
1544+ GenID ID
1545+ Witness wire.TxWitness
1546+ }
1547+
14941548// Asset represents a Taproot asset.
14951549type Asset struct {
14961550 // Version is the Taproot Asset version of the asset.
0 commit comments