@@ -11,13 +11,11 @@ import (
1111 "github.com/btcsuite/btcd/btcec/v2"
1212 "github.com/btcsuite/btcd/btcec/v2/schnorr"
1313 "github.com/btcsuite/btcd/btcutil/hdkeychain"
14- "github.com/btcsuite/btcd/chaincfg/chainhash"
1514 "github.com/btcsuite/btcd/txscript"
1615 "github.com/btcsuite/btcd/wire"
1716 "github.com/lightninglabs/taproot-assets/fn"
1817 "github.com/lightninglabs/taproot-assets/internal/test"
1918 "github.com/lightninglabs/taproot-assets/mssmt"
20- "github.com/lightningnetwork/lnd/input"
2119 "github.com/lightningnetwork/lnd/tlv"
2220 "github.com/stretchr/testify/require"
2321 "pgregory.net/rapid"
@@ -729,81 +727,6 @@ func TestAssetID(t *testing.T) {
729727 require .NotEqual (t , id [:], differentID [:])
730728}
731729
732- // TestAssetGroupKey tests that the asset key group is derived correctly.
733- func TestAssetGroupKey (t * testing.T ) {
734- t .Parallel ()
735-
736- privKey , err := btcec .NewPrivateKey ()
737- groupPub := privKey .PubKey ()
738- require .NoError (t , err )
739- privKeyCopy := btcec .PrivKeyFromScalar (& privKey .Key )
740- genSigner := NewMockGenesisSigner (privKeyCopy )
741- genBuilder := MockGroupTxBuilder {}
742- fakeKeyDesc := test .PubToKeyDesc (groupPub )
743- fakeScriptKey := NewScriptKeyBip86 (fakeKeyDesc )
744-
745- g := Genesis {
746- FirstPrevOut : wire.OutPoint {
747- Hash : hashBytes1 ,
748- Index : 99 ,
749- },
750- Tag : "normal asset 1" ,
751- MetaHash : [MetaHashLen ]byte {1 , 2 , 3 },
752- OutputIndex : 21 ,
753- Type : Collectible ,
754- }
755- groupTweak := g .ID ()
756-
757- internalKey := input .TweakPrivKey (privKeyCopy , groupTweak [:])
758- tweakedKey := txscript .TweakTaprootPrivKey (* internalKey , nil )
759-
760- // TweakTaprootPrivKey modifies the private key that is passed in! We
761- // need to provide a copy to arrive at the same result.
762- protoAsset := NewAssetNoErr (t , g , 1 , 0 , 0 , fakeScriptKey , nil )
763- groupReq := NewGroupKeyRequestNoErr (
764- t , fakeKeyDesc , fn .None [ExternalKey ](), g , protoAsset , nil ,
765- fn .None [chainhash.Hash ](),
766- )
767- genTx , err := groupReq .BuildGroupVirtualTx (& genBuilder )
768- require .NoError (t , err )
769-
770- keyGroup , err := DeriveGroupKey (genSigner , * genTx , * groupReq , nil )
771- require .NoError (t , err )
772-
773- require .Equal (
774- t , schnorr .SerializePubKey (tweakedKey .PubKey ()),
775- schnorr .SerializePubKey (& keyGroup .GroupPubKey ),
776- )
777-
778- // We should also be able to reproduce the correct tweak with a non-nil
779- // tapscript root.
780- tapTweak := test .RandBytes (32 )
781- tweakedKey = txscript .TweakTaprootPrivKey (* internalKey , tapTweak )
782-
783- groupReq = NewGroupKeyRequestNoErr (
784- t , test .PubToKeyDesc (privKey .PubKey ()), fn .None [ExternalKey ](),
785- g , protoAsset , tapTweak , fn .None [chainhash.Hash ](),
786- )
787- genTx , err = groupReq .BuildGroupVirtualTx (& genBuilder )
788- require .NoError (t , err )
789-
790- keyGroup , err = DeriveGroupKey (genSigner , * genTx , * groupReq , nil )
791- require .NoError (t , err )
792-
793- require .Equal (
794- t , schnorr .SerializePubKey (tweakedKey .PubKey ()),
795- schnorr .SerializePubKey (& keyGroup .GroupPubKey ),
796- )
797-
798- // Group key tweaking should fail when given invalid tweaks.
799- badTweak := test .RandBytes (33 )
800- _ , err = GroupPubKeyV0 (groupPub , badTweak , badTweak )
801- require .Error (t , err )
802-
803- _ , err = GroupPubKeyV0 (groupPub , groupTweak [:], badTweak )
804- require .Error (t , err )
805- }
806-
807730// TestDeriveGroupKey tests that group key derivation fails for assets that are
808731// not eligible to be group anchors.
809732func TestDeriveGroupKey (t * testing.T ) {
0 commit comments