mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-14 10:29:29 +02:00
watchtower/multi: use new blob.BreachKey for enc/dec of justice kits
This commit is contained in:
@@ -202,13 +202,16 @@ func (l *Lookout) processEpoch(epoch *chainntnfs.BlockEpoch,
|
||||
|
||||
// The decryption key for the state update should be the full
|
||||
// txid of the breaching commitment transaction.
|
||||
commitTxID := commitTx.TxHash()
|
||||
// The decryption key for the state update should be computed as
|
||||
// key = SHA256(txid).
|
||||
breachTxID := commitTx.TxHash()
|
||||
breachKey := blob.NewBreachKeyFromHash(&breachTxID)
|
||||
|
||||
// Now, decrypt the blob of justice that we received in the
|
||||
// state update. This will contain all information required to
|
||||
// sweep the breached commitment outputs.
|
||||
justiceKit, err := blob.Decrypt(
|
||||
commitTxID[:], match.EncryptedBlob,
|
||||
breachKey, match.EncryptedBlob,
|
||||
match.SessionInfo.Policy.BlobType,
|
||||
)
|
||||
if err != nil {
|
||||
|
@@ -148,14 +148,17 @@ func TestLookoutBreachMatching(t *testing.T) {
|
||||
CommitToLocalSig: makeArray64(2),
|
||||
}
|
||||
|
||||
// Encrypt the first justice kit under the txid of the first txn.
|
||||
encBlob1, err := blob1.Encrypt(hash1[:], blob.FlagCommitOutputs.Type())
|
||||
key1 := blob.NewBreachKeyFromHash(&hash1)
|
||||
key2 := blob.NewBreachKeyFromHash(&hash2)
|
||||
|
||||
// Encrypt the first justice kit under breach key one.
|
||||
encBlob1, err := blob1.Encrypt(key1, blob.FlagCommitOutputs.Type())
|
||||
if err != nil {
|
||||
t.Fatalf("unable to encrypt sweep detail 1: %v", err)
|
||||
}
|
||||
|
||||
// Encrypt the second justice kit under the txid of the second txn.
|
||||
encBlob2, err := blob2.Encrypt(hash2[:], blob.FlagCommitOutputs.Type())
|
||||
// Encrypt the second justice kit under breach key two.
|
||||
encBlob2, err := blob2.Encrypt(key2, blob.FlagCommitOutputs.Type())
|
||||
if err != nil {
|
||||
t.Fatalf("unable to encrypt sweep detail 2: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user