Problem
When a user enters their PIN on the device, they have no way to verify they're interacting with genuine firmware vs. a malicious replacement. An attacker with physical access could replace the display/firmware to capture PINs.
Solution: PIN Prefix Words
Production hardware wallets use a technique where entering the first few digits of your PIN displays derived BIP-39 words that only the genuine device with your secret can produce.
User Flow:
- User starts PIN entry
- After entering 2-4 digits, device displays two BIP-39 words
- User verifies words match what they expect (memorized during setup)
- If words are wrong → device is compromised, abort
- If words match → continue entering full PIN
Implementation:
typedef struct {
uint8_t prefix[4]; // First 4 PIN digits
uint8_t prefix_len; // How many digits entered
} pin_prefix_t;
// Derive anti-phishing words from PIN prefix + device secret
int pin_derive_prefix_words(const pin_prefix_t *prefix,
const uint8_t *device_secret,
uint16_t *word1_index,
uint16_t *word2_index) {
uint8_t hmac_out[32];
// HMAC(device_secret, "anti-phishing" || prefix)
mbedtls_md_hmac(MBEDTLS_MD_SHA256,
device_secret, 32,
combined_input, input_len,
hmac_out);
// Extract two 11-bit word indices (BIP-39 has 2048 words)
*word1_index = (hmac_out[0] << 3 | hmac_out[1] >> 5) & 0x7FF;
*word2_index = (hmac_out[1] << 6 | hmac_out[2] >> 2) & 0x7FF;
secure_memzero(hmac_out, sizeof(hmac_out));
return 0;
}
Display Integration:
Setup Flow:
- During first PIN creation, derive and show prefix words
- User writes down: "My anti-phishing words are:
abandon ability"
- On every subsequent unlock, user verifies these words appear
Security Properties
- Words are deterministic: same prefix + same secret = same words
- Words change if device secret changes (detects tampering)
- Words change if PIN prefix changes (different users get different words)
- Attacker cannot predict words without knowing device secret
Dependencies
Acceptance Criteria
Problem
When a user enters their PIN on the device, they have no way to verify they're interacting with genuine firmware vs. a malicious replacement. An attacker with physical access could replace the display/firmware to capture PINs.
Solution: PIN Prefix Words
Production hardware wallets use a technique where entering the first few digits of your PIN displays derived BIP-39 words that only the genuine device with your secret can produce.
User Flow:
Implementation:
Display Integration:
Setup Flow:
abandonability"Security Properties
Dependencies
Acceptance Criteria