4.5 KiB
Abstract
Boltcard NFC Programmer App is a native app on iOS and Android to flash or reset NTag424 into a Boltcard.
- The
Boltcard Servicegenerates the keys, and format them into a QR Code - The user opens the Boltcard NFC Programmer, go to
Create Bolt Card, scans the QR code - The user then taps the card
The QR code contains all the keys necessary for the app to create the Boltcard.
Here are the shortcomings we aim to address in this specification:
- If the QR code is on the mobile device itself, it isn't possible to scan it
- It isn't possible to generate a pair of keys specific for the NTag424 being setup (the deterministic key generation needs the UID before generating the keys)
Boltcard deeplinks
The solution is for the Boltcard Service to generate deep links with the following format: Boltcard://[program|reset]?url=[keys-request-url].
When clicked, Boltcard NFC Programmer would open and either allow the user to program their NTag424 or reset it after asking for the NTags keys to the keys-request-url.
The Boltcard NFC Programmer should send an HTTP POST request with Content-Type: application/json in the following format:
{
"UID": "[UID]"
}
Or
{
"LNURLW": "lnurlw://..."
}
In curl:
curl -X POST "[keys-request-url]" -H "Content-Type: application/json" -d '{"UID": "[UID]"}'
UIDneeds to be 7 bytes. (Program action)LNURLWneeds to be read from the Boltcard's NDEF and can be sent in place ofUID. It must contains thep=andc=arguments of the Boltcard. (Reset action)
The response will be similar to the format of the QR code:
{
"LNURLW": "lnurlw://...",
"K0":"[Key0]",
"K1":"[Key1]",
"K2":"[Key2]",
"K3":"[Key3]",
"K4":"[Key4]"
}
The Program action
If program is specified in the Boltcard link, the Boltcard NFC Programmer must:
- Check if the lnurlw
NDEFcan be read.- If the record can be read, then the card isn't reset, an error should be displayed to the user to first reset the Boltcard with the previous
Boltcard Service. - If the record can't be read, assume
K0is00000000000000000000000000000000authenticate and callGetUIDon the card again. (SinceGetUIDis called after authentication, the realUIDwill be returned even ifRandom UIDhas been activated)
- If the record can be read, then the card isn't reset, an error should be displayed to the user to first reset the Boltcard with the previous
- Send a request to the
keys-request-urlusing the UID as explained above to get the NTag424 app keys - Program the Boltcard
The Reset action
If reset is specified in the Boltcard link, the Boltcard NFC Programmer must:
- Check if the lnurlw
NDEFcan be read.- If the record can't be read, then the card is already reset, show an error message to the user.
- If the record can be read, continue to step 2.
- Send a request to the
keys-request-urlusing the lnurlw as explained above to get the NTag424 app keys - Reset the Boltcard to factory state
Handling setup/reset cycles for Boltcard Services
When a NTag424 is reset, its counter is reset too. This means that if the user:
- Setup a Boltcard
- Make
5payments - Reset the Boltcard
- Setup the Boltcard on same
keys-request-url
With a naive implementation, the server will expect the next counter to be above 5, but the next payment will have a counter of 0.
More precisely, the user will need to tap the card 5 times before being able to use the Boltcard for a payment successfully again.
To avoid this issue the Boltcard Service, if using Deterministic key generation, should ensure it updates the key version during a program action.
This can be done easily by the Boltcard Service by adding a parameter in the keys-request-url which specifies that the version need to be updated.
When the Boltcard NFC Programmer queries the URL with the UID of the card, the Boltcard Service will detect this parameter, and update the version.
Test vectors
Here is an example of two links for respectively program the Boltcard and Reset it.
<p>
<a id="SetupBoltcard" href="boltcard://program?url=https%3A%2F%2Flocalhost%3A14142%2Fapi%2Fv1%2Fpull-payments%2FfUDXsnySxvb5LYZ1bSLiWzLjVuT%2Fboltcards%3FonExisting%3DUpdateVersion" target="_blank">
Setup Boltcard
</a>
<span> | </span>
<a id="ResetBoltcard" href="boltcard://reset?url=https%3A%2F%2Flocalhost%3A14142%2Fapi%2Fv1%2Fpull-payments%2FfUDXsnySxvb5LYZ1bSLiWzLjVuT%2Fboltcards%3FonExisting%3DKeepVersion" target="_blank">
Reset Boltcard
</a>
</p>