Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding encrypted/decrypted pin (used in LNURLPoS/LNURLVend) workflow to protocol? #136

Open
arcbtc opened this issue Dec 14, 2021 · 9 comments

Comments

@arcbtc
Copy link

arcbtc commented Dec 14, 2021

LNURLPoS and LNURLVend encrypt a pin on each payment, which is passed to server through an LNURL-pay, then decrypted and sent back in the receipt upon completion of payment. The crypto was elegantly written by @stepansnigirev and using readily available bitcoin crypto.

On LNURLPoS the encrypted pin is added to LNURL here: https://github.com/arcbtc/LNURLPoS/blob/40cb199c4599d9f6c64b7e372a5c7938b75a83f0/LNURLPoS/LNURLPoS.ino#L232

On LNbits server side, it is decrypted and sent back as a receipt here:
https://github.com/lnbits/lnbits-legend/blob/a2bb34060102d049e07766436359e9526e3d8aab/lnbits/extensions/lnurlpos/lnurl.py#L37

Bleskomat uses practically the same method, but for LNURL-withdraws and their offline ATM.

If we made encrypting a confirmation pin and passing through LNURL, then sending back decrypted pin in the receipt, part of the LNURL protocol, then a service like OpenNode could support it directly and LNURLPoS, LNURLVend, Bleskomat, etc would be compatible native with their platform.

@arcbtc arcbtc changed the title Adding ncrypted/decrypted pin LNURLPoS and LNURLVend workflow to protocol? Adding encrypted/decrypted pin LNURLPoS and LNURLVend workflow to protocol? Dec 14, 2021
@arcbtc arcbtc changed the title Adding encrypted/decrypted pin LNURLPoS and LNURLVend workflow to protocol? Adding encrypted/decrypted pin (used in LNURLPoS/LNURLVend) workflow to protocol? Dec 14, 2021
@fiatjaf
Copy link
Collaborator

fiatjaf commented Dec 14, 2021

Bleskomat is very different. It's not using encrypted anything, it is using an HMAC to ensure the amount can be safely withdrawn. See #91.

@karliatto
Copy link

karliatto commented Dec 14, 2021

Yes, Bleskomat works using HMAC signature for the withdrawRequest but the workflow described here can be used to integrate payRequest with the offline device.

I think it would be a great improvement in the way LNURLPoS works right now and for similar workflow projects if there would be something like successMessage sent from the LN Service to the LN WALLET after point 9 described in LUD06 - Wallet to service interaction flow

So when LN Service verifies the invoice has been paid it responds to the LN WALLET with the decrypted pin (or potentially other data), and then the LN WALLET displays it to the user. Making not necessary to have a web page that will show the decrypted pin once the payment is done.

@arcbtc
Copy link
Author

arcbtc commented Dec 14, 2021

The Bleskomat concept is similar, in that it uses a secret to prove the LNURL was generated from a legitimate source. I'm sure these projects can find a common workflow so a generic standard can be added to LNURL.

I'm looking forward to using the improved successaction workflow once it has greater support across wallets

@Kixunil
Copy link
Contributor

Kixunil commented Dec 14, 2021

One problem I see with the idea of displaying arbitrary data is it's an attack vector for phishing. ("Upgrade the wallet to receive the token") A pretty good solution would be to just enforce that the wallet displays it either as hex or decimal number. Thus any text would be scrambled and unreadable for common user.

There's another problem which I disclosed to @arcbtc privately. Since he said the code is not used in the wild, I'm thinking of publishing it.

@arcbtc
Copy link
Author

arcbtc commented Dec 14, 2021

Please do, although can you wait until we have patched.
If creating a standard Bleskomat and LNURLPoS/LNURLVend can share involves a change to how we encrypt the pin, the benefit will far outweigh any inconvenience

@Kixunil
Copy link
Contributor

Kixunil commented Dec 14, 2021

OK, I'll wait. Please ping me once it's patched.

@fiatjaf
Copy link
Collaborator

fiatjaf commented Dec 14, 2021

I'm not seeing these benefits. What are the benefits? If OpenNode wants to support LNURLPoS why can't it just implement the LNURLPoS backend? Bleskomat is completely unrelated.

@chill117
Copy link
Contributor

I'm not seeing these benefits. What are the benefits? If OpenNode wants to support LNURLPoS why can't it just implement the LNURLPoS backend? Bleskomat is completely unrelated.

There is benefit to creating a standard for a common and useful design pattern - especially one involving cryptographic functions. It's better than having a bunch of slightly different implementations floating around each with their own potential vulnerabilities. One standard that has been well tested and vetted by many eyes - that's desirable.

And the current iteration of Bleskomat uses only an HMAC to secure the signed lnurl-withdraw flow. But we could implement a similar flow as the LnurlPOS or LnurlVend using a signed lnurl-pay with encrypted PIN. This can make all kinds of offline hardware possible using Lightning.

@Kixunil
Copy link
Contributor

Kixunil commented Dec 14, 2021

Exactly, cryptography can be very subtle and very dangerous to implement without review and experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants