keycard-go

July 14, 2026 · View on GitHub

keycard-go is a set of Go packages for interacting with the Status Keycard, a secure NFC-based hardware wallet.

If you only need a CLI tool to initialize your card, check out keycard-cli.

Packages

PackageDescription
keycardMain API — CommandSet for card operations, secure channel, pairing
keycard/globalplatformGlobalPlatform commands — applet installation, SCP02 secure channel
keycard/apduAPDU command/response types and encoding
keycard/cryptoCryptographic utilities (ECDH, AES-CCM, HMAC, PBKDF2, zeroization)
keycard/derivationpathBIP32 derivation path parsing and encoding
keycard/identifiersAIDs and instance identifiers for Keycard, NDEF, Cash
keycard/tlvTLV encoding/decoding
keycard/typesShared types — Pairing, Signature, Bip32KeyPair, ApplicationInfo, etc.

Keycard Commands

Setup and Status

CommandMethod(s)
SELECTSelect()
INITInit(), InitWithSecret(), InitV2(), InitWithOptions()
FACTORY RESETFactoryReset()
GET STATUSGetStatus(), GetStatusApplication(), GetStatusKeyPath()
IDENTIFYIdentify()

Secure Channel

FeatureDetails
V1 (pairing-based)OpenSecureChannel(), AutoOpenSecureChannel()
V2 (certificate-based, app ≥ 4.0)AutoOpenSecureChannel(), AutoPair()
Auto-detectionSecureChannelVersion() — selected automatically after Select()
Mutual AuthenticationPerformed automatically during channel open

Pairing (Secure Channel V1)

CommandMethod(s)
PAIRPair() (legacy), AutoPairWithMode(), AutoPairWithSecret(), AutoPairWithSecretAndMode()
UNPAIRUnpair(index)
UNPAIR OTHERSUnpairOthers()
CHANGE PAIRING PASSWORDChangePairingPassword()
Pairing modesP2PairAny, P2PairEphemeral, P2PairPersistent

PIN / PUK Management

CommandMethod(s)
VERIFY PINVerifyPIN()
CHANGE PINChangePIN()
UNBLOCK PINUnblockPIN(puk, newPIN)
CHANGE PUKChangePUK()

Key Management

CommandMethod(s)
LOAD KEY (BIP32)LoadKeyBIP32(), LoadKeyBIP32OmitPublic()
LOAD KEY (Seed)LoadSeed()
LOAD KEY (LEE)LoadLEEKey()
DERIVE KEYDeriveKey(path)
GENERATE KEYGenerateKey()
GENERATE MNEMONICGenerateMnemonic(checksumSize)
REMOVE KEYRemoveKey()
EXPORT KEY (BIP32)ExportKey(), ExportKeyExtended(), ExportKeyWithP2(), ExportCurrentKey()
EXPORT KEY (LEE)ExportLEEKey(keypath)
EXPORT KEY (BIP85)ExportBIP85(keypath, length)

Signing

CommandMethod(s)Algorithms
SIGN (current key)Sign(data)ECDSA, EdDSA/Ed25519, BLS12-381, BIP340 Schnorr
SIGN (derived path)SignWithPath(data, path), SignWithPathAndAlgo(data, path, algo)Same
SIGN (pinless)SignPinless(data)ECDSA
SET PINLESS PATHSetPinlessPath(path)
RESET PINLESS PATHResetPinlessPath()

Sign algorithm constants: P2SignECDSA, P2SignEdDSAEd25519, P2SignBLS12_381, P2SignBIP340Schnorr.

Data Storage

CommandMethod(s)
STORE DATAStoreData(typ, data), StoreDataWithOffset(typ, data, offset)
GET DATAGetData(typ)
SET NDEFSetNDEF(ndef)
GET CHALLENGEGetChallenge(length)

Data type constants: P1StoreDataPublic, P1StoreDataNDEF, P1StoreDataCash.

GlobalPlatform (Applet Management)

CommandMethod(s)
SELECTglobalplatform.NewCommandSelect(aid)
INITIALIZE UPDATEglobalplatform.NewCommandInitializeUpdate(challenge)
EXTERNAL AUTHENTICATEglobalplatform.NewCommandExternalAuthenticate(...)
GET RESPONSEglobalplatform.NewCommandGetResponse(length)
DELETEglobalplatform.NewCommandDelete(aid, p2)
INSTALL FOR LOADglobalplatform.NewCommandInstallForLoad(aid, sdaid)
INSTALL FOR INSTALLglobalplatform.NewCommandInstallForInstall(pkgAID, appletAID, instanceAID, params)
SCP02 Secure Channelglobalplatform.SCP02Wrapper, globalplatform.SecureChannel
Applet Loadingglobalplatform.NewLoadCommandStream(file)

Cash Application

CommandMethod(s)
SELECTCashCommandSet.Select()
SIGNCashCommandSet.Sign(data)

Secure Channel Versions

VersionApp VersionAuthenticationNotes
V1< 4.0ECDH + pairing password (PBKDF2)Up to 5 persistent pairing slots
V2≥ 4.0ECDH + X.509 certificateCA-trusted, no pairing password needed

V2 is auto-selected for app version ≥ 4.0. Use AutoOpenSecureChannel() and AutoPairWithMode() for version-agnostic code.