Skip to content

Commit 91690b7

Browse files
jharveybgijswijs
authored andcommitted
proof: add STXO inclusion proofs for non-splits
Co-authored-by: Gijs van Dam <[email protected]>
1 parent 55a5adc commit 91690b7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

proof/append.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,41 @@ func CreateTransitionProof(prevOut wire.OutPoint,
160160
TapSiblingPreimage: params.TapscriptSibling,
161161
}
162162

163+
if proof.Asset.IsTransferRoot() {
164+
stxoInclusionProofs := make(
165+
map[asset.SerializedKey]commitment.Proof,
166+
len(proof.Asset.PrevWitnesses),
167+
)
168+
for _, wit := range proof.Asset.PrevWitnesses {
169+
spentAsset, err := asset.MakeSpentAsset(wit)
170+
if err != nil {
171+
return nil, fmt.Errorf("error creating "+
172+
"altLeaf: %w", err)
173+
}
174+
175+
// Generate an STXO inclusion proof for each prev
176+
// witness.
177+
_, stxoProof, err := params.TaprootAssetRoot.Proof(
178+
asset.EmptyGenesisID,
179+
spentAsset.AssetCommitmentKey(),
180+
)
181+
if err != nil {
182+
return nil, err
183+
}
184+
keySerialized := asset.ToSerialized(
185+
spentAsset.ScriptKey.PubKey,
186+
)
187+
stxoInclusionProofs[keySerialized] = *stxoProof
188+
}
189+
190+
if len(stxoInclusionProofs) == 0 {
191+
return nil, fmt.Errorf("no stxo inclusion proofs")
192+
}
193+
194+
proof.InclusionProof.CommitmentProof.STXOProofs =
195+
stxoInclusionProofs
196+
}
197+
163198
// If the asset is a split asset, we also need to generate MS-SMT
164199
// inclusion proofs that prove the existence of the split root asset.
165200
if proof.Asset.HasSplitCommitmentWitness() {

0 commit comments

Comments
 (0)