You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Create fresh destination/shutdown scripts for each channel in KeysManager #1139
The trait tells us to, for privacy, but we ignore it. While we're at it, we should probably merge destination + shutdown scripts cause they don't need to be separate. When we do this we need to ensure we bump some serialization version so that old clients don't read new KeysManager and not know about keys.
I had a look at the keysinterface and had two questions:
In the implementation for the Keysinterface for KeysManager, the functions returning the destination and shutdown script return a clone of the script. Does a fresh script mean using the pubkey to recreate the scripts again via the p2wsh or p2wpkh methods?
What does it mean to merge two different scripts? How do you hold information about two different scripts in one? From what I see some of the methods do have some assertions on the shutdown_pubkey, so if we did have a single merged script how would I generate the required shutdown key to replace the same assertion?
In the implementation for the Keysinterface for KeysManager, the functions returning the destination and shutdown script return a clone of the script. Does a fresh script mean using the pubkey to recreate the scripts again via the p2wsh or p2wpkh methods?
No, it would mean creating a whole new script using some deterministic derivation path.
What does it mean to merge two different scripts? How do you hold information about two different scripts in one? From what I see some of the methods do have some assertions on the shutdown_pubkey, so if we did have a single merged script how would I generate the required shutdown key to replace the same assertion?
Oops I'm so sorry I managed to let this fall off my radar.
To create a new public key, look at how we derive keys from the master now, and do something similar, except likely a second layer HD path (ie derive a key and then use that as a new master). That way we can just extend that HD path arbitrarily and create as many pubkeys as we want. Happy to point to specific code if you need, just let me know.
Right, we should drop the destination_script logic, take the shutdown_pubkey and keep it as an ExtendedPubKey, deriving new children and then building both a destination and shutdown pubkey with it per-channel.
@TheBlueMatt In the last part of spend_spendable_outputs, we get the derivation_idx by comparing destination_script and output.script_pubkey. How do I use the ExtendedPubKey to create the destination_script? I see that there is a method called ckd_pub to derive public child key but the secp_ctx that it requires(Verification trait) is not available in this particular function.
I think we should include the channel_keys_id in SpendableOutputDescriptor::StaticOutput and use the first 8 bytes (I think HD counters are 8 bytes?) of the channel_keys_id as the key derivation index.
When we do this we should also make the payment_key in the channel less reliant on as much entropy, so that it can theoretically be derived from the seed if we have to (maybe 32-bits of entropy or something smaller).
Activity
vss96 commentedon Jan 24, 2022
I had a look at the keysinterface and had two questions:
TheBlueMatt commentedon Jan 24, 2022
No, it would mean creating a whole new script using some deterministic derivation path.
As in, just use the same script in both places.
vss96 commentedon Jan 25, 2022
Need some context here 😓
TheBlueMatt commentedon Feb 4, 2022
Oops I'm so sorry I managed to let this fall off my radar.
To create a new public key, look at how we derive keys from the master now, and do something similar, except likely a second layer HD path (ie derive a key and then use that as a new master). That way we can just extend that HD path arbitrarily and create as many pubkeys as we want. Happy to point to specific code if you need, just let me know.
vss96 commentedon Feb 7, 2022
@TheBlueMatt i guess this is what you meant? (new method from KeysManager)
TheBlueMatt commentedon Feb 8, 2022
Right, we should drop the
destination_scriptlogic, take theshutdown_pubkeyand keep it as anExtendedPubKey, deriving new children and then building both a destination and shutdown pubkey with it per-channel.vss96 commentedon Feb 9, 2022
@TheBlueMatt In the last part of
spend_spendable_outputs, we get the derivation_idx by comparingdestination_scriptandoutput.script_pubkey. How do I use theExtendedPubKeyto create the destination_script? I see that there is a method calledckd_pubto derive public child key but the secp_ctx that it requires(Verification trait) is not available in this particular function.TheBlueMatt commentedon Feb 9, 2022
I think we should include the
channel_keys_idinSpendableOutputDescriptor::StaticOutputand use the first 8 bytes (I think HD counters are 8 bytes?) of the channel_keys_id as the key derivation index.TheBlueMatt commentedon Jul 15, 2023
When we do this we should also make the payment_key in the channel less reliant on as much entropy, so that it can theoretically be derived from the seed if we have to (maybe 32-bits of entropy or something smaller).
TheBlueMatt commentedon Jul 15, 2023
Gonna mark this 117 cause we at least should do the above sooner rather than later.
TheBlueMatt commentedon Dec 5, 2024
Unlikely we can get to this in time for 0.1 and there's no use delaying the release for this.
Add changelog entry for (lightningdevkit#1139)