From dbcce82d52fea6ce091b14065eac4e648133e2ac Mon Sep 17 00:00:00 2001 From: Andrey Samokhvalov Date: Tue, 2 May 2017 02:25:32 +0300 Subject: [PATCH] lnwallet: make DeriveRevocationRoot public In order to be able to use the DeriveRevocationRoot in the createChannel function inside the htlcswicth package we need to make it public. NOTE: The original lnwallet.CreateChannel function haven't been sufficient as far it not takes the private keys as input. --- lnwallet/channel_test.go | 4 ++-- lnwallet/script_utils.go | 4 ++-- lnwallet/wallet.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go index 876dff4d..898f6694 100644 --- a/lnwallet/channel_test.go +++ b/lnwallet/channel_test.go @@ -202,7 +202,7 @@ func createTestChannels(revocationWindow int) (*LightningChannel, *LightningChan } fundingTxIn := wire.NewTxIn(prevOut, nil, nil) - bobRoot := deriveRevocationRoot(bobKeyPriv, bobKeyPub, aliceKeyPub) + bobRoot := DeriveRevocationRoot(bobKeyPriv, bobKeyPub, aliceKeyPub) bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot) bobFirstRevoke, err := bobPreimageProducer.AtIndex(0) if err != nil { @@ -210,7 +210,7 @@ func createTestChannels(revocationWindow int) (*LightningChannel, *LightningChan } bobRevokeKey := DeriveRevocationPubkey(aliceKeyPub, bobFirstRevoke[:]) - aliceRoot := deriveRevocationRoot(aliceKeyPriv, aliceKeyPub, bobKeyPub) + aliceRoot := DeriveRevocationRoot(aliceKeyPriv, aliceKeyPub, bobKeyPub) alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot) aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0) if err != nil { diff --git a/lnwallet/script_utils.go b/lnwallet/script_utils.go index e7f06257..c051d954 100644 --- a/lnwallet/script_utils.go +++ b/lnwallet/script_utils.go @@ -752,7 +752,7 @@ func DeriveRevocationPrivKey(commitPrivKey *btcec.PrivateKey, return privRevoke } -// deriveRevocationRoot derives an root unique to a channel given the +// DeriveRevocationRoot derives an root unique to a channel given the // private key for our public key in the 2-of-2 multi-sig, and the remote // node's multi-sig public key. The seed is derived using the HKDF[1][2] // instantiated with sha-256. The secret data used is our multi-sig private @@ -760,7 +760,7 @@ func DeriveRevocationPrivKey(commitPrivKey *btcec.PrivateKey, // // [1]: https://eprint.iacr.org/2010/264.pdf // [2]: https://tools.ietf.org/html/rfc5869 -func deriveRevocationRoot(derivationRoot *btcec.PrivateKey, +func DeriveRevocationRoot(derivationRoot *btcec.PrivateKey, localMultiSigKey *btcec.PublicKey, remoteMultiSigKey *btcec.PublicKey) *chainhash.Hash { diff --git a/lnwallet/wallet.go b/lnwallet/wallet.go index 04838982..d8395431 100644 --- a/lnwallet/wallet.go +++ b/lnwallet/wallet.go @@ -773,7 +773,7 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) { // Now that we have their commitment key, we can create the revocation // key for the first version of our commitment transaction. To do so, // we'll first create our root, then produce the first pre-image. - root := deriveRevocationRoot(masterElkremRoot, ourKey, theirKey) + root := DeriveRevocationRoot(masterElkremRoot, ourKey, theirKey) producer := shachain.NewRevocationProducer(*root) pendingReservation.partialState.RevocationProducer = producer firstPreimage, err := producer.AtIndex(0) @@ -914,7 +914,7 @@ func (l *LightningWallet) handleSingleContribution(req *addSingleContributionMsg // Now that we know their commitment key, we can create the revocation // key for our version of the initial commitment transaction. - root := deriveRevocationRoot(masterElkremRoot, ourKey, theirKey) + root := DeriveRevocationRoot(masterElkremRoot, ourKey, theirKey) producer := shachain.NewRevocationProducer(*root) firstPreimage, err := producer.AtIndex(0) if err != nil {