baseid-wallet-core
The wallet-core crate provides the business logic for a digital identity wallet, handling credential storage, selection, and presentation.
Installation
Section titled “Installation”[dependencies]baseid-wallet-core = "0.1.0-alpha.1"Create a Wallet
Section titled “Create a Wallet”use baseid_wallet_core::store::InMemoryStore;use baseid_wallet_core::wallet::Wallet;
let store = InMemoryStore::new();let wallet = Wallet::new(store, "did:key:z6MkHolder...".into());Store a Credential
Section titled “Store a Credential”wallet.store_credential("my-degree", jwt_bytes)?;List Credentials
Section titled “List Credentials”let credentials = wallet.list_credentials()?;for (id, _cred) in &credentials { println!("Stored: {id}");}Match Against a Request
Section titled “Match Against a Request”let matches = wallet.match_credentials(&presentation_request)?;// Returns credentials that satisfy the verifier's requirementsStorage Backends
Section titled “Storage Backends”| Backend | Use Case |
|---|---|
InMemoryStore | Testing and development |
Custom Store impl | Production (SQLite, filesystem, secure enclave) |
Implement the Store trait to create a custom backend:
pub trait Store { fn put(&mut self, id: &str, data: &[u8]) -> Result<()>; fn get(&self, id: &str) -> Result<Option<Vec<u8>>>; fn list(&self) -> Result<Vec<String>>; fn delete(&mut self, id: &str) -> Result<()>;}