mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
swap: reserve multi-address key families
Reserve separate key families for static receive and change addresses. This keeps derived keys out of the legacy static-address and HTLC key streams.
This commit is contained in:
parent
6d1dbcb599
commit
1baf02e210
2 changed files with 35 additions and 2 deletions
|
|
@ -5,7 +5,16 @@ var (
|
|||
// spending of the htlc.
|
||||
KeyFamily = int32(99)
|
||||
|
||||
// StaticAddressKeyFamily is the key family used to generate static
|
||||
// address keys.
|
||||
// StaticAddressKeyFamily is the legacy static-address key family. It is
|
||||
// used for the V0 single static-address key and for static-address HTLC
|
||||
// keys.
|
||||
StaticAddressKeyFamily = int32(42060)
|
||||
|
||||
// StaticMultiAddressKeyFamily is the key family used to generate
|
||||
// externally visible multi-address static-address receive keys.
|
||||
StaticMultiAddressKeyFamily = int32(42061)
|
||||
|
||||
// StaticAddressChangeKeyFamily is the key family used to generate
|
||||
// static-address change outputs.
|
||||
StaticAddressChangeKeyFamily = int32(42062)
|
||||
)
|
||||
|
|
|
|||
24
swap/keychain_test.go
Normal file
24
swap/keychain_test.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package swap
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestStaticAddressKeyFamiliesAreDisjoint documents the key-family split used
|
||||
// by static-address HTLC, receive and change key derivation.
|
||||
func TestStaticAddressKeyFamiliesAreDisjoint(t *testing.T) {
|
||||
families := map[int32]string{
|
||||
KeyFamily: "swap htlc",
|
||||
StaticAddressKeyFamily: "legacy static address and htlc",
|
||||
StaticMultiAddressKeyFamily: "multi-address receive",
|
||||
StaticAddressChangeKeyFamily: "static-address change",
|
||||
}
|
||||
|
||||
require.Len(t, families, 4)
|
||||
require.EqualValues(t, 99, KeyFamily)
|
||||
require.EqualValues(t, 42060, StaticAddressKeyFamily)
|
||||
require.EqualValues(t, 42061, StaticMultiAddressKeyFamily)
|
||||
require.EqualValues(t, 42062, StaticAddressChangeKeyFamily)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue