Select the communication interface by defining USE_SPI or USE_I2C below.
#include <CryptnoxWallet.h>
#define USE_SPI
#if defined(USE_SPI)
#include <SPI.h>
#define PN532_SS (10U)
#elif defined(USE_I2C)
#include <Wire.h>
#define PN532_IRQ (2U)
#define PN532_RST (3U)
#else
#error "Please define USE_SPI or USE_I2C to select the PN532 interface."
#endif
#define DEFAULT_PIN "000000000"
#define DEFAULT_PIN_LEN (sizeof(DEFAULT_PIN) - 1U)
delay(1000);
#if defined(USE_SPI)
SPI.begin();
#elif defined(USE_I2C)
Wire.begin();
#endif
while(1);
}
}
if (
wallet.connect(session)) {
serialAdapter.println(
F(
"Card connected and secure channel established"));
memset(testHash, 0x01, sizeof(testHash));
signRequest.hash = testHash;
signRequest.hashLength = sizeof(testHash);
}
}
} else {
}
}
delay(1000);
}
#define DEFAULT_PIN
Default PIN code (ASCII digits). Must match the PIN used during card.init().
void setup()
Arduino setup function.
CryptnoxWallet wallet(nfc, serialAdapter, cryptoProvider, platform)
#define PN532_SS
SPI slave select (CS) pin for the PN532 module.
PN532Adapter nfc(serialAdapter, PN532_SS, &SPI)
ArduinoLoggerAdapter serialAdapter
ArduinoCryptoProvider cryptoProvider
void loop()
Arduino main loop.
#define CW_SIGN_SIG_ECDSA_LOW_S
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]