Skip to main content

Module store

Module store 

Source
Expand description

Key storage traits and implementations.

This module provides secure key storage functionality with:

  • A trait-based interface for pluggable storage backends
  • A file-based implementation storing encrypted keys in ~/.txgate/keys/
  • Automatic encryption/decryption using ChaCha20-Poly1305 with Argon2id

§Security Properties

  • Encryption at rest: All keys are encrypted before storage
  • Restricted permissions: Files are created with 0600 (owner read/write only)
  • Atomic writes: Uses temp file + rename to prevent corruption
  • Thread safety: Implementations are Send + Sync

§Example

use txgate_crypto::store::{KeyStore, FileKeyStore};
use txgate_crypto::keys::SecretKey;

// Create a key store
let store = FileKeyStore::new().expect("failed to create key store");

// Store a key
let key = SecretKey::generate();
store.store("my-wallet", &key, "secure-passphrase").expect("failed to store key");

// List stored keys
let keys = store.list().expect("failed to list keys");
println!("Stored keys: {:?}", keys);

// Load the key back
let loaded = store.load("my-wallet", "secure-passphrase").expect("failed to load key");

Structs§

FileKeyStore
File-based key storage in ~/.txgate/keys/.

Traits§

KeyStore
Trait for secure key storage.