P2:
Note that not all implementations support all algorithms. The Keycard applet implements P2 = 0x00 and, since 4.0, P2 = 0x03.
P1 must be 0x01: the key path is always taken from the data field. An empty path means the master key. Since 4.0 there is no "current key" on the card — see the version note below.
| P2 | Data field |
|---|---|
| 0x00 (ECDSA) | hash (32) ‖ path |
| 0x03 (Schnorr) | hash (32) ‖ tweak (32) ‖ path |
The hash can be produced by any algorithm, as long as it is 32 bytes long.
If calculating the recovery ID on card is too expensive the card is allowed to return the template above instead of a raw signature, in which case a client that needs the recovery ID can derive it by trying recovery IDs from 0 and checking which one recovers the public key returned in the template. Implementations that do return a recovery ID use:
A client must accept either format.
Introduced in 4.0, P2 = 0x03 produces a BIP-340 signature, as used by Bitcoin Taproot. The mandatory 32-byte tweak is added to the derived private key before signing, which is what makes Taproot key-path spending possible; pass 32 zero bytes for an untweaked key.
The signature is returned as:
The returned public key is the tweaked one, so it is the key the signature must be verified against.
Before 4.0, P1 could additionally be 0x00 (sign with the key left active by a previous DERIVE KEY), 0x02 (derive and make current) or 0x03 (sign with the pinless path, the one case where no secure channel and no PIN were needed). Those options are gone: DERIVE KEY no longer exists and neither does pinless signing, so 0x01 with an explicit path is the only form, and a secure channel plus PIN verification are always required.