@@ -453,6 +453,44 @@ func TestVerifyV1InclusionProof(t *testing.T) {
453
453
},
454
454
expectedErrContains : "error verifying STXO proof: invalid " +
455
455
"taproot proof" ,
456
+ }, {
457
+ name : "valid v0 and invalid v1 proofs but with v0 version" ,
458
+ makeProof : func (t * testing.T ) []* Proof {
459
+ p , rootCommitments := makeV0InclusionProof (t )
460
+
461
+ // We add an STXO asset to the root commitment.
462
+ _ , key := addV1InclusionProof (
463
+ t , p [0 ], rootCommitments [0 ], withAddStxoProof (),
464
+ withUpdateAnchorTx (),
465
+ )
466
+
467
+ // At this point both proofs are valid. But we want to
468
+ // invalidate just the v1 proof, so we replace it by one
469
+ // that is derived from a different commitment. We can
470
+ // achieve that by downgrading the commitment and
471
+ // re-deriving the same proof, without updating the
472
+ // anchor output transaction.
473
+ clonedCommitment , err := rootCommitments [0 ].Downgrade ()
474
+ require .NoError (t , err )
475
+
476
+ _ , v1ProofOld , err := clonedCommitment .Proof (
477
+ asset .EmptyGenesisID ,
478
+ p [0 ].Asset .AssetCommitmentKey (),
479
+ )
480
+ require .NoError (t , err )
481
+
482
+ cp := p [0 ].InclusionProof .CommitmentProof
483
+ cp .STXOProofs [key ] = * v1ProofOld
484
+
485
+ // We now have a invalid v1 proof, but the proof's
486
+ // version is still set to 0. We do however expect the
487
+ // verification to fail, since the v1 proof is present
488
+ // and will be verified..
489
+
490
+ return p
491
+ },
492
+ expectedErrContains : "error verifying STXO proof: invalid " +
493
+ "taproot proof" ,
456
494
}, {
457
495
name : "stxo proof missing" ,
458
496
makeProof : func (t * testing.T ) []* Proof {
@@ -670,6 +708,31 @@ func TestVerifyV1ExclusionProof(t *testing.T) {
670
708
671
709
return p
672
710
},
711
+ }, {
712
+ name : "invalid v1 exclusion proof but with v0 version" ,
713
+ makeProof : func (t * testing.T ) []* Proof {
714
+ p , _ := makeV0InclusionProof (t )
715
+
716
+ // We now correctly prove that the asset isn't in the
717
+ // second output.
718
+ emptyCommitment , err := commitment .NewTapCommitment (nil )
719
+ require .NoError (t , err )
720
+
721
+ addV0ExclusionOutput (
722
+ t , p [0 ], emptyCommitment ,
723
+ p [0 ].Asset .TapCommitmentKey (),
724
+ p [0 ].Asset .AssetCommitmentKey (), internalKey , 1 ,
725
+ )
726
+
727
+ randAsset := makeTransferAsset (t )
728
+ addV1ExclusionProof (
729
+ t , p [0 ], * randAsset , emptyCommitment , 1 ,
730
+ )
731
+
732
+ return p
733
+ },
734
+ expectedErrContains : "error verifying v1 exclusion proof: " +
735
+ "missing STXO asset for key" ,
673
736
}, {
674
737
name : "multiple assets with an exclusion proof each" ,
675
738
makeProof : func (t * testing.T ) []* Proof {
0 commit comments