Files
hanzo-devandClaude Opus 4.8 fab434685b feat(hanzovfs): end-to-end post-quantum native SQLite VFS (durable)
Replaces the in-memory prototype with the real thing: per-database DEK seals
every 4 KiB page with ChaCha20-Poly1305, persisted to a backend dir; the DEK
itself is sealed with luxfi/age PQ-hybrid (ML-KEM-768 + X25519). The full path
tenant page → encrypted block → object is end-to-end post-quantum — recording
ciphertext yields nothing without the ML-KEM identity.

- Config{Dir, Recipients, Identities}; Register(name, cfg); GenerateIdentity().
- Test proves: DEK is age-sealed (never raw), pages carry no plaintext SQLite,
  right identity → data durable across reopen, WRONG identity → open rejected.
- Durable PQ bench (arm64): 720K insert/s, 59.6K point-read/s — 2.6x writes /
  5x reads vs the FUSE path, and post-quantum.

No FUSE, no cgo, no kludge.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 20:48:33 +00:00

49 lines
1.7 KiB
Go

// hanzovfs-bench: native PQ SQLite VFS throughput (in-process, no FUSE).
// go run github.com/hanzoai/sqlite3/cmd/hanzovfs-bench@latest
package main
import (
"fmt"
"os"
"runtime"
"time"
"github.com/hanzoai/sqlite3"
_ "github.com/hanzoai/sqlite3/embed"
"github.com/hanzoai/sqlite3/hanzovfs"
"github.com/luxfi/age"
)
func bench(label, dsn string) {
db, err := sqlite3.Open(dsn)
if err != nil { fmt.Printf("%-24s OPEN ERR %v\n", label, err); return }
defer db.Close()
db.Exec(`PRAGMA journal_mode=MEMORY; PRAGMA synchronous=OFF;`)
db.Exec(`CREATE TABLE t(id INTEGER PRIMARY KEY, email TEXT, body TEXT)`)
const n = 20000
t0 := time.Now()
db.Exec("BEGIN")
st, _, _ := db.Prepare("INSERT INTO t(email,body) VALUES(?,?)")
for i := 0; i < n; i++ {
st.BindText(1, fmt.Sprintf("u%d@hanzo.ai", i))
st.BindText(2, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
st.Step(); st.Reset()
}
st.Close(); db.Exec("COMMIT")
ins := float64(n) / time.Since(t0).Seconds()
t0 = time.Now()
sel, _, _ := db.Prepare("SELECT body FROM t WHERE id=?")
for i := 0; i < 5000; i++ { sel.BindInt(1, 1+(i*7)%n); sel.Step(); sel.Reset() }
sel.Close()
fmt.Printf("%-24s insert=%9.0f rows/s point_sel=%9.0f q/s\n", label, ins, 5000/time.Since(t0).Seconds())
}
func main() {
fmt.Printf("hanzovfs-bench %s/%s (%d CPU)\n", runtime.GOOS, runtime.GOARCH, runtime.NumCPU())
id, rcpt, err := hanzovfs.GenerateIdentity()
if err != nil { panic(err) }
dir, _ := os.MkdirTemp("", "hvfs")
hanzovfs.Register("pq", hanzovfs.Config{Dir: dir, Recipients: []age.Recipient{rcpt}, Identities: []age.Identity{id}})
bench("native PQ VFS (ML-KEM)", "file:/orgs/acme/bench.db?vfs=pq")
}