@@ -14,7 +14,6 @@ import (
1414
1515 "github.com/btcsuite/btcd/blockchain"
1616 "github.com/btcsuite/btcd/btcec/v2"
17- "github.com/btcsuite/btcd/btcec/v2/schnorr"
1817 "github.com/btcsuite/btcd/btcutil"
1918 "github.com/btcsuite/btcd/chaincfg"
2019 "github.com/btcsuite/btcd/chaincfg/chainhash"
@@ -26,7 +25,6 @@ import (
2625 "github.com/lightninglabs/taproot-assets/commitment"
2726 "github.com/lightninglabs/taproot-assets/internal/test"
2827 "github.com/lightningnetwork/lnd/build"
29- "github.com/lightningnetwork/lnd/keychain"
3028 "github.com/stretchr/testify/require"
3129)
3230
@@ -138,127 +136,6 @@ func assertEqualProof(t *testing.T, expected, actual *Proof) {
138136 require .Equal (t , expected .ChallengeWitness , actual .ChallengeWitness )
139137}
140138
141- func randomProof (t * testing.T , genesis asset.Genesis ,
142- scriptKey * btcec.PublicKey , block wire.MsgBlock , txIndex int ,
143- outputIndex uint32 ) Proof {
144-
145- txMerkleProof , err := NewTxMerkleProof (block .Transactions , txIndex )
146- require .NoError (t , err )
147-
148- tweakedScriptKey := asset .NewScriptKey (scriptKey )
149- protoAsset := asset .NewAssetNoErr (
150- t , genesis , 1 , 0 , 0 , tweakedScriptKey , nil ,
151- )
152- groupKey := asset .RandGroupKey (t , genesis , protoAsset )
153- groupReveal := asset.GroupKeyReveal {
154- RawKey : asset .ToSerialized (& groupKey .GroupPubKey ),
155- TapscriptRoot : test .RandBytes (32 ),
156- }
157-
158- mintCommitment , assets , err := commitment .Mint (
159- genesis , groupKey , & commitment.AssetDetails {
160- Type : asset .Collectible ,
161- ScriptKey : test .PubToKeyDesc (scriptKey ),
162- Amount : nil ,
163- LockTime : 1337 ,
164- RelativeLockTime : 6 ,
165- },
166- )
167- require .NoError (t , err )
168- proofAsset := assets [0 ]
169- proofAsset .GroupKey .RawKey = keychain.KeyDescriptor {}
170-
171- // Empty the group witness, since it will eventually be stored as the
172- // asset's witness within the proof.
173- // TODO(guggero): Actually store the witness in the proof.
174- proofAsset .GroupKey .Witness = nil
175-
176- // Empty the raw script key, since we only serialize the tweaked
177- // pubkey. We'll also force the main script key to be an x-only key as
178- // well.
179- proofAsset .ScriptKey .PubKey , err = schnorr .ParsePubKey (
180- schnorr .SerializePubKey (proofAsset .ScriptKey .PubKey ),
181- )
182- require .NoError (t , err )
183-
184- proofAsset .ScriptKey .TweakedScriptKey = nil
185-
186- _ , commitmentProof , err := mintCommitment .Proof (
187- proofAsset .TapCommitmentKey (), proofAsset .AssetCommitmentKey (),
188- )
189- require .NoError (t , err )
190-
191- leaf1 := txscript .NewBaseTapLeaf ([]byte {1 })
192- leaf2 := txscript .NewBaseTapLeaf ([]byte {2 })
193- testLeafPreimage := commitment .NewPreimageFromLeaf (leaf1 )
194- testLeafPreimage2 := commitment .NewPreimageFromLeaf (leaf2 )
195- testBranchPreimage := commitment .NewPreimageFromBranch (
196- txscript .NewTapBranch (leaf1 , leaf2 ),
197- )
198- return Proof {
199- PrevOut : genesis .FirstPrevOut ,
200- BlockHeader : block .Header ,
201- BlockHeight : 42 ,
202- AnchorTx : * block .Transactions [txIndex ],
203- TxMerkleProof : * txMerkleProof ,
204- Asset : * proofAsset ,
205- InclusionProof : TaprootProof {
206- OutputIndex : outputIndex ,
207- InternalKey : test .RandPubKey (t ),
208- CommitmentProof : & CommitmentProof {
209- Proof : * commitmentProof ,
210- TapSiblingPreimage : testLeafPreimage ,
211- },
212- TapscriptProof : nil ,
213- },
214- ExclusionProofs : []TaprootProof {
215- {
216- OutputIndex : 2 ,
217- InternalKey : test .RandPubKey (t ),
218- CommitmentProof : & CommitmentProof {
219- Proof : * commitmentProof ,
220- TapSiblingPreimage : testLeafPreimage ,
221- },
222- TapscriptProof : nil ,
223- },
224- {
225- OutputIndex : 3 ,
226- InternalKey : test .RandPubKey (t ),
227- CommitmentProof : nil ,
228- TapscriptProof : & TapscriptProof {
229- TapPreimage1 : testBranchPreimage ,
230- TapPreimage2 : testLeafPreimage2 ,
231- Bip86 : true ,
232- },
233- },
234- {
235- OutputIndex : 4 ,
236- InternalKey : test .RandPubKey (t ),
237- CommitmentProof : nil ,
238- TapscriptProof : & TapscriptProof {
239- Bip86 : true ,
240- },
241- },
242- },
243- SplitRootProof : & TaprootProof {
244- OutputIndex : 4 ,
245- InternalKey : test .RandPubKey (t ),
246- CommitmentProof : & CommitmentProof {
247- Proof : * commitmentProof ,
248- TapSiblingPreimage : nil ,
249- },
250- },
251- MetaReveal : & MetaReveal {
252- Data : []byte ("quoth the raven nevermore" ),
253- Type : MetaOpaque ,
254- },
255- AdditionalInputs : []File {},
256- ChallengeWitness : wire.TxWitness {[]byte ("foo" ), []byte ("bar" )},
257- GenesisReveal : & genesis ,
258- GroupKeyReveal : & groupReveal ,
259- }
260- }
261-
262139func TestProofEncoding (t * testing.T ) {
263140 t .Parallel ()
264141
@@ -267,7 +144,7 @@ func TestProofEncoding(t *testing.T) {
267144
268145 genesis := asset .RandGenesis (t , asset .Collectible )
269146 scriptKey := test .RandPubKey (t )
270- proof := randomProof (t , genesis , scriptKey , oddTxBlock , 0 , 1 )
147+ proof := RandProof (t , genesis , scriptKey , oddTxBlock , 0 , 1 )
271148
272149 file , err := NewFile (V0 , proof , proof )
273150 require .NoError (t , err )
0 commit comments