|
cryptnox-sdk-esp32 1.0.0
ESP32 SDK for Cryptnox Hardware Wallet
|
Directories | |
| main | |
Files | |
| config.template.h | |
Sign an arbitrary 32-byte digest on the Cryptnox Hardware Wallet using the secp256k1 curve (Bitcoin, Ethereum, BSC, Polygon, …). The private key never leaves the card; the ESP32 only ever sees the hash and the resulting (r, s).
| Component | Details |
|---|---|
| Hardware Wallet | Cryptnox Hardware Wallet, initialised and seeded |
| NFC reader | PN532 over SPI — MOSI=11, MISO=13, SCLK=12, CS=10 (see hardware setup) |
| Board | ESP32-S3-DevKitC-1 |
| Toolchain | ESP-IDF v5.5 |
main/config.h must contain valid WIFI_SSID / WIFI_PASSWORD — the radio is started on boot to seed the hardware TRNG before any crypto runs.
Provision the card from a host with a PC/SC reader and the Cryptnox CLI:
Without a seed the SDK returns CW_SIGN_NO_KEY_LOADED (0x81).
Create your runtime config from the template (kept out of git so credentials never get committed) and fill in Wi-Fi:
Build, flash and monitor:
r and s together form the 64-byte raw ECDSA signature (signature[0..31] = r, signature[32..63] = s). The card returns a canonical low-S signature (S ≤ n/2), so the output is directly forwardable to any chain that enforces BIP-62.
CW_SIGN_CURR_K1 signs with the card's current secp256k1 key (usually m/). To derive a BIP-44 sub-key first, set derivePath / derivePathLength on the request and use CW_SIGN_DERIVE_K1 — see UsdcSigning for a worked example (m/44'/60'/0'/0/0 for Ethereum).
| Mode | Round-trips | Notes |
|---|---|---|
| CW_SIGN_WITH_PIN (this example) | 1 | PIN included inside the SIGN APDU; one shot |
| CW_SIGN_PINLESS after verifyPin() | 2 | One PIN verification covers many subsequent signatures |
Pre-verifying is preferable when you sign more than one hash per session.
Build the sign request:
Sign and handle the result:
Wipe secrets before the next iteration:
CW_Utils::secure_wipe is a volatile-pointer memset that the compiler cannot elide — required to keep secrets from lingering in RAM.
| errorCode | Meaning | Action |
|---|---|---|
| CW_OK (0x00) | Signature OK | Use sig.signature |
| CW_SIGN_NO_KEY_LOADED (0x81) | Card has no seed | cryptnox seed generate |
| CW_SIGN_PIN_INCORRECT (0x82) | Wrong PIN | Halt — fix DEMO_PIN before re-running |
| other | Channel error / unexpected SW | Check the raw status word printed by the SDK |
| Symptom | Cause | Fix |
|---|---|---|
| Sign failed: 0x81 | No seed on card | cryptnox seed generate |
| Sign failed: 0x82 | Wrong PIN | Edit DEMO_PIN, re-flash — do not keep retrying |
| APDU exchange failed! | NFC link dropped mid-exchange | Hold the card steady through the LED pulse |
| Card not detected | Card not on the antenna | Bring the card within ~1 cm of the antenna |
cryptnox-sdk-esp32 is dual-licensed:
For commercial inquiries, contact: conta.nosp@m.ct@c.nosp@m.ryptn.nosp@m.ox.c.nosp@m.om