From 5bb3efba4c7f25562cafd3834841d858ae4d829b Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 12 Sep 2017 17:38:26 +0200 Subject: [PATCH] lnwallet: properly use the lsat 6-bytes of the sha hash for state hints This commit fixes an existing w.r.t the way that we constructed all commitment transactions. We were computing the hash that the obfsucator was derived form correctly, but we were using the first 6-bytes, rather than the last 6 bytes. --- lnwallet/wallet.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lnwallet/wallet.go b/lnwallet/wallet.go index 3824f654..4470e0ec 100644 --- a/lnwallet/wallet.go +++ b/lnwallet/wallet.go @@ -1347,7 +1347,7 @@ func (l *LightningWallet) deriveMasterRevocationRoot() (*btcec.PrivateKey, error // state hints from the root to be used for a new channel. The obsfucsator is // generated via the following computation: // -// * sha256(initiatorKey || responderKey)[:6] +// * sha256(initiatorKey || responderKey)[26:] // * where both keys are the multi-sig keys of the respective parties // // The first 6 bytes of the resulting hash are used as the state hint. @@ -1359,7 +1359,7 @@ func deriveStateHintObfuscator(key1, key2 *btcec.PublicKey) [StateHintSize]byte sha := h.Sum(nil) var obfuscator [StateHintSize]byte - copy(obfuscator[:], sha[:]) + copy(obfuscator[:], sha[26:]) return obfuscator }