libHaLo
Overview
LibHaLo is an open library designed for interacting with HaLo chips from a variety of interfaces including a mobile web browser, native apps and CLIs. Below you can find guides from the libHaLo repo that include detailed examples on how you can use libHaLo in your project. We recommend looking at the Guides section to find the right guide for your use case. Below we've included a common mobile web example to get you started quickly.
Demos
We host several interactive libHaLo demos (opens in a new tab) that you can try out in your mobile web and desktop browser as indicated.
Example
Mobile Browser Example
Include the libhalo.js on your webpage:
<script src="libhalo.js"></script>
Create a minimal user interface:
<div id="statusText">Please click on the button below.</div>
<button onclick="btnPressed();">Click here</button>
Call the library inside the button click routine:
async function btnPressed() {
let command = {
name: "sign",
keyNo: 1,
digest: "6e76e202b71892e9ee32a634eefcf522ba1c4cb4eadd7e4562ced1270214c41e"
};
document.getElementById('statusText').innerText = "Please tap NFC tag to the back of your smartphone...";
try {
let res = await execHaloCmdWeb(command);
// display operation result
document.getElementById('statusText').innerText = JSON.stringify(res, null, 4);
} catch (e) {
// display error
document.getElementById('statusText').innerText = e;
}
}
Load the webpage through HTTPS on a mobile browser like iOS Safari or Android Chrome and tap Click here
to initiate a scan. You can use a tool like localtunnel (opens in a new tab) to serve a locally hosted page over HTTPS.
Guides
For web browser applications: scan the HaLo tag presented to the smartphone, execute the HaLo command and return the result. Supports Chrome (Android), Safari (iOS) and other browsers. Installation of additional software is not required on the user's side.
- Using libhalo as a standalone library in a classic HTML web application (opens in a new tab)
- Using libhalo within a React.js web application (opens in a new tab)
- Documentation of the execHaloCmdWeb API (opens in a new tab)
- Documentation of the utility functions exposed by LibHaLo (opens in a new tab)
(React Native/Expo) execHaloCmdRN
async function execHaloCmdRN(nfcManager, command, options)
For React Native/Expo mobile applications (Android/iOS) based on react-native-nfc-manager
library: scan the HaLo tag presented to the smartphone, execute the HaLo command and return the result.
- Using libhalo within a React Native application for Android/iOS (opens in a new tab)
- Using libhalo within an Expo mobile application for Android/iOS (opens in a new tab)
- Documentation of the execHaloCmdRN API (opens in a new tab)
- Documentation of the utility functions exposed by LibHaLo (opens in a new tab)
(Desktop) execHaloCmdPCSC
async function execHaloCmdPCSC(command, reader)
For desktop applications based on nfc-pcsc
library: scan the HaLo tag present at the specified reader
, execute the HaLo command and return the result.
- Using libhalo as a CLI tool on the desktop computer with PC/SC reader (USB NFC reader) (opens in a new tab)
- Using libhalo to build your own application for desktop computers with PC/SC reader (USB NFC reader) (opens in a new tab)
- Using LibHaLo to build your own application for desktop computers using HaLo Gateway (using remote smartphone as the NFC reader) (opens in a new tab)
- Documentation of the execHaloCmdPCSC API (opens in a new tab)
- Documentation of the utility functions exposed by LibHaLo (opens in a new tab)
Commands
LibHaLo library supports the following HaLo tag commands:
sign
- sign arbitrary data using ECDSA private key on the NFC tag;sign_random
- sign a sequential counter with random pad using ECDSA private key on the NFC tag;sign_challenge
- sign a specified challenge using selected key slot on the NFC tag;write_latch
- write one-time programmable memory slot on the NFC tag;cfg_ndef
- configure the parameters returned in the dynamic URL when the NFC tag is scanned;gen_key
- request generation of the key;gen_key_confirm
- confirm the generated public key;gen_key_finalize
- finish the key generation process;get_pkeys
- get tag's public keys #1, #2 and #3;get_key_info
- get information about the specified key slot;version
- check HaLo tag's firmware version (only for PCSC/React Native);read_ndef
- read the dynamic URL generated by the tag (only for PCSC/React Native);
Full articles:
- Documentation of the available commands (HaLo Command Set) (opens in a new tab)
- HaLo Firmware Versions - command compatibility table (opens in a new tab)
- HaLo Key Slots - description of the available key slots and their functions (opens in a new tab)