53dbdf0f1d
Workspace en 4 ejes (core/modules/apps/shared):
- core/: 24 crates de arje (Init systemd-compatible: ente-card, ente-zero,
ente-kernel, ente-bus, ente-cas, ente-soma, ente-wasm, ente-snapshot,
ente-brain, ente-echo, ente-policy-provider, + 12 crates *-compat)
- modules/semantic_dht/: 5 crates de minga (minga-core con AST/CAS/MST,
minga-p2p con libp2p Kad, minga-store, minga-vfs, minga-cli)
- modules/ui_engine/: 11 crates de yahweh (libs/{core,theme,bus,providers},
widgets/{tree,splitter,tabs,tiled,container_core,text_input})
- apps/: 5 crates de yahweh (file_explorer, database_explorer, text_viewer,
image_viewer, yahweh-shell)
- shared_wit/protocol.wit: handshake/lifecycle inicial
Cargo.toml unificado: thiserror bumped a 2 (transparente para arje), tokio
"full", paths intra-workspace de yahweh redirigidos a su nueva ubicación.
cargo check --workspace: 0 errores, 17 warnings (dead code preexistente).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
//! Persistencia en disco de keypairs cifrados.
|
|
//!
|
|
//! El cifrado en sí (AES-GCM + Argon2id) vive en `minga-core`, que es
|
|
//! pure logic. Aquí solo se monta la parte de IO: leer/escribir
|
|
//! bytes a un archivo.
|
|
//!
|
|
//! Layout del archivo: el blob crudo que produce
|
|
//! `Keypair::encrypt(passphrase)`. 85 bytes total.
|
|
|
|
use std::fs;
|
|
use std::io;
|
|
use std::path::Path;
|
|
|
|
use minga_core::{Keypair, KeypairCryptoError};
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum KeypairFileError {
|
|
#[error("io: {0}")]
|
|
Io(#[from] io::Error),
|
|
|
|
#[error("crypto: {0}")]
|
|
Crypto(#[from] KeypairCryptoError),
|
|
}
|
|
|
|
/// Guarda un keypair cifrado con la passphrase en `path`. Si el
|
|
/// archivo ya existe, lo sobrescribe.
|
|
pub fn save<P: AsRef<Path>>(
|
|
keypair: &Keypair,
|
|
path: P,
|
|
passphrase: &str,
|
|
) -> Result<(), KeypairFileError> {
|
|
let blob = keypair.encrypt(passphrase)?;
|
|
fs::write(path, blob)?;
|
|
Ok(())
|
|
}
|
|
|
|
/// Carga un keypair desde un archivo cifrado.
|
|
pub fn load<P: AsRef<Path>>(path: P, passphrase: &str) -> Result<Keypair, KeypairFileError> {
|
|
let blob = fs::read(path)?;
|
|
Ok(Keypair::decrypt(&blob, passphrase)?)
|
|
}
|