Minimal Cryptnox example: sign a 32-byte hash on the secp256k1 curve.
Minimal Cryptnox example: sign a 32-byte hash on the secp256k1 curve.Wiring & prerequisites:
#include <CryptnoxWallet.h>
#include <SPI.h>
#define PN532_SS_PIN (10U)
#define DEMO_PIN "000000000"
delay(1000);
SPI.begin();
while (1);
}
}
if (!
wallet.connect(session)) {
delay(1000);
return;
}
memset(hash, 0x01, sizeof(hash));
req.hash = hash;
req.hashLength = sizeof(hash);
for (uint8_t i = 0U; i < 32U; i++) {
}
for (uint8_t i = 0U; i < 32U; i++) {
}
serialAdapter.println(
F(
"Wrong PIN — halting to protect retry counter"));
while (1);
} else {
}
delay(1000);
}
void setup()
Arduino setup function.
CryptnoxWallet wallet(nfc, serialAdapter, cryptoProvider, platform)
PN532Adapter nfc(serialAdapter, PN532_SS, &SPI)
ArduinoLoggerAdapter serialAdapter
ArduinoCryptoProvider cryptoProvider
void loop()
Arduino main loop.
#define CW_SIGN_SIG_ECDSA_LOW_S
#define CW_SIGN_PIN_INCORRECT
#define PN532_SS_PIN
SPI slave-select (CS) pin connected to the PN532 module.
#define DEMO_PIN
Demo PIN used by this example. Must match the PIN that the card was initialised with (4–9 ASCII digit...
CW_CryptoProvider implementation for the Arduino UNO R4 (RA4M1).
CW_Logger implementation wrapping Arduino's HardwareSerial.
static bool safe_memcpy(uint8_t *dst, size_t dstSize, const uint8_t *src, size_t count)
Safe memcpy — validates pointers, sizes, and checks for overlap.
static void secure_wipe(uint8_t *buf, size_t len)
Securely zero a buffer, guaranteed not to be optimised away.
High-level interface for interacting with a Cryptnox Hardware Wallet over NFC.
CW_NfcTransport implementation over the Adafruit_PN532 driver.
Holds cryptographic session state for reentrant secure channel operations.
Request parameters for CryptnoxWallet::sign.
Result of CryptnoxWallet::sign.
uint8_t signature[CW_RAW_SIGNATURE_SIZE]