Expand description
§AmateRS - Fully Homomorphic Encrypted Distributed Database
AmateRS (天照RS) is a distributed database system providing Encryption-in-Use capabilities via TFHE (Fully Homomorphic Encryption). The name comes from Amaterasu (天照), the Japanese sun goddess.
This is the facade crate that re-exports all AmateRS components for
convenient, unified access. Instead of depending on individual crates
(amaters-core, amaters-net, amaters-cluster, amaters-sdk-rust),
you can depend on amaters alone and access everything through a
single namespace.
§Architecture (Japanese Mythology Theme)
| Component | Origin | Role |
|---|---|---|
| Iwato (岩戸) | Heavenly Rock Cave | Storage Engine |
| Yata (八咫鏡) | Eight-Span Mirror | Compute Engine |
| Ukehi (宇気比) | Sacred Pledge | Consensus Layer |
| Musubi (結び) | The Knot | Network Layer |
§Quick Start
use amaters::prelude::*;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Connect to AmateRS server
let client = AmateRSClient::connect("http://localhost:50051").await?;
// Store encrypted data
let key = Key::from_str("user:123");
let value = CipherBlob::new(vec![/* encrypted bytes */]);
client.set("users", &key, &value).await?;
// Retrieve data
if let Some(data) = client.get("users", &key).await? {
println!("Retrieved {} bytes", data.len());
}
Ok(())
}§Storage Engine (Iwato)
The storage engine is based on an LSM-Tree with WiscKey value separation, WAL for durability, bloom filters, and block caching.
use amaters::core::storage::LsmTree;
use amaters::core::{CipherBlob, Key};
let dir = std::env::temp_dir().join("amaters_doc_example");
let tree = LsmTree::new(&dir)?;
// Put
tree.put(Key::from_str("hello"), CipherBlob::new(vec![1, 2, 3]))?;
// Get
let val = tree.get(&Key::from_str("hello"))?;
assert!(val.is_some());
// Delete
tree.delete(Key::from_str("hello"))?;
tree.close()?;
std::fs::remove_dir_all(&dir).ok();§Query Builder
Build queries with a fluent API. Queries can target both local storage and remote servers via the SDK.
use amaters::core::{Key, CipherBlob, Predicate, col};
use amaters::sdk::query;
// Point lookup
let q1 = query("users").get(Key::from_str("user:123"));
// Filter with predicates
let q2 = query("users")
.where_clause()
.eq(col("status"), CipherBlob::new(vec![1]))
.and(Predicate::Gt(col("age"), CipherBlob::new(vec![18])))
.build();
// Range scan
let q3 = query("events")
.range(Key::from_str("2024-01-01"), Key::from_str("2024-12-31"));§Compression
The storage layer supports pluggable compression:
use amaters::core::storage::compression::{compress_block, decompress_block, CompressionType};
let data = b"hello world, compressing with LZ4";
let compressed = compress_block(data, CompressionType::Lz4)?;
let decompressed = decompress_block(&compressed, CompressionType::Lz4, data.len())?;
assert_eq!(&decompressed, &data[..]);§Consensus (Ukehi)
use amaters::cluster::{RaftNode, RaftConfig, Command};
let config = RaftConfig::new(1, vec![1, 2, 3]);
let node = RaftNode::new(config)?;
let cmd = Command::from_str("SET key value");
let index = node.propose(cmd)?;§Module Structure
| Module | Crate | Description |
|---|---|---|
core | amaters-core | Storage, compute, types, and errors |
net | amaters-net | gRPC services and mTLS |
cluster | amaters-cluster | Raft consensus |
sdk | amaters-sdk-rust | Client SDK |
§Feature Flags
| Feature | Description |
|---|---|
full | Enable all features (mtls + fhe) |
mtls | Enable mTLS support in the networking layer |
fhe | Enable full FHE support with TFHE in the SDK |
Re-exports§
pub use amaters_core as core;pub use amaters_net as net;pub use amaters_cluster as cluster;pub use amaters_sdk_rust as sdk;
Modules§
- prelude
- Prelude module for convenient imports.