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)
|
fundingTxIn := wire.NewTxIn(prevOut, nil, nil)
|
||||||
|
|
||||||
bobRoot := deriveRevocationRoot(bobKeyPriv, bobKeyPub, aliceKeyPub)
|
bobRoot := DeriveRevocationRoot(bobKeyPriv, bobKeyPub, aliceKeyPub)
|
||||||
bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot)
|
bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot)
|
||||||
bobFirstRevoke, err := bobPreimageProducer.AtIndex(0)
|
bobFirstRevoke, err := bobPreimageProducer.AtIndex(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -210,7 +210,7 @@ func createTestChannels(revocationWindow int) (*LightningChannel, *LightningChan
|
|||||||
}
|
}
|
||||||
bobRevokeKey := DeriveRevocationPubkey(aliceKeyPub, bobFirstRevoke[:])
|
bobRevokeKey := DeriveRevocationPubkey(aliceKeyPub, bobFirstRevoke[:])
|
||||||
|
|
||||||
aliceRoot := deriveRevocationRoot(aliceKeyPriv, aliceKeyPub, bobKeyPub)
|
aliceRoot := DeriveRevocationRoot(aliceKeyPriv, aliceKeyPub, bobKeyPub)
|
||||||
alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot)
|
alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot)
|
||||||
aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0)
|
aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -752,7 +752,7 @@ func DeriveRevocationPrivKey(commitPrivKey *btcec.PrivateKey,
|
|||||||
return privRevoke
|
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
|
// 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]
|
// 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
|
// 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
|
// [1]: https://eprint.iacr.org/2010/264.pdf
|
||||||
// [2]: https://tools.ietf.org/html/rfc5869
|
// [2]: https://tools.ietf.org/html/rfc5869
|
||||||
func deriveRevocationRoot(derivationRoot *btcec.PrivateKey,
|
func DeriveRevocationRoot(derivationRoot *btcec.PrivateKey,
|
||||||
localMultiSigKey *btcec.PublicKey,
|
localMultiSigKey *btcec.PublicKey,
|
||||||
remoteMultiSigKey *btcec.PublicKey) *chainhash.Hash {
|
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
|
// Now that we have their commitment key, we can create the revocation
|
||||||
// key for the first version of our commitment transaction. To do so,
|
// key for the first version of our commitment transaction. To do so,
|
||||||
// we'll first create our root, then produce the first pre-image.
|
// 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)
|
producer := shachain.NewRevocationProducer(*root)
|
||||||
pendingReservation.partialState.RevocationProducer = producer
|
pendingReservation.partialState.RevocationProducer = producer
|
||||||
firstPreimage, err := producer.AtIndex(0)
|
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
|
// Now that we know their commitment key, we can create the revocation
|
||||||
// key for our version of the initial commitment transaction.
|
// key for our version of the initial commitment transaction.
|
||||||
root := deriveRevocationRoot(masterElkremRoot, ourKey, theirKey)
|
root := DeriveRevocationRoot(masterElkremRoot, ourKey, theirKey)
|
||||||
producer := shachain.NewRevocationProducer(*root)
|
producer := shachain.NewRevocationProducer(*root)
|
||||||
firstPreimage, err := producer.AtIndex(0)
|
firstPreimage, err := producer.AtIndex(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user