feat: Update SAL Vault examples and documentation
- Renamed examples directory to `_archive` to reflect legacy status. - Updated README.md to reflect current status of vault module, including migration from Sameh's implementation to Lee's. - Temporarily disabled Rhai scripting integration for the vault. - Added notes regarding current and future development steps.
This commit is contained in:
@@ -1,64 +1,76 @@
|
||||
# Hero Vault Cryptography Examples
|
||||
# SAL Vault Examples
|
||||
|
||||
This directory contains examples demonstrating the Hero Vault cryptography functionality integrated into the SAL project.
|
||||
This directory contains examples demonstrating the SAL Vault functionality.
|
||||
|
||||
## Overview
|
||||
|
||||
Hero Vault provides cryptographic operations including:
|
||||
SAL Vault provides secure key management and cryptographic operations including:
|
||||
|
||||
- Key space management (creation, loading, encryption, decryption)
|
||||
- Keypair management (creation, selection, listing)
|
||||
- Digital signatures (signing and verification)
|
||||
- Symmetric encryption (key generation, encryption, decryption)
|
||||
- Ethereum wallet functionality
|
||||
- Smart contract interactions
|
||||
- Key-value store with encryption
|
||||
- Vault creation and management
|
||||
- KeySpace operations (encrypted key-value stores)
|
||||
- Symmetric key generation and operations
|
||||
- Asymmetric key operations (signing and verification)
|
||||
- Secure key derivation from passwords
|
||||
|
||||
## Example Files
|
||||
## Current Status
|
||||
|
||||
- `example.rhai` - Basic example demonstrating key management, signing, and encryption
|
||||
- `advanced_example.rhai` - Advanced example with error handling, conditional logic, and more complex operations
|
||||
- `key_persistence_example.rhai` - Demonstrates creating and saving a key space to disk
|
||||
- `load_existing_space.rhai` - Shows how to load a previously created key space and use its keypairs
|
||||
- `contract_example.rhai` - Demonstrates loading a contract ABI and interacting with smart contracts
|
||||
- `agung_send_transaction.rhai` - Demonstrates sending native tokens on the Agung network
|
||||
- `agung_contract_with_args.rhai` - Shows how to interact with contracts with arguments on Agung
|
||||
⚠️ **Note**: The vault module is currently being updated to use Lee's implementation.
|
||||
The Rhai scripting integration is temporarily disabled while we adapt the examples
|
||||
to work with the new vault API.
|
||||
|
||||
## Running the Examples
|
||||
## Available Operations
|
||||
|
||||
You can run the examples using the `herodo` tool that comes with the SAL project:
|
||||
- **Vault Management**: Create and manage vault instances
|
||||
- **KeySpace Operations**: Open encrypted key-value stores within vaults
|
||||
- **Symmetric Encryption**: Generate keys and encrypt/decrypt data
|
||||
- **Asymmetric Operations**: Create keypairs, sign messages, verify signatures
|
||||
|
||||
```bash
|
||||
# Run a single example
|
||||
herodo --path example.rhai
|
||||
## Example Files (Legacy - Sameh's Implementation)
|
||||
|
||||
# Run all examples using the provided script
|
||||
./run_examples.sh
|
||||
⚠️ **These examples are currently archived and use the previous vault implementation**:
|
||||
|
||||
- `_archive/example.rhai` - Basic example demonstrating key management, signing, and encryption
|
||||
- `_archive/advanced_example.rhai` - Advanced example with error handling and complex operations
|
||||
- `_archive/key_persistence_example.rhai` - Demonstrates creating and saving a key space to disk
|
||||
- `_archive/load_existing_space.rhai` - Shows how to load a previously created key space
|
||||
- `_archive/contract_example.rhai` - Demonstrates smart contract interactions (Ethereum)
|
||||
- `_archive/agung_send_transaction.rhai` - Demonstrates Ethereum transactions on Agung network
|
||||
- `_archive/agung_contract_with_args.rhai` - Shows contract interactions with arguments
|
||||
|
||||
## Current Implementation (Lee's Vault)
|
||||
|
||||
The current vault implementation provides:
|
||||
|
||||
```rust
|
||||
// Create a new vault
|
||||
let vault = Vault::new(&path).await?;
|
||||
|
||||
// Open an encrypted keyspace
|
||||
let keyspace = vault.open_keyspace("my_space", "password").await?;
|
||||
|
||||
// Perform cryptographic operations
|
||||
// (API documentation coming soon)
|
||||
```
|
||||
|
||||
## Key Space Storage
|
||||
## Migration Status
|
||||
|
||||
Key spaces are stored in the `~/.hero-vault/key-spaces/` directory by default. Each key space is stored in a separate JSON file named after the key space (e.g., `my_space.json`).
|
||||
|
||||
## Ethereum Functionality
|
||||
|
||||
The Hero Vault module provides comprehensive Ethereum wallet functionality:
|
||||
|
||||
- Creating and managing wallets for different networks
|
||||
- Sending ETH transactions
|
||||
- Checking balances
|
||||
- Interacting with smart contracts (read and write functions)
|
||||
- Support for multiple networks (Ethereum, Gnosis, Peaq, Agung, etc.)
|
||||
- ✅ **Vault Core**: Lee's implementation is active
|
||||
- ✅ **Archive**: Sameh's implementation preserved in `vault/_archive/`
|
||||
- ⏳ **Rhai Integration**: Being developed for Lee's implementation
|
||||
- ⏳ **Examples**: Will be updated to use Lee's API
|
||||
- ❌ **Ethereum Features**: Not available in Lee's implementation
|
||||
|
||||
## Security
|
||||
|
||||
Key spaces are encrypted with ChaCha20Poly1305 using a key derived from the provided password. The encryption ensures that the key material is secure at rest.
|
||||
The vault uses:
|
||||
|
||||
## Best Practices
|
||||
- **ChaCha20Poly1305** for symmetric encryption
|
||||
- **Password-based key derivation** for keyspace encryption
|
||||
- **Secure key storage** with proper isolation
|
||||
|
||||
1. **Use Strong Passwords**: Since the security of your key spaces depends on the strength of your passwords, use strong, unique passwords.
|
||||
2. **Backup Key Spaces**: Regularly backup your key spaces directory to prevent data loss.
|
||||
3. **Script Organization**: Split your scripts into logical units, with separate scripts for key creation and key usage.
|
||||
4. **Error Handling**: Always check the return values of functions to ensure operations succeeded before proceeding.
|
||||
5. **Network Selection**: When working with Ethereum functionality, be explicit about which network you're targeting to avoid confusion.
|
||||
6. **Gas Management**: For Ethereum transactions, consider gas costs and set appropriate gas limits.
|
||||
## Next Steps
|
||||
|
||||
1. **Rhai Integration**: Implement Rhai bindings for Lee's vault
|
||||
2. **New Examples**: Create examples using Lee's simpler API
|
||||
3. **Documentation**: Complete API documentation for Lee's implementation
|
||||
4. **Migration Guide**: Provide guidance for users migrating from Sameh's implementation
|
||||
|
Reference in New Issue
Block a user