Skip to content

Commit e12c0fd

Browse files
committed
fixup! proof: Add stxo exclusion proof verification
1 parent 0eebe3f commit e12c0fd

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

proof/taproot.go

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ var (
2525
ErrInvalidCommitmentProof = errors.New(
2626
"invalid Taproot Asset commitment proof",
2727
)
28+
29+
ErrStxoInputProofMissing = errors.New(
30+
"missing STXO input proof for Taproot Asset commitment",
31+
)
2832
)
2933

3034
// CommitmentProof represents a full commitment proof for an asset. It can

proof/verifier.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func (p *Proof) verifyInclusionProof() (*commitment.TapCommitment, error) {
193193

194194
if needStxoProofs && !hasStxoProofs {
195195
return nil, fmt.Errorf("%w: missing STXO proofs",
196-
ErrInvalidCommitmentProof)
196+
ErrStxoInputProofMissing)
197197
}
198198

199199
// We ignore the STXO proofs if the proof signals version 0, or if there
@@ -237,7 +237,7 @@ func (p *Proof) verifyInclusionProof() (*commitment.TapCommitment, error) {
237237
// missing proofs for those outputs.
238238
if len(p2trOutputs) > 0 {
239239
return nil, fmt.Errorf("%w: missing inclusion proof",
240-
ErrInvalidCommitmentProof)
240+
ErrStxoInputProofMissing)
241241
}
242242

243243
return v0Commitment, nil
@@ -303,7 +303,7 @@ func (p *Proof) verifyExclusionProofs() (*commitment.TapCommitmentVersion,
303303

304304
if needStxoProofs && !hasStxoProofs {
305305
return nil, fmt.Errorf("%w: missing STXO proofs",
306-
ErrInvalidCommitmentProof)
306+
ErrStxoInputProofMissing)
307307
}
308308

309309
// We ignore the STXO proofs if the proof signals version 0, or if there
@@ -411,7 +411,7 @@ func (p *Proof) verifyV1ExclusionProofs(p2trOutputs fn.Set[uint32]) error {
411411
// missing proofs for those outputs.
412412
if len(p2trOutputsSTXOs) > 0 {
413413
return fmt.Errorf("%w: missing STXO proofs",
414-
ErrInvalidCommitmentProof)
414+
ErrStxoInputProofMissing)
415415
}
416416

417417
return nil

proof/verifier_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func TestVerifyV1InclusionProof(t *testing.T) {
329329

330330
return p
331331
},
332-
expectedErr: ErrInvalidCommitmentProof,
332+
expectedErr: ErrStxoInputProofMissing,
333333
}, {
334334
name: "invalid v0 proof",
335335
makeProof: func(t *testing.T) []*Proof {
@@ -363,7 +363,7 @@ func TestVerifyV1InclusionProof(t *testing.T) {
363363

364364
return p
365365
},
366-
expectedErr: ErrInvalidCommitmentProof,
366+
expectedErr: ErrStxoInputProofMissing,
367367
expectedErrContains: "missing STXO proofs",
368368
}, {
369369
name: "correct v0 and v1 proofs",
@@ -439,7 +439,7 @@ func TestVerifyV1InclusionProof(t *testing.T) {
439439

440440
return p
441441
},
442-
expectedErr: ErrInvalidCommitmentProof,
442+
expectedErr: ErrStxoInputProofMissing,
443443
expectedErrContains: "missing inclusion proof",
444444
}, {
445445
name: "multiple valid stxo proofs",
@@ -602,7 +602,7 @@ func TestVerifyV1ExclusionProof(t *testing.T) {
602602

603603
return p
604604
},
605-
expectedErr: ErrInvalidCommitmentProof,
605+
expectedErr: ErrStxoInputProofMissing,
606606
expectedErrContains: "missing STXO proofs",
607607
}, {
608608
name: "correct v1 exclusion proof",
@@ -757,7 +757,7 @@ func TestVerifyV1ExclusionProof(t *testing.T) {
757757

758758
return p
759759
},
760-
expectedErr: ErrInvalidCommitmentProof,
760+
expectedErr: ErrStxoInputProofMissing,
761761
expectedErrContains: "missing STXO proofs",
762762
}}
763763

0 commit comments

Comments
 (0)