Skip to content

Commit 7af5271

Browse files
committed
wip: proof version bump
1 parent 5a922a7 commit 7af5271

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

proof/mint.go

+6
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@ func baseProof(params *BaseProofParams, prevOut wire.OutPoint) (*Proof, error) {
307307
}
308308
proof.ExclusionProofs = params.ExclusionProofs
309309

310+
// We set the proof version to V1, which is the first version that
311+
// supports STXO proofs for root transfer assets. A root transfer is an
312+
// asset that is neither a genesis asset nor contains split commitment
313+
// witness data.
314+
proof.Version = TransitionV1
315+
310316
return proof, nil
311317
}
312318

proof/proof.go

+13
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ type TransitionVersion uint32
228228
const (
229229
// TransitionV0 is the first version of the state transition proof.
230230
TransitionV0 TransitionVersion = 0
231+
232+
TransitionV1 TransitionVersion = 1
231233
)
232234

233235
// Proof encodes all of the data necessary to prove a valid state transition for
@@ -485,11 +487,22 @@ func (p *Proof) IsUnknownVersion() bool {
485487
switch p.Version {
486488
case TransitionV0:
487489
return false
490+
case TransitionV1:
491+
return false
488492
default:
489493
return true
490494
}
491495
}
492496

497+
// IsUnknownVersion returns true if a proof has a version that is not recognized
498+
// by this implementation of tap.
499+
func (p *Proof) IsVersionV1() bool {
500+
if p.Version == TransitionV1 {
501+
return true
502+
}
503+
return false
504+
}
505+
493506
// ToChainAsset converts the proof to a ChainAsset.
494507
func (p *Proof) ToChainAsset() (asset.ChainAsset, error) {
495508
emptyAsset := asset.ChainAsset{}

proof/verifier.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ func verifyTaprootProof(anchor *wire.MsgTx, proof *TaprootProof,
170170
// verifyInclusionProof verifies the InclusionProof is valid.
171171
func (p *Proof) verifyInclusionProof() (*commitment.TapCommitment, error) {
172172
// Determine if we're dealing with v0 or v1 proofs.
173-
hasV1Proofs := p.InclusionProof.CommitmentProof != nil &&
173+
hasV1Proofs := p.IsVersionV1() &&
174+
p.InclusionProof.CommitmentProof != nil &&
174175
len(p.InclusionProof.CommitmentProof.STXOProofs) > 0
175176

176177
if !hasV1Proofs {
@@ -251,7 +252,8 @@ func (p *Proof) verifyExclusionProofs() (*commitment.TapCommitmentVersion,
251252
}
252253

253254
// Early pass to determine if we're dealing with v0 or v1 proofs.
254-
hasV1Proofs := len(p.ExclusionProofs) > 0 &&
255+
hasV1Proofs := p.IsVersionV1() &&
256+
len(p.ExclusionProofs) > 0 &&
255257
p.ExclusionProofs[0].CommitmentProof != nil &&
256258
len(p.ExclusionProofs[0].CommitmentProof.STXOProofs) > 0
257259

0 commit comments

Comments
 (0)