<oembed><type>rich</type><version>1.0</version><author_name>npub1sgs97fe0n9wehe6zw7drcxdz4cy9yt9pfqjv8gasz5jlk4zezc0quppx3c</author_name><author_url>https://nostr.ae/npub1sgs97fe0n9wehe6zw7drcxdz4cy9yt9pfqjv8gasz5jlk4zezc0quppx3c</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2015-02-22&#xA;📝 Original message:On 02/22/2015 02:37 PM, Andy Schroder wrote:&#xA;&gt; I&#39;d like to see some discussion too about securing the bluetooth&#xA;&gt; connection. Right now it is possible for an eavesdropper to monitor the&#xA;&gt; data transferred. &#xA;&#xA;Yes, this should be a prerequisite issue to all others.&#xA;&#xA;&gt; I&#39;d personally like to see if wrapping the current&#xA;&gt; connection with SSL works or if we can run https over a bluetooth&#xA;&gt; socket. &#xA;&#xA;There is no reason to add this significant complexity. The purpose of&#xA;SSL/TLS is to establish privacy over a *public* channel. But to do so&#xA;requires verification by the user of the merchant&#39;s public certificate.&#xA;Once we rely on the channel being *private*, the entire SSL process is&#xA;unnecessary.&#xA;&#xA;Presumably we would not want to require PKI for privacy, since that&#39;s a&#xA;bit of a contradiction. But if one wants to do this NFC is not required,&#xA;since the private session can be established over the public (Bluetooth)&#xA;network.&#xA;&#xA;&gt; There was some criticism of this, but I don&#39;t think it has been&#xA;&gt; tested to know if it is really a problem or not. If we just run https&#xA;&gt; over bluetooth, then a lot of my concerns about the message header&#xA;&gt; inconsistencies will go away and the connection will also be secure. We&#xA;&gt; don&#39;t have to reinvent anything.&#xA;&gt; &#xA;&gt; &#xA;&gt; &#xA;&gt; Andy Schroder&#xA;&gt; &#xA;&gt; On 02/22/2015 02:08 PM, Jan Vornberger wrote:&#xA;&gt;&gt; Hi everyone,&#xA;&gt;&gt;&#xA;&gt;&gt; I am working on a Bitcoin point of sale terminal based on a Raspberry&#xA;&gt;&gt; Pi, which&#xA;&gt;&gt; displays QR codes, but also provides payment requests via NFC. It can&#xA;&gt;&gt; optionally&#xA;&gt;&gt; receive the sender&#39;s transaction via Bluetooth, so if the sender wallet&#xA;&gt;&gt; supports it, the sender can be completely offline. Only the terminal&#xA;&gt;&gt; needs an&#xA;&gt;&gt; internet connection.&#xA;&gt;&gt;&#xA;&gt;&gt; Typical scenario envisioned: Customer taps their smartphone (or maybe&#xA;&gt;&gt; smartwatch&#xA;&gt;&gt; in the future) on the NFC pad, confirms the transaction on their phone&#xA;&gt;&gt; (or smartwatch) and the transaction completes via Bluetooth and/or the&#xA;&gt;&gt; phone&#39;s&#xA;&gt;&gt; internet connection.&#xA;&gt;&gt;&#xA;&gt;&gt; You can see a prototype in action here:&#xA;&gt;&gt;&#xA;&gt;&gt;    https://www.youtube.com/watch?v=P7vKHMoapr8&#xA;&gt;&gt;&#xA;&gt;&gt; The above demo uses a release version of Schildbach&#39;s Bitcoin Wallet,&#xA;&gt;&gt; so it&#xA;&gt;&gt; works as shown today. However, some parts - especially the Bluetooth&#xA;&gt;&gt; stuff - are&#xA;&gt;&gt; custom extensions of Schildbach&#39;s wallet which are not yet standard.&#xA;&gt;&gt;&#xA;&gt;&gt; I&#39;m writing this post to document my experience implementing NFC and&#xA;&gt;&gt; offline&#xA;&gt;&gt; payments and hope to move the discussion forward around standardizing&#xA;&gt;&gt; some of&#xA;&gt;&gt; this stuff. Andy Schroder&#39;s work around his Bitcoin Fluid Dispenser [1,2]&#xA;&gt;&gt; follows along the same lines, so his proposed TBIP74 [3] and TBIP75&#xA;&gt;&gt; [4] are&#xA;&gt;&gt; relevant here as well.&#xA;&gt;&gt;&#xA;&gt;&gt;&#xA;&gt;&gt; ## NFC vs Bluetooth vs NFC+Bluetooth ##&#xA;&gt;&gt;&#xA;&gt;&gt; Before I get into the implementation details, a few words for why I&#xA;&gt;&gt; decided to&#xA;&gt;&gt; go with the combination of NFC and Bluetooth:&#xA;&gt;&gt;&#xA;&gt;&gt; Doing everything via NFC is an interesting option to keep things&#xA;&gt;&gt; simple, but the&#xA;&gt;&gt; issue is, that one usually can&#39;t maintain the connection while the&#xA;&gt;&gt; user confirms&#xA;&gt;&gt; the transaction (as they take the device back to press a button or&#xA;&gt;&gt; maybe enter a&#xA;&gt;&gt; PIN). So there are three options:&#xA;&gt;&gt;&#xA;&gt;&gt; 1. Do a &#34;double tap&#34;: User taps, takes the device back, confirms, then&#xA;&gt;&gt; taps&#xA;&gt;&gt; again to transmit the transaction. (I think Google Wallet does&#xA;&gt;&gt; something like&#xA;&gt;&gt; this.)&#xA;&gt;&gt;&#xA;&gt;&gt; 2. Confirm beforehand: User confirms, then taps and everything can&#xA;&gt;&gt; happen in one&#xA;&gt;&gt; go. The disadvantage is, that you confirm the transaction before you&#xA;&gt;&gt; have seen&#xA;&gt;&gt; the details. (I believe Google Wallet can also work this way.)&#xA;&gt;&gt;&#xA;&gt;&gt; 3. Tap the phone, then establish a Bluetooth connection which allows&#xA;&gt;&gt; you to do&#xA;&gt;&gt; all necessary communication even if the user takes the device back.&#xA;&gt;&gt;&#xA;&gt;&gt; I feel that option 3 is the nicest UX, so that is what I am focusing&#xA;&gt;&gt; on right&#xA;&gt;&gt; now, but there are pros and cons to all options. One disadvantage of&#xA;&gt;&gt; option 3 in&#xA;&gt;&gt; practice is, that many users - in my experience - have Bluetooth&#xA;&gt;&gt; turned off, so&#xA;&gt;&gt; it can result in additional UI dialogs popping up, asking the user to&#xA;&gt;&gt; turn on&#xA;&gt;&gt; Bluetooth.&#xA;&gt;&gt;&#xA;&gt;&gt; Regarding doing everything via Bluetooth or maybe BLE: I have been&#xA;&gt;&gt; following the&#xA;&gt;&gt; work that Airbitz has done around that, but personally I prefer the NFC&#xA;&gt;&gt; interaction of &#34;I touch what I want to pay&#34; rather than &#34;a payment&#xA;&gt;&gt; request comes&#xA;&gt;&gt; to me through the air and I figure out whether it is meant for me/is&#xA;&gt;&gt; legitimate&#34;.&#xA;&gt;&gt;&#xA;&gt;&gt;&#xA;&gt;&gt; ## NFC data formats ##&#xA;&gt;&gt;&#xA;&gt;&gt; A bit of background for those who are not that familiar with NFC: Most&#xA;&gt;&gt; Bitcoin&#xA;&gt;&gt; wallets with NFC support make use of NDEF (NFC Data Exchange Format)&#xA;&gt;&gt; as far as I&#xA;&gt;&gt; am aware (with CoinBlesk being an exception, which uses host-based card&#xA;&gt;&gt; emulation, if I understand it correctly). NDEF defines a number of&#xA;&gt;&gt; record types,&#xA;&gt;&gt; among them &#39;URI&#39; and &#39;Mime Type&#39;.&#xA;&gt;&gt;&#xA;&gt;&gt; A common way of using NFC with Bitcoin is to create a URI record that&#xA;&gt;&gt; contains a&#xA;&gt;&gt; Bitcoin URI. Beyond that Schildbach&#39;s wallet (and maybe others?) also&#xA;&gt;&gt; support&#xA;&gt;&gt; the mime type record, which is then set to&#xA;&gt;&gt; &#39;application/bitcoin-paymentrequest&#39;&#xA;&gt;&gt; and the rest of the NFC data is a complete BIP70 payment request.&#xA;&gt;&gt;&#xA;&gt;&gt;&#xA;&gt;&gt; ## Implementation ##&#xA;&gt;&gt;&#xA;&gt;&gt; To structure the discussion a little bit, I have listed a number of&#xA;&gt;&gt; scenarios to&#xA;&gt;&gt; consider below. Not every possible combination is listed, but it&#xA;&gt;&gt; should cover a&#xA;&gt;&gt; bit of everything.&#xA;&gt;&gt;&#xA;&gt;&gt; Scenarios:&#xA;&gt;&gt;&#xA;&gt;&gt; 1) Scan QR code, transmit transaction via Bitcoin network&#xA;&gt;&gt;     Example QR code: bitcoin:1asdf...?amount=42&#xA;&gt;&gt;&#xA;&gt;&gt; 2) Touch NFC pad, transmit transaction via Bitcoin network&#xA;&gt;&gt;     Example NFC URI: bitcoin:1asdf...?amount=42&#xA;&gt;&gt;&#xA;&gt;&gt; 3) Scan QR code, fetch BIP70 details via HTTP, post transaction via HTTP&#xA;&gt;&gt;     Example QR code:&#xA;&gt;&gt; bitcoin:1asdf...?amount=42&amp;r=https://example.org/bip70paymentrequest&#xA;&gt;&gt;&#xA;&gt;&gt; 4) Touch NFC pad, fetch BIP70 details via HTTP, post transaction via HTTP&#xA;&gt;&gt;     Example NFC URI:&#xA;&gt;&gt; bitcoin:1asdf...?amount=42&amp;r=https://example.org/bip70paymentrequest&#xA;&gt;&gt;&#xA;&gt;&gt; 5) Touch NFC pad, receive BIP70 details directly, post transaction via&#xA;&gt;&gt; HTTP&#xA;&gt;&gt;     Example NFC MIME record: application/bitcoin-paymentrequest +&#xA;&gt;&gt; BIP70 payment request&#xA;&gt;&gt;&#xA;&gt;&gt; 6) Scan QR code, fetch BIP70 details via Bluetooth, post transaction&#xA;&gt;&gt; via Bluetooth&#xA;&gt;&gt;     Example QR code: bitcoin:1asdf...?amount=42&amp;bt=1234567890AB&#xA;&gt;&gt;     Payment request has &#39;payment_url&#39; set to &#39;bt:1234567890AB&#39;&#xA;&gt;&gt;&#xA;&gt;&gt; 7) Touch NFC pad, fetch BIP70 details via Bluetooth, post transaction&#xA;&gt;&gt; via Bluetooth&#xA;&gt;&gt;     Example NFC URI: bitcoin:1asdf...?amount=42&amp;bt=1234567890AB&#xA;&gt;&gt;     Payment request has &#39;payment_url&#39; set to &#39;bt:1234567890AB&#39;&#xA;&gt;&gt;&#xA;&gt;&gt; Scenarios 1 and 2 are basically the &#39;legacy&#39;/pre-BIP70 approach and I&#xA;&gt;&gt; am just&#xA;&gt;&gt; listing them here for comparison. Scenario 3 is what is often in use&#xA;&gt;&gt; now, for&#xA;&gt;&gt; example when using a checkout screen by BitPay or Coinbase.&#xA;&gt;&gt;&#xA;&gt;&gt; I played around with both scenarios 4 and 5, trying to decide whether&#xA;&gt;&gt; I should&#xA;&gt;&gt; use an NFC URI record or already provide the complete BIP70 payment&#xA;&gt;&gt; request via&#xA;&gt;&gt; NFC.&#xA;&gt;&gt;&#xA;&gt;&gt; My experience here has been, that the latter was fairly fragile in my&#xA;&gt;&gt; setup&#xA;&gt;&gt; (Raspberry Pi, NFC dongle from a company called Sensor ID, using&#xA;&gt;&gt; nfcpy). I tried&#xA;&gt;&gt; with signed payment requests that were around 4k to 5k and the&#xA;&gt;&gt; transfer would&#xA;&gt;&gt; often not complete if I didn&#39;t hold the phone perfectly in place. So I&#xA;&gt;&gt; quickly&#xA;&gt;&gt; switched to using the NFC URI record instead and have the phone fetch&#xA;&gt;&gt; the BIP70&#xA;&gt;&gt; payment request via Bluetooth afterwards. Using this approach the&#xA;&gt;&gt; amount of data&#xA;&gt;&gt; is small enough that it&#39;s usually &#39;all or nothing&#39; and that seems more&#xA;&gt;&gt; robust to&#xA;&gt;&gt; me.&#xA;&gt;&gt;&#xA;&gt;&gt; That said, I continue to have problems with the NFC stack that I&#39;m&#xA;&gt;&gt; using, so it&#xA;&gt;&gt; might just be my NFC setup that is causing these problems. I will&#xA;&gt;&gt; probably give&#xA;&gt;&gt; the NXP NFC library a try next (which I believe is also the stack that&#xA;&gt;&gt; is used&#xA;&gt;&gt; by Android). Maybe I have more luck with that approach and could then&#xA;&gt;&gt; switch to&#xA;&gt;&gt; scenario 5.&#xA;&gt;&gt;&#xA;&gt;&gt; Scenarios 6 and 7 is what the terminal is doing right now. The &#39;bt&#39;&#xA;&gt;&gt; parameter is&#xA;&gt;&gt; the non-standard extension of Andreas&#39; wallet that I was mentioning.&#xA;&gt;&gt; TBIP75&#xA;&gt;&gt; proposes to change &#39;bt&#39; into &#39;r1&#39; as part of a more generic approach of&#xA;&gt;&gt; numbering different sources for the BIP70 payment request. I think&#xA;&gt;&gt; that is a&#xA;&gt;&gt; good idea and would express my vote for this proposal. So the QR code&#xA;&gt;&gt; or NFC URI&#xA;&gt;&gt; would then look something like this:&#xA;&gt;&gt;&#xA;&gt;&gt;   &#xA;&gt;&gt; bitcoin:1asdf...?amount=42&amp;r=https://example.org/bip70&amp;r1=bt:1234567890AB/resource&#xA;&gt;&gt;&#xA;&gt;&gt;&#xA;&gt;&gt; In addition the payment request would need to list additional&#xA;&gt;&gt; &#39;payment_url&#39;s. My&#xA;&gt;&gt; proposal would be to do something like this:&#xA;&gt;&gt;&#xA;&gt;&gt;      message PaymentDetails {&#xA;&gt;&gt;          ...&#xA;&gt;&gt;          optional string payment_url = 6;&#xA;&gt;&gt;          optional bytes merchant_data = 7;&#xA;&gt;&gt;          repeated string additional_payment_urls = 8;&#xA;&gt;&gt;            // ^-- new; to hold things like &#39;bt:1234567890AB&#39;&#xA;&gt;&gt;      }&#xA;&gt;&gt;&#xA;&gt;&gt; TBIP75 proposes to just change &#39;optional string payment_url&#39; into&#xA;&gt;&gt; &#39;repeated&#xA;&gt;&gt; string payment_url&#39;. If this isn&#39;t causing any problems (and hopefully&#xA;&gt;&gt; not too&#xA;&gt;&gt; much confusion?) I guess that would be fine too.&#xA;&gt;&gt;&#xA;&gt;&gt; In my opinion a wallet should then actually attempt all or multiple of&#xA;&gt;&gt; the&#xA;&gt;&gt; provided mechanisms in parallel (e.g. try to fetch the BIP70 payment&#xA;&gt;&gt; request via&#xA;&gt;&gt; both HTTP and Bluetooth) and go with whatever completes first. But&#xA;&gt;&gt; that is of&#xA;&gt;&gt; course up to each wallet to decide how to handle.&#xA;&gt;&gt;&#xA;&gt;&gt; TBIP75 furthermore proposes to include an additional &#39;h&#39; parameter&#xA;&gt;&gt; which would&#xA;&gt;&gt; be a hash of the BIP70 payment request, preventing a MITM attack on the&#xA;&gt;&gt; Bluetooth channel even if the BIP70 payment request isn&#39;t signed. This&#xA;&gt;&gt; would&#xA;&gt;&gt; have also been my suggestion, although I know that Mike Hearn has raised&#xA;&gt;&gt; concerns about this approach. One being, that one needs to finalize&#xA;&gt;&gt; the BIP70&#xA;&gt;&gt; payment request at the time the QR code and NFC URI is generated.&#xA;&gt;&gt;&#xA;&gt;&gt;&#xA;&gt;&gt; ## Questions ##&#xA;&gt;&gt;&#xA;&gt;&gt; My questions to the list:&#xA;&gt;&gt;&#xA;&gt;&gt; 1) Do you prefer changing &#39;optional string payment_url&#39; into &#39;repeated&#xA;&gt;&gt; string&#xA;&gt;&gt; payment_url&#39; or would you rather introduce a new field&#xA;&gt;&gt; &#39;additional_payment_urls&#39;?&#xA;&gt;&gt;&#xA;&gt;&gt; 2) @Andreas: Is the r, r1, r2 mechanism already implemented in Bitcoin&#xA;&gt;&gt; Wallet?&#xA;&gt;&gt;&#xA;&gt;&gt; 3) Are there other comments regarding &#39;h&#39; parameter as per TBIP75?&#xA;&gt;&gt;&#xA;&gt;&gt; 4) General comments, advice, feedback?&#xA;&gt;&gt;&#xA;&gt;&gt; I appreciate your input! :-)&#xA;&gt;&gt;&#xA;&gt;&gt; Cheers,&#xA;&gt;&gt; Jan&#xA;&gt;&gt;&#xA;&gt;&gt; [1] http://andyschroder.com/BitcoinFluidDispenser/&#xA;&gt;&gt; [2]&#xA;&gt;&gt; https://www.mail-archive.com/bitcoin-development%40lists.sourceforge.net/msg06354.html&#xA;&gt;&gt;&#xA;&gt;&gt; [3] https://github.com/AndySchroder/bips/blob/master/tbip-0074.mediawiki&#xA;&gt;&gt; [4] https://github.com/AndySchroder/bips/blob/master/tbip-0075.mediawiki&#xA;&gt;&gt;&#xA;&gt;&gt; ------------------------------------------------------------------------------&#xA;&gt;&gt;&#xA;&gt;&gt; Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server&#xA;&gt;&gt; from Actuate! Instantly Supercharge Your Business Reports and Dashboards&#xA;&gt;&gt; with Interactivity, Sharing, Native Excel Exports, App Integration &amp; more&#xA;&gt;&gt; Get technology previously reserved for billion-dollar corporations, FREE&#xA;&gt;&gt; http://pubads.g.doubleclick.net/gampad/clk?id=190641631&amp;iu=/4140/ostg.clktrk&#xA;&gt;&gt;&#xA;&gt;&gt; _______________________________________________&#xA;&gt;&gt; Bitcoin-development mailing list&#xA;&gt;&gt; Bitcoin-development at lists.sourceforge.net&#xA;&gt;&gt; https://lists.sourceforge.net/lists/listinfo/bitcoin-development&#xA;&gt;&gt;&#xA;&gt;&gt;&#xA;&gt;&gt;&#xA;&gt; &#xA;&gt; &#xA;&gt; &#xA;&gt; ------------------------------------------------------------------------------&#xA;&gt; Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server&#xA;&gt; from Actuate! Instantly Supercharge Your Business Reports and Dashboards&#xA;&gt; with Interactivity, Sharing, Native Excel Exports, App Integration &amp; more&#xA;&gt; Get technology previously reserved for billion-dollar corporations, FREE&#xA;&gt; http://pubads.g.doubleclick.net/gampad/clk?id=190641631&amp;iu=/4140/ostg.clktrk&#xA;&gt; &#xA;&gt; &#xA;&gt; &#xA;&gt; _______________________________________________&#xA;&gt; Bitcoin-development mailing list&#xA;&gt; Bitcoin-development at lists.sourceforge.net&#xA;&gt; https://lists.sourceforge.net/lists/listinfo/bitcoin-development&#xA;&gt; &#xA;&#xA;-------------- next part --------------&#xA;A non-text attachment was scrubbed...&#xA;Name: signature.asc&#xA;Type: application/pgp-signature&#xA;Size: 473 bytes&#xA;Desc: OpenPGP digital signature&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20150222/a3e8cdc2/attachment.sig&gt;</html></oembed>