Research/Bitcoin Dev Archive / lightning-dev list
AMP via HD, BN+SS, and TR
4 messages, Mar 19 to 20, 2018. Started by ZmnSCPxj.
ZmnSCPxj (3), Andrew Poelstra
Good morning list,
I sketch here the idea, of making atomic multipath payment (AMP), with the properties:
1. Has a proof-of-payment. 2. Multipath decorrelation.
Note: I am not a mathematician. Thus, it is likely, that there is a mistake here, and we cannot make this work.
First, we look at BIP32 hierarchically derived (HD) keys by Wuille. Roughly, given a parent private key k_par, we can do derive k_i child keys for integer i by:
k_i = H(i || k_par * G) + k_par
where H(x) is a hash function and G is the generator point. (this it not quite how BIP32 does it, it uses HMAC, maybe that is safer for some reason that my non-mathematician self is unaware of...)
The parent public key K_par = k_par * G. We can derive K_i public child keys for integer i by:
K_i = H(i || K_par) * G + K_par
(I think)
Note that K_i = k_i * G still, as is usual for elliptic curve asymmetric cryptography:
K_i = k_i * G = (H(i || k_par * G) + k_par) * G = H(i || k_par * G) * G + k_par * G = H(i || K_par) * G + K_par
Of note is that if we know an i, a private child key k_i corresponding to that i, and the public parent key K_par, we can derive the private parent key k_par:
k_i = H(i || K_par) + k_par
k_par = k_i - H(i || K_par)
Now all we need is to have a conditional payment, which can only be performed if the payee provides a private key which matches a public key, i.e. given x * G, the payee must provide x.
Fortunately Poelstra has done this work beforehand in the Scriptless Script (SS) concept, where the payee provides a T = t * G, and the Scriptless Script construction requires that the payee reveal the t in order to claim the payment. I will not go into the math since there is a good chance I shall make a mistake; look up discussions by better mathematicians by me. Scriptless Script requires Bellare-Neven (BN) signatures to work.
Note that Scriptless Script handles only the equivalent of hashlocking. We still need a timelock in case the payee refuses to reveal the proof-of-payment t.
Fortunately, Maxwell has provided a construction, taproot (TR). This construction has two top-level branches: a Bellare-Neven n-of-n, or a Bitcoin Script. We know that Scriptless Script can make an equivalent to a hashlock from a Bellare-Neven n-of-n. The other branch of a taproot construction can now be a simple OP_CLTV+OP_CHECKSIG script, forming the timelock half of an HTLC.
How would a multipath payment work? The invoice would contain the parent public key K_par. From this, the payer derives as many K_i, as it needs to split the payment to. It sets up conditional payments that require revelation of the private child key k_i for each K_i it derives.
When the payee receives a partial payment, it is not incentivized to claim it immediately yet. This is because revelation of even one child key k_i will, in combination with the parent public key K_par, reveal the parent private key k_par, which serves as proof-of-payment. The payee will wait for the entire payment to reach it, and then claim all of them. This reveals all the private child keys k_i, any one of which will let the payer extract the parent private key k_par that serves as proof-of-payment.
Each path has a different k_i, thus providing multipath decorrelation.
(Please check my math --- I am not a mathematician and it is possible I have made a mistake somewhere)
Regards, ZmnSCPXj
Hi ZmnSCPxj,
Yep, I'm pretty sure this works the way you describe -- essentially replace the hash challenges with adaptor signatures which are reblinded at each layer. Because adaptor signatures can make arbitrary sets of signatures atomic (and don't require any precommitments in the blockchain) it's easy to do multipath stuff this way. And using discrete logs as challenges makes reblinding and transferrable proof-of-payment easy.
It's also true that you can use BIP32 hardened keys for the challenges. You might as well use HMAC rather than a hash for the sake of standardness, but I don't think there's any particular reason to do this for key derivation.
Then Taproot can hide the non-cooperative cases as you mention.
I've been working on understanding Lightning and figuring out best way to use the full power of scriptless scripts. I think we can do better than just dropping TR+SS into the existing architecture. (Some of AJ's recent emails to the list have been one-sided commentary on ideas I floated to him in person recently, but I haven't had time to get everything straight enough in my mind to reply.)
For example, with adaptor signatures + Graftroot [1], one party can make their commit-tx signature atomic with a delegation to a timelock script; the other party does the same but for a different timelock script. Then maybe both parties can share the same commit tx rather than doing the symmetric thing, which would save space and simplify the protocol a bit. And more generally, this "output has different spend conditions depending on who publishes to the chain" primitive seems like a really powerful thing, and AFAIK nobody has noticed this feature of Graftroot until very recently.
Cheers
Andrew
[1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-February/015700.html
On Sun, Mar 18, 2018 at 08:25:13PM -0400, ZmnSCPxj via Lightning-dev wrote:
Quoted text (53 lines)
> Good morning list, > > I sketch here the idea, of making atomic multipath payment (AMP), with the properties: > > 1. Has a proof-of-payment. > 2. Multipath decorrelation. > > Note: I am not a mathematician. Thus, it is likely, that there is a mistake here, and we cannot make this work. > > First, we look at BIP32 hierarchically derived (HD) keys by Wuille. Roughly, given a parent private key k_par, we can do derive k_i child keys for integer i by: > > k_i = H(i || k_par * G) + k_par > > where H(x) is a hash function and G is the generator point. (this it not quite how BIP32 does it, it uses HMAC, maybe that is safer for some reason that my non-mathematician self is unaware of...) > > The parent public key K_par = k_par * G. We can derive K_i public child keys for integer i by: > > K_i = H(i || K_par) * G + K_par > > (I think) > > Note that K_i = k_i * G still, as is usual for elliptic curve asymmetric cryptography: > > K_i = k_i * G = (H(i || k_par * G) + k_par) * G = H(i || k_par * G) * G + k_par * G = H(i || K_par) * G + K_par > > Of note is that if we know an i, a private child key k_i corresponding to that i, and the public parent key K_par, we can derive the private parent key k_par: > > k_i = H(i || K_par) + k_par > > k_par = k_i - H(i || K_par) > > Now all we need is to have a conditional payment, which can only be performed if the payee provides a private key which matches a public key, i.e. given x * G, the payee must provide x. > > Fortunately Poelstra has done this work beforehand in the Scriptless Script (SS) concept, where the payee provides a T = t * G, and the Scriptless Script construction requires that the payee reveal the t in order to claim the payment. I will not go into the math since there is a good chance I shall make a mistake; look up discussions by better mathematicians by me. Scriptless Script requires Bellare-Neven (BN) signatures to work. > > Note that Scriptless Script handles only the equivalent of hashlocking. We still need a timelock in case the payee refuses to reveal the proof-of-payment t. > > Fortunately, Maxwell has provided a construction, taproot (TR). This construction has two top-level branches: a Bellare-Neven n-of-n, or a Bitcoin Script. We know that Scriptless Script can make an equivalent to a hashlock from a Bellare-Neven n-of-n. The other branch of a taproot construction can now be a simple OP_CLTV+OP_CHECKSIG script, forming the timelock half of an HTLC. > > How would a multipath payment work? The invoice would contain the parent public key K_par. From this, the payer derives as many K_i, as it needs to split the payment to. It sets up conditional payments that require revelation of the private child key k_i for each K_i it derives. > > When the payee receives a partial payment, it is not incentivized to claim it immediately yet. This is because revelation of even one child key k_i will, in combination with the parent public key K_par, reveal the parent private key k_par, which serves as proof-of-payment. The payee will wait for the entire payment to reach it, and then claim all of them. This reveals all the private child keys k_i, any one of which will let the payer extract the parent private key k_par that serves as proof-of-payment. > > Each path has a different k_i, thus providing multipath decorrelation. > > (Please check my math --- I am not a mathematician and it is possible I have made a mistake somewhere) > > Regards, > ZmnSCPXj > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev
Good morning Andrew,
Quoted text (5 lines)
> Hi ZmnSCPxj, > > Yep, I'm pretty sure this works the way you describe -- essentially replace > > the hash challenges with adaptor signatures which are reblinded at each layer.
Thank you very much your confirmation.
Quoted text (9 lines)
> For example, with adaptor signatures + Graftroot \[1\], one party can make their > > commit-tx signature atomic with a delegation to a timelock script; the other > > party does the same but for a different timelock script. Then maybe both parties > > can share the same commit tx rather than doing the symmetric thing, which would > > save space and simplify the protocol a bit.
Possibly not? On each pair of symmetric commitments, an output that is timelocked on one commitment transaction is not timelocked on the other commitment transaction, and that output is signable by the same party. E.g. in the simple case with a single output controlled by a single party A, A has a commitment transaction whose output is timelocked and unlockable by A, B has a commitment transaction whose output is only unlockable by A (and in particular not timelocked). Each side still needs its own commitment transaction I think.
(unless Graftroot is even more magical than how I understand it: my skills already strain trying to understand Scriptless Script and Taproot, so possibly I just do not understand Graftroot well enough)
Symmetry in commitment transactions is not particularly space-heavy. Well-behaved nodes will never bother storing old commitments and can delete those from disk, and you only need to store your own commitment --- the other commitment is the responsibility of the counterparty to store.
Quoted text (7 lines)
> And more generally, this "output > > has different spend conditions depending on who publishes to the chain" primitive > > seems like a really powerful thing, and AFAIK nobody has noticed this feature of > > Graftroot until very recently.
Ah, this is indeed very interesting!
Regards, ZmnSCPxj
Good morning list,
It is possible to mean atomic in multiple meanings:
1. The payee is completely unable to claim any partial payments until all partial payments arrive at the payee. 2. The payee is not incentivized to claim partial payments until all partial payments arrive at the payee.
My proposal uses "atomic" in the sense of #2. As soon as a single partial payment reveals a child key k_i, then with the know public parent key K_par it is possible to compute parent secret key k_par.
This is sufficient if k_par is valuable, for example if it is also the encryption key for valuable digital data such as some megabytes of a streamed movie, game downloadable content, ransomed files, etc. i.e. for ZKCP. The payee is incentivized to claim payments only if all partial payments reach it, since once it claims any sub-payment, it will also release the valuable secret k_par.
However, it is possible to upgrade from #2 to #1 by adding a secret from the payer to the payee that is sent "in pieces" for each sub-payment.
We add this payer secret p and modify our derivation as follows:
K_i = H(i || p || K_par) * G + K_par
k_i = H(i || p || k_par * G) + k_par
k_par can be derived if we know any i, k_i, p, and K_par:
k_par = k_i - H(i || p || K_par)
When splitting a single payment into two payments, the payer generates a hiding random number x_1.
When sending an onion payment, the onion payload contains pieces of the payer secret p. For example, in the 2-subpayment case:
sub-payment 1: p ^ x_1 sub-payment 2: x_1
This can be extended to any number of subpayments n:
sub-payment 1: p ^ x_1 ^ ... ^ x_n-1 sub-payment 2: x_1 ... sub-payment n: x_n-1
In this case, the payee truly cannot claim any sub-payment unless all sub-payments have reached it. When all sub-payments have reached it, it XORs all the pieces of the payer secret together to compute p.
The payee cannot derive k_i unless it knows i, p, and the secret k_par. Once at least one sub-payment is claimed, then the payer can derive the secret k_par.
Since offers on LN are HTLCs, there is a timelock involved. As long as the payee does not claim too close to the timelock, it has time to claim all sub-payments, even if only claiming one sub-payment is enough for the payer to derive the (potentially valuable) secret k_par.
Thus this scheme achieves atomicity in the sense "the payee cannot claim partial payments", not just "the payee is disincentivized to claim partial payments".
Regards, ZmnSCPxj
Sent with [ProtonMail](https://protonmail.com) Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On March 19, 2018 8:25 AM, ZmnSCPxj via Lightning-dev <lightning-dev at lists.linuxfoundation.org> wrote:
Quoted text (49 lines)
> Good morning list, > > I sketch here the idea, of making atomic multipath payment (AMP), with the properties: > > 1. Has a proof-of-payment. > 2. Multipath decorrelation. > > Note: I am not a mathematician. Thus, it is likely, that there is a mistake here, and we cannot make this work. > > First, we look at BIP32 hierarchically derived (HD) keys by Wuille. Roughly, given a parent private key k_par, we can do derive k_i child keys for integer i by: > > k_i = H(i || k_par * G) + k_par > > where H(x) is a hash function and G is the generator point. (this it not quite how BIP32 does it, it uses HMAC, maybe that is safer for some reason that my non-mathematician self is unaware of...) > > The parent public key K_par = k_par * G. We can derive K_i public child keys for integer i by: > > K_i = H(i || K_par) * G + K_par > > (I think) > > Note that K_i = k_i * G still, as is usual for elliptic curve asymmetric cryptography: > > K_i = k_i * G = (H(i || k_par * G) + k_par) * G = H(i || k_par * G) * G + k_par * G = H(i || K_par) * G + K_par > > Of note is that if we know an i, a private child key k_i corresponding to that i, and the public parent key K_par, we can derive the private parent key k_par: > > k_i = H(i || K_par) + k_par > > k_par = k_i - H(i || K_par) > > Now all we need is to have a conditional payment, which can only be performed if the payee provides a private key which matches a public key, i.e. given x * G, the payee must provide x. > > Fortunately Poelstra has done this work beforehand in the Scriptless Script (SS) concept, where the payee provides a T = t * G, and the Scriptless Script construction requires that the payee reveal the t in order to claim the payment. I will not go into the math since there is a good chance I shall make a mistake; look up discussions by better mathematicians by me. Scriptless Script requires Bellare-Neven (BN) signatures to work. > > Note that Scriptless Script handles only the equivalent of hashlocking. We still need a timelock in case the payee refuses to reveal the proof-of-payment t. > > Fortunately, Maxwell has provided a construction, taproot (TR). This construction has two top-level branches: a Bellare-Neven n-of-n, or a Bitcoin Script. We know that Scriptless Script can make an equivalent to a hashlock from a Bellare-Neven n-of-n. The other branch of a taproot construction can now be a simple OP_CLTV+OP_CHECKSIG script, forming the timelock half of an HTLC. > > How would a multipath payment work? The invoice would contain the parent public key K_par. From this, the payer derives as many K_i, as it needs to split the payment to. It sets up conditional payments that require revelation of the private child key k_i for each K_i it derives. > > When the payee receives a partial payment, it is not incentivized to claim it immediately yet. This is because revelation of even one child key k_i will, in combination with the parent public key K_par, reveal the parent private key k_par, which serves as proof-of-payment. The payee will wait for the entire payment to reach it, and then claim all of them. This reveals all the private child keys k_i, any one of which will let the payer extract the parent private key k_par that serves as proof-of-payment. > > Each path has a different k_i, thus providing multipath decorrelation. > > (Please check my math --- I am not a mathematician and it is possible I have made a mistake somewhere) > > Regards, > ZmnSCPXj