Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Data piggybacking within the payment_preimage for offline payments in wallets

4 messages, Dec 17 to 20, 2018. Started by ZmnSCPxj.

ZmnSCPxj (3), Jose Femenías Cañuelo

Permalink First message in the Wayback Machine

ZmnSCPxj permalink original

Good morning JOSE,

Quoted text (1 line)
>  An offline device (say a vending machine) shares a secret S1 with an online LN Node.

Is this the same problem that is solved by: https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/offline-lightning-enabled-vending-machines#m-ffb6496e ?

I believe the solution presented at the summit is superior technology-wise.

1.  The offline device holds no secrets.  Hacking it (if somehow possible) is thus not incentivized.
2.  The offline device can verify the hashes it holds in memory come from its owner.  Invoices require a signature, and invoices include the payment hash.  A payment hash stored in the offline device is thus committed to in the signature of the invoice, and the invoice signature can be verified.
3.  It works as-is without additions to the BOLT spec or to current wallets.

The only problem is that the hash preimage is 32 bytes. But if an invoice can acceptably be sent via QR code, why cannot hash preimages also? (it may simplify the design of the vending machine, which now needs only present a standard keypad for a PIN)

6-digit decimal codes may be acceptable. Given about 1 second to enter 6 digits (superhuman speed) it would take about 6 days or so to go through about half the space of 6-digit decimal codes. Perhaps the vending machine can simply delay if too many failing 6-digit decimal codes are entered. At the same time, it is easier for meat-based humans to remember and enter a mere 6-digit decimal code.

Perhaps a compromise is possible.

Let me propose this instead, which again *requires no changes to BOLT spec or special changes in wallet implementations*.

1.  The online LN node prepares a set of invoices.
    * The first 6 hexadecimal digits of the preimages are restricted to the set of decimal digits (or just put 6 more keys into your keypad, of course meat-based humans can understand letters too).
    * The succeeding 58 digits of the preimage are a salt.
2.  The offline vending machine stores the payment hash, salt, and invoice signature from the online LN node.
3.  When a customer arrives and indicates desire to purchase, the offline vending machine presents one of the unclaimed invoices.
4.  Upon paying, the vending machine instructs the customer to enter the first 6 digits of the payment preimage.
5.  The vending machine looks through its list of unclaimed invoices to find one where the 6 digits, concatenated with the salt, hash to the given payment hash.
    * If so, it marks that invoice as used and dispenses the product.
    * Otherwise, it is a failure and the vending machine will delay.

Regards, ZmnSCPxj

Jose Femenías Cañuelo in reply to ZmnSCPxj permalink original
ZmnSCPxj in reply to Jose Femenías Cañuelo permalink original

Good morning Jose,

Quoted text (1 line)
> Anyway, my point here is that it is actually desirable having both standards and modified wallets, to radically increase usability, which will be needed if we want to have widespread adoption of LN payments.

This is badly undesirable. We should have standard wallets that can talk to other standard-following software well. Modifications to wallets are dangerous in many ways, as well as greatly increasing effort overall.

Quoted text (2 lines)
>
> The biggest drawback to the system you propose is -IMHO- the logistics needed for replenishing the hashes into offline vending machines. The system I propose only requires an initial configuration of the machine with the shared secret for an unlimited series of payments.

Do your vending machines generate product out of quantum foam, like I sometimes do on a boring afternoon? Or are they replenished as they run out of product?

Each product sold is one invoice claimed. Thus, replenishing of products, is same operation as replenishing of invoices. You have to open the vending machine anyway to replenish its stock of products for sale. While your technician is replenishing the machine and doing whatever basic checks, your technician also replaces a EEPROM board with a new EEPROM board with fresh invoices. Even tiny EEPROM chip can hold enough data to support thousands of invoices. And it is unlikely you would fill a vending machine with thousands of product.

Quoted text (4 lines)
>
> I still have a few doubts however on how the scheme you propose would handle these concerns:
>
> a) Price changes: With the piggybacking scheme I propose, the vending machine (or toll both, or whatever) doesn't set the price of the item or service. It only sends the product/service Id to the remote LN Node. This way, prices can be adjusted in real time.

Why would you sell products with widely fluctuating BTC value? We sell products with a fixed BTC value! And because BTC is deflationary, BTC value of product will never change. We can see very readily that BTC price relative to dollar does not change except for dollar inflation rate and there is no such thing as massive bear market.

Note that what you want is not an invoice system. What you want is a static offer system. I suggest to look at Rusty proposal for static offers. https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/strawman-bolt11-static-offer-format-using-probes#m-544d9d2f

Quoted text (2 lines)
>
> b) Static QR codes: Again, the piggybacking scheme allows for static QR codes to be used by having an implicit transaction Id (the timestamp in 30 seconds  increments).

Same as above.

Quoted text (2 lines)
>
> c) Privacy and security: By sending the six digits code in the clear, within the preimage, intermediate nodes have access to this information. I think that poses both a privacy and a security problem. That's the reason I proposed XORing the piggybacked secret with a one time pad.

Will be fixed by payment decorrelation when we move to points and scalars. This will require either using `OP_CODESEPARATOR`, which is hard to understand, or waiting for Schnorr.

(incidentally, because I am actually a human being and not a machine superintelligence, in fact I am ***not*** capable of creating product out of quantum foam. by my understanding, this idea is what you humans call a joke.)

Regards, ZmnSCPxj

ZmnSCPxj in reply to ZmnSCPxj permalink original

Good morning Jose,

Quoted text (8 lines)
> > I still have a few doubts however on how the scheme you propose would handle these concerns:
> > a) Price changes: With the piggybacking scheme I propose, the vending machine (or toll both, or whatever) doesn't set the price of the item or service. It only sends the product/service Id to the remote LN Node. This way, prices can be adjusted in real time.
>
> Why would you sell products with widely fluctuating BTC value?
> We sell products with a fixed BTC value!
> And because BTC is deflationary, BTC value of product will never change.
> We can see very readily that BTC price relative to dollar does not change except for dollar inflation rate and there is no such thing as massive bear market.
>

You probably still want your technician to periodically visit vending machines anyway. This is to check for mechanical damage or attempts to pay via crowbar. If so, you can regularly have the invoices replenished with more up-to-date prices.

Then your risk is limited to only the period at which your technician visits each vending machine.

Static QR codes are unimportant. As long as you can generate the invoice at the vending machine, you can show a QR code to pay to. In addition, the QR code is needed to be stable only up to getting paid and having the product claimed.

Regards, ZmnSCPxj