Skip to content

Commit 3192a7e

Browse files
guggerogijswijs
authored andcommitted
multi: disable STXO proof generation for channels
Since we already disable creating the STXO commitments for TAP channels, we also need to disable creating the proofs for them, as they would be invalid anyway.
1 parent 65eb88f commit 3192a7e

File tree

7 files changed

+38
-11
lines changed

7 files changed

+38
-11
lines changed

proof/append.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ import (
1414
// GenConfig is a struct that holds the configuration for creating Taproot Asset
1515
// proofs.
1616
type GenConfig struct {
17-
// transitionVersion is the version of the asset state transition proof
17+
// TransitionVersion is the version of the asset state transition proof
1818
// that is going to be used.
19-
transitionVersion TransitionVersion
19+
TransitionVersion TransitionVersion
20+
21+
// NoSTXOProofs indicates whether to skip the generation of STXO
22+
// inclusion and exclusion proofs for the transition proof.
23+
NoSTXOProofs bool
2024
}
2125

2226
// DefaultGenConfig returns a default proof generation configuration.
2327
func DefaultGenConfig() GenConfig {
2428
return GenConfig{
25-
transitionVersion: TransitionV0,
29+
TransitionVersion: TransitionV0,
2630
}
2731
}
2832

@@ -34,7 +38,15 @@ type GenOption func(*GenConfig)
3438
// given version.
3539
func WithVersion(v TransitionVersion) GenOption {
3640
return func(cfg *GenConfig) {
37-
cfg.transitionVersion = v
41+
cfg.TransitionVersion = v
42+
}
43+
}
44+
45+
// WithNoSTXOProofs is an option that can be used to skip the generation of
46+
// STXO inclusion and exclusion proofs for the transition proof.
47+
func WithNoSTXOProofs() GenOption {
48+
return func(cfg *GenConfig) {
49+
cfg.NoSTXOProofs = true
3850
}
3951
}
4052

@@ -158,7 +170,7 @@ func CreateTransitionProof(prevOut wire.OutPoint, params *TransitionParams,
158170
}
159171

160172
proof, err := baseProof(
161-
&params.BaseProofParams, prevOut, cfg.transitionVersion,
173+
&params.BaseProofParams, prevOut, cfg.TransitionVersion,
162174
)
163175
if err != nil {
164176
return nil, fmt.Errorf("error creating base proofs: %w", err)
@@ -194,7 +206,7 @@ func CreateTransitionProof(prevOut wire.OutPoint, params *TransitionParams,
194206
TapSiblingPreimage: params.TapscriptSibling,
195207
}
196208

197-
if proof.Asset.IsTransferRoot() {
209+
if proof.Asset.IsTransferRoot() && !cfg.NoSTXOProofs {
198210
stxoInclusionProofs := make(
199211
map[asset.SerializedKey]commitment.Proof,
200212
len(proof.Asset.PrevWitnesses),

proof/mint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func NewMintingBlobs(params *MintParams, vCtx VerifierCtx,
266266

267267
base, err := baseProof(
268268
&params.BaseProofParams, params.GenesisPoint,
269-
opts.genConfig.transitionVersion,
269+
opts.genConfig.TransitionVersion,
270270
)
271271
if err != nil {
272272
return nil, err

tapchannel/aux_closer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ func (a *AuxChanCloser) FinalizeClose(desc chancloser.AuxCloseDesc,
726726
proofSuffix, err := tapsend.CreateProofSuffixCustom(
727727
closeTx, vPkt, closeInfo.outputCommitments,
728728
outIdx, closeInfo.vPackets, exclusionCreator,
729+
proof.WithNoSTXOProofs(),
729730
)
730731
if err != nil {
731732
return fmt.Errorf("unable to create proof "+

tapchannel/aux_funding_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ func (f *FundingController) anchorVPackets(fundedPkt *tapsend.FundedPsbt,
11141114
proofSuffix, err := tapsend.CreateProofSuffix(
11151115
fundedPkt.Pkt.UnsignedTx, fundedPkt.Pkt.Outputs,
11161116
vPkt, outputCommitments, vOutIdx, allPackets,
1117+
proof.WithNoSTXOProofs(),
11171118
)
11181119
if err != nil {
11191120
return nil, fmt.Errorf("unable to create "+

tapchannel/aux_sweeper.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,7 @@ func (a *AuxSweeper) importCommitTx(req lnwallet.ResolutionReq,
16121612
proofSuffix, err := tapsend.CreateProofSuffixCustom(
16131613
req.CommitTx, vPkt, outCommitments, outIdx,
16141614
vPackets, exclusionCreator,
1615+
proof.WithNoSTXOProofs(),
16151616
)
16161617
if err != nil {
16171618
return fmt.Errorf("unable to create "+
@@ -2450,7 +2451,7 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest,
24502451

24512452
proofSuffix, err := tapsend.CreateProofSuffixCustom(
24522453
sweepTx, vPkt, outCommitments, outIdx, allVpkts,
2453-
exclusionCreator,
2454+
exclusionCreator, proof.WithNoSTXOProofs(),
24542455
)
24552456
if err != nil {
24562457
return fmt.Errorf("unable to create proof "+

tapchannel/commitment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ func GenerateCommitmentAllocations(prevState *cmsg.Commitment,
612612
fakeCommitTx, vPkt, outCommitments, outIdx,
613613
vPackets, tapsend.NonAssetExclusionProofs(
614614
allocations,
615-
),
615+
), proof.WithNoSTXOProofs(),
616616
)
617617
if err != nil {
618618
return nil, nil, fmt.Errorf("unable to create "+

tapsend/proof.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,14 @@ func CreateProofSuffixCustom(finalTx *wire.MsgTx, vPacket *tappsbt.VPacket,
155155

156156
inputPrevID := vPacket.Inputs[0].PrevID
157157

158+
cfg := proof.DefaultGenConfig()
159+
for _, opt := range opts {
160+
opt(&cfg)
161+
}
162+
158163
params, err := proofParams(
159164
finalTx, vPacket, outputCommitments, outIndex,
160-
allAnchoredVPackets,
165+
allAnchoredVPackets, cfg.NoSTXOProofs,
161166
)
162167
if err != nil {
163168
return nil, err
@@ -233,7 +238,8 @@ func newParams(finalTx *wire.MsgTx, a *asset.Asset, outputIndex int,
233238
// proofs for the sender and receiver.
234239
func proofParams(finalTx *wire.MsgTx, vPkt *tappsbt.VPacket,
235240
outputCommitments tappsbt.OutputCommitments, outIndex int,
236-
allAnchoredVPackets []*tappsbt.VPacket) (*proof.TransitionParams, error) {
241+
allAnchoredVPackets []*tappsbt.VPacket,
242+
noStxoProofs bool) (*proof.TransitionParams, error) {
237243

238244
isSplit, err := vPkt.HasSplitCommitment()
239245
if err != nil {
@@ -269,6 +275,12 @@ func proofParams(finalTx *wire.MsgTx, vPkt *tappsbt.VPacket,
269275
outputCommitments,
270276
)
271277

278+
// If we don't require STXO exclusion proofs, then we are done
279+
// here.
280+
if noStxoProofs {
281+
return rootParams, err
282+
}
283+
272284
// Add STXO exclusion proofs for all the other outputs, for all
273285
// STXOs spent by _all_ VOutputs that anchor in this output.
274286
// First Collect all STXOs for this anchor output. Then add

0 commit comments

Comments
 (0)