lnwallet: integrate new taproot channels into internal funding flow
In this commit, we build on all the prior commits and integrate the new taproot channels into the existing internal funding flow. Along the way, we do some refactoring to unify things like signing and verifying incoming commitment transaction signatures. For our local nonce, we use the existing functional option type to derive the nonce based on the initial shachain pre-image we'll use as our revocation.
This commit is contained in:
6 files changed
+315
-108
No files matched your search
@@ -2,12 +2,15 @@ package lnwallet
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
@@ -545,3 +548,27 @@ func NewMusigPairSession(cfg *MusigSessionCfg) *MusigPairSession {
|
||||
signer: cfg.Signer,
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
// taprootRevRootKey is the key used to derive the revocation root for
|
||||
// the taproot nonces. This is done via HMAC of the existing revocation
|
||||
// root.
|
||||
taprootRevRootKey = []byte("taproot-rev-root")
|
||||
)
|
||||
|
||||
// deriveMusig2Shachain derives a shachain producer for the taproot channel
|
||||
// from normal shachain revocation root.
|
||||
func deriveMusig2Shachain(revRoot chainhash.Hash) (shachain.Producer, error) {
|
||||
// For taproot channel types, we'll also generate a distinct shachain
|
||||
// root using the same seed information. We'll use this to generate
|
||||
// verification nonces for the channel. We'll bind with this a simple
|
||||
// hmac.
|
||||
taprootRevHmac := hmac.New(sha256.New, taprootRevRootKey)
|
||||
taprootRevRoot := taprootRevHmac.Sum(nil)
|
||||
|
||||
// Once we have the root, we can then generate our shachain producer
|
||||
// and from that generate the per-commitment point.
|
||||
return shachain.NewRevocationProducerFromBytes(
|
||||
taprootRevRoot,
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user