5 Commits

Author SHA1 Message Date
Maxime Van Hees
f3da14b957 Merge branch 'append' 2025-09-11 15:31:47 +02:00
Maxime Van Hees
5ea34b4445 update variable name as 'gen' is a reserved keyword since Rust 2024 edition 2025-09-11 15:25:26 +02:00
Maxime Van Hees
d9a3b711d1 Update tot Rust 2024 edition + update Cargo.toml file 2025-09-11 15:24:28 +02:00
Maxime Van Hees
d931770e90 Fix test suite + update Cargo.toml file 2025-09-09 16:04:31 +02:00
Timur Gordon
a87ec4dbb5 add readme 2025-08-27 15:39:59 +02:00
3 changed files with 89 additions and 7 deletions

View File

@@ -1,8 +1,8 @@
[package] [package]
name = "herodb" name = "herodb"
version = "0.0.1" version = "0.0.1"
authors = ["Pin Fang <fpfangpin@hotmail.com>"] authors = ["ThreeFold Tech NV"]
edition = "2021" edition = "2024"
[dependencies] [dependencies]
anyhow = "1.0.59" anyhow = "1.0.59"

View File

@@ -1,5 +1,20 @@
# HeroDB # HeroDB
<<<<<<< HEAD
Redis-compatible database server with encryption and AGE cryptographic operations.
## Features
- Redis protocol compatibility
- String, hash, and list data types
- Key expiration and persistence
- Database encryption with ChaCha20-Poly1305
- AGE encryption/decryption operations
- Digital signatures with Ed25519
- Persistent storage using redb
## Installation
=======
HeroDB is a Redis-compatible database built with Rust, offering a flexible and secure storage solution. It supports two primary storage backends: `redb` (default) and `sled`, both with full encryption capabilities. HeroDB aims to provide a robust and performant key-value store with advanced features like data-at-rest encryption, hash operations, list operations, and cursor-based scanning. HeroDB is a Redis-compatible database built with Rust, offering a flexible and secure storage solution. It supports two primary storage backends: `redb` (default) and `sled`, both with full encryption capabilities. HeroDB aims to provide a robust and performant key-value store with advanced features like data-at-rest encryption, hash operations, list operations, and cursor-based scanning.
## Purpose ## Purpose
@@ -23,11 +38,77 @@ The main purpose of HeroDB is to offer a lightweight, embeddable, and Redis-comp
### Building HeroDB ### Building HeroDB
To build HeroDB, navigate to the project root and run: To build HeroDB, navigate to the project root and run:
>>>>>>> append
```bash ```bash
cargo build --release cargo build --release
``` ```
<<<<<<< HEAD
## Usage
```bash
./target/release/herodb --dir /path/to/db --port 6379
```
### Options
- `--dir`: Database directory (required)
- `--port`: Server port (default: 6379)
- `--debug`: Enable debug logging
- `--encrypt`: Enable database encryption
- `--encryption-key`: Master encryption key for encrypted databases
### Examples
```bash
# Basic server
herodb --dir ./data
# Encrypted database
herodb --dir ./data --encrypt --encryption-key "your-key"
# Custom port with debug
herodb --dir ./data --port 7000 --debug
```
## Redis Commands
Supports standard Redis commands including:
- **Strings**: GET, SET, MGET, MSET, INCR, DEL
- **Hashes**: HGET, HSET, HGETALL, HDEL, HEXISTS
- **Lists**: LPUSH, RPUSH, LPOP, RPOP, LLEN, LRANGE
- **Keys**: KEYS, SCAN, EXISTS, EXPIRE, TTL
- **Transactions**: MULTI, EXEC, DISCARD
- **Server**: PING, ECHO, INFO, CONFIG
## AGE Commands
Extended commands for cryptographic operations:
- **Key Generation**: `AGE GENENC`, `AGE GENSIGN`, `AGE KEYGEN`
- **Encryption**: `AGE ENCRYPT`, `AGE DECRYPT`, `AGE ENCRYPTNAME`
- **Signing**: `AGE SIGN`, `AGE VERIFY`, `AGE SIGNNAME`
- **Management**: `AGE LIST`
## Client Usage
Connect using any Redis client:
```bash
redis-cli -p 6379 SET key value
redis-cli -p 6379 GET key
redis-cli -p 6379 AGE GENENC
```
## Architecture
- **Storage**: redb embedded database
- **Protocol**: Redis RESP protocol over TCP
- **Encryption**: ChaCha20-Poly1305 for data, AGE for operations
- **Concurrency**: Tokio async runtime
=======
### Running HeroDB ### Running HeroDB
You can start HeroDB with different backends and encryption options: You can start HeroDB with different backends and encryption options:
@@ -83,3 +164,4 @@ For more detailed information on commands, features, and advanced usage, please
- [Basics](docs/basics.md) - [Basics](docs/basics.md)
- [Supported Commands](docs/cmds.md) - [Supported Commands](docs/cmds.md)
- [AGE Cryptography](docs/age.md) - [AGE Cryptography](docs/age.md)
>>>>>>> append

View File

@@ -501,11 +501,11 @@ async fn test_07_age_stateless_suite() {
let mut s = connect(port).await; let mut s = connect(port).await;
// GENENC -> [recipient, identity] // GENENC -> [recipient, identity]
let gen = send_cmd(&mut s, &["AGE", "GENENC"]).await; let genenc = send_cmd(&mut s, &["AGE", "GENENC"]).await;
assert!( assert!(
gen.starts_with("*2\r\n$"), genenc.starts_with("*2\r\n$"),
"AGE GENENC should return array [recipient, identity], got:\n{}", "AGE GENENC should return array [recipient, identity], got:\n{}",
gen genenc
); );
// Parse simple RESP array of two bulk strings to extract keys // Parse simple RESP array of two bulk strings to extract keys
@@ -520,7 +520,7 @@ async fn test_07_age_stateless_suite() {
let ident = lines.next().unwrap_or("").to_string(); let ident = lines.next().unwrap_or("").to_string();
(recip, ident) (recip, ident)
} }
let (recipient, identity) = parse_two_bulk_array(&gen); let (recipient, identity) = parse_two_bulk_array(&genenc);
assert!( assert!(
recipient.starts_with("age1") && identity.starts_with("AGE-SECRET-KEY-1"), recipient.starts_with("age1") && identity.starts_with("AGE-SECRET-KEY-1"),
"Unexpected AGE key formats.\nrecipient: {}\nidentity: {}", "Unexpected AGE key formats.\nrecipient: {}\nidentity: {}",