nexum-keycard
is a comprehensive toolkit for interacting with Keycards - secure smart cards designed for blockchain applications and cryptocurrency key management. This implementation provides a complete solution for Keycard operations in Rust.
Build secure blockchain applications with hardware-backed security and the power of Rust.
The easiest way to get started is to add the core crate:
cargo add nexum-keycard
For blockchain signing capabilities:
cargo add nexum-keycard-signer
For the command-line interface:
cargo install nexum-keycard-cli
use nexum_keycard::{Keycard, PcscDeviceManager, CardExecutor, Error};
fn main() -> Result<(), Error> {
// Create a PC/SC transport
let manager = PcscDeviceManager::new()?;
let readers = manager.list_readers()?;
let reader = readers.iter().find(|r| r.has_card()).expect("No card present");
let transport = manager.open_reader(reader.name())?;
// Create a card executor
let mut executor = CardExecutor::new_with_defaults(transport);
// Create a Keycard instance and select the applet
let mut keycard = Keycard::new(&mut executor);
let app_info = keycard.select_keycard()?;
println!("Selected Keycard with instance: {}", app_info.instance_uid);
println!("Applet version: {}", app_info.version);
// Initialize a new card (if needed)
if !app_info.initialized() {
let secrets = keycard.init(None, None, None)?;
println!("Card initialized with:\nPIN: {}\nPUK: {}\nPairing password: {}",
secrets.pin(), secrets.puk(), secrets.pairing_password());
}
Ok(())
}
This repository contains the following crates:
nexum-keycard
: Core functionality for interacting with Keycardsnexum-keycard-signer
: Alloy signer implementation for blockchain operationsnexum-keycard-cli
: Command-line interface for Keycard management
- 🔐 Secure Channel Communication - Encrypted and authenticated channel to the card
- 🔑 Key Management - Generate, export, and manage keys on the Keycard
- 📝 Credential Management - Set and update PINs, PUKs, and pairing passwords
- 🔍 Status Information - Retrieve detailed info about the card status
- 🔄 BIP32/39 Support - Key derivation path support and mnemonic generation
- 📊 Data Storage - Store and retrieve custom data on the card
- 📱 Factory Reset - Complete card reset when needed
- 🌐 Blockchain Integration - Built-in support for Ethereum transaction signing
For detailed documentation on each crate, please check their individual README
files:
nexum-keycard
README
- Core Keycard functionalitynexum-keycard-signer
README
- Blockchain signer implementationnexum-keycard-cli
README
- Command-line interface
nexum-keycard includes a comprehensive CLI for managing Keycards:
# List available readers
nexum-keycard-cli list
# Initialize a new card
nexum-keycard-cli init
# Generate a new key pair
nexum-keycard-cli generate-key
# Sign data
nexum-keycard-cli sign 0123456789abcdef --path m/44'/60'/0'/0/0
nexum-keycard
is built on a layered architecture:
- APDU Transport Layer - Handles low-level communication with card readers (via
nexum-apdu-*
crates) - Secure Channel Layer - Provides encryption and authentication for sensitive operations
- Keycard Command Layer - Implements the Keycard protocol and commands
- Application Layer - High-level APIs for key management and card operations
Licensed under the AGPL License or http://www.gnu.org/licenses/agpl-3.0.html.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these crates by you shall be licensed as above, without any additional terms or conditions.