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.
This commit is contained in:
parent
f774e3d9bf
commit
dbcce82d52
@ -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 {
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user