mina_node_account/
lib.rs

1//! Account management for Mina nodes
2//!
3//! This crate provides a high-level interface for managing Mina accounts,
4//! built on top of the
5//! [`mina-signer`](https://github.com/o1-labs/proof-systems/tree/master/signer)
6//! crate. It handles cryptographic key generation, encryption/decryption of
7//! secret keys, and address handling.
8//!
9//! # Overview
10//!
11//! The crate exports two main types:
12//! - [`AccountSecretKey`] - Represents a private key that can be used to
13//!   sign transactions
14//! - [`AccountPublicKey`] - Represents a public key/address for receiving
15//!   transactions
16//!
17//! # Key Features
18//!
19//! - **Key Generation**: Generate new random keypairs for Mina accounts
20//! - **Key Encryption**: Encrypt and decrypt secret keys using password-based
21//!   encryption
22//! - **Address Format**: Encode and decode Mina addresses using the standard
23//!   Base58Check format
24//! - **Key Import/Export**: Read and write encrypted keys from/to files
25//!
26//! # Example Usage
27//!
28//! ```
29//! use mina_node_account::{AccountSecretKey, AccountPublicKey};
30//! use std::env;
31//!
32//! // Generate a new keypair
33//! let secret_key = AccountSecretKey::rand();
34//! let public_key = secret_key.public_key();
35//!
36//! // Save encrypted key to file in temp directory
37//! let temp_dir = env::temp_dir();
38//! let path = temp_dir.join(format!("test-wallet-{}", public_key));
39//! let password = "secure-password";
40//! secret_key.to_encrypted_file(&path, password)
41//!     .expect("Failed to save key");
42//!
43//! // Load encrypted key from file
44//! let loaded_key = AccountSecretKey::from_encrypted_file(&path, password)
45//!     .expect("Failed to load key");
46//!
47//! // Get the public address
48//! let address = AccountPublicKey::from(loaded_key.public_key());
49//! println!("Address: {}", address);
50//!
51//! // Verify the keys match
52//! assert_eq!(secret_key.public_key().to_string(),
53//!            loaded_key.public_key().to_string());
54//!
55//! // Clean up
56//! std::fs::remove_file(&path).ok();
57//! ```
58//!
59//! # Cryptography
60//!
61//! Mina uses the Pasta curves (Pallas and Vesta) for its cryptographic
62//! operations. These curves are specifically designed for efficient
63//! recursive zero-knowledge proof composition.
64
65mod public_key;
66mod secret_key;
67pub use public_key::AccountPublicKey;
68pub use secret_key::AccountSecretKey;