lnwire: add new HtlcPoint to OpenChannel and AcceptChannel
In this commit, we begin implementing the latest spec change to reduce the attack surface on online channels. In this commit, we introduce a distinct HTLC base point which will be used to sign the second-level HTLC transactions for each active HLTC on the commitment transaction of the remote node. With this, we allow the commitment key to remain offline, as it isn’t needed in routine channel updates, unless we need to go to chain.
This commit is contained in:
parent
caec23a236
commit
a14a15641b
@ -75,6 +75,12 @@ type AcceptChannel struct {
|
||||
// where they claim funds.
|
||||
DelayedPaymentPoint *btcec.PublicKey
|
||||
|
||||
// HtlcPoint is the base point used to derive the set of keys for this
|
||||
// party that will be used within the HTLC public key scripts. This
|
||||
// value is combined with the receiver's revocation base point in order
|
||||
// to derive the keys that are used within HTLC scripts.
|
||||
HtlcPoint *btcec.PublicKey
|
||||
|
||||
// FirstCommitmentPoint is the first commitment point for the sending
|
||||
// party. This value should be combined with the receiver's revocation
|
||||
// base point in order to derive the revocation keys that are placed
|
||||
@ -105,6 +111,7 @@ func (a *AcceptChannel) Encode(w io.Writer, pver uint32) error {
|
||||
a.RevocationPoint,
|
||||
a.PaymentPoint,
|
||||
a.DelayedPaymentPoint,
|
||||
a.HtlcPoint,
|
||||
a.FirstCommitmentPoint,
|
||||
)
|
||||
}
|
||||
@ -128,6 +135,7 @@ func (a *AcceptChannel) Decode(r io.Reader, pver uint32) error {
|
||||
&a.RevocationPoint,
|
||||
&a.PaymentPoint,
|
||||
&a.DelayedPaymentPoint,
|
||||
&a.HtlcPoint,
|
||||
&a.FirstCommitmentPoint,
|
||||
)
|
||||
}
|
||||
@ -145,6 +153,6 @@ func (a *AcceptChannel) MsgType() MessageType {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (a *AcceptChannel) MaxPayloadLength(uint32) uint32 {
|
||||
// 32 + (8 * 4) + (4 * 1) + (2 * 2) + (33 * 5)
|
||||
return 237
|
||||
// 32 + (8 * 4) + (4 * 1) + (2 * 2) + (33 * 6)
|
||||
return 270
|
||||
}
|
||||
|
@ -188,6 +188,11 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
t.Fatalf("unable to generate key: %v", err)
|
||||
return
|
||||
}
|
||||
req.HtlcPoint, err = randPubKey()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate key: %v", err)
|
||||
return
|
||||
}
|
||||
req.FirstCommitmentPoint, err = randPubKey()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate key: %v", err)
|
||||
@ -233,6 +238,11 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
t.Fatalf("unable to generate key: %v", err)
|
||||
return
|
||||
}
|
||||
req.HtlcPoint, err = randPubKey()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate key: %v", err)
|
||||
return
|
||||
}
|
||||
req.FirstCommitmentPoint, err = randPubKey()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate key: %v", err)
|
||||
|
@ -102,6 +102,12 @@ type OpenChannel struct {
|
||||
// where they claim funds.
|
||||
DelayedPaymentPoint *btcec.PublicKey
|
||||
|
||||
// HtlcPoint is the base point used to derive the set of keys for this
|
||||
// party that will be used within the HTLC public key scripts. This
|
||||
// value is combined with the receiver's revocation base point in order
|
||||
// to derive the keys that are used within HTLC scripts.
|
||||
HtlcPoint *btcec.PublicKey
|
||||
|
||||
// FirstCommitmentPoint is the first commitment point for the sending
|
||||
// party. This value should be combined with the receiver's revocation
|
||||
// base point in order to derive the revocation keys that are placed
|
||||
@ -141,6 +147,7 @@ func (o *OpenChannel) Encode(w io.Writer, pver uint32) error {
|
||||
o.RevocationPoint,
|
||||
o.PaymentPoint,
|
||||
o.DelayedPaymentPoint,
|
||||
o.HtlcPoint,
|
||||
o.FirstCommitmentPoint,
|
||||
o.ChannelFlags,
|
||||
)
|
||||
@ -168,6 +175,7 @@ func (o *OpenChannel) Decode(r io.Reader, pver uint32) error {
|
||||
&o.RevocationPoint,
|
||||
&o.PaymentPoint,
|
||||
&o.DelayedPaymentPoint,
|
||||
&o.HtlcPoint,
|
||||
&o.FirstCommitmentPoint,
|
||||
&o.ChannelFlags,
|
||||
)
|
||||
@ -186,6 +194,6 @@ func (o *OpenChannel) MsgType() MessageType {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (o *OpenChannel) MaxPayloadLength(uint32) uint32 {
|
||||
// (32 * 2) + (8 * 6) + (4 * 1) + (2 * 2) + (33 * 5) + 1
|
||||
return 286
|
||||
// (32 * 2) + (8 * 6) + (4 * 1) + (2 * 2) + (33 * 6) + 1
|
||||
return 319
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user