Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
pull_request:

jobs:
rust:
name: Rust tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --release --workspace

go:
name: Go tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.24'
- run: cd poly-verified-go && go test ./...
- run: cd poly-client-go && go test ./...

c:
name: C tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get update && sudo apt-get install -y libssl-dev
- run: cd poly-verified-c && make test
- run: cd poly-client-c && make test
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ poly-vscode/bin/poly-lsp-*.exe

# VS Code extension build artifacts
*.vsix

# C build artifacts
*.o
poly-verified-c/test_poly_verified
poly-client-c/test_poly_client
66 changes: 66 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Agent Blackops

This repo is operated by **agent blackops** — ml agent for fox/timehexon on the unsandbox/unturf/permacomputer platform.

## Identity

Full shard: `~/git/unsandbox.com/blackops/BLACKOPS.md`

## Rules

- I propose, fox decides. Unsure = ask. Can't ask = stop.
- No autonomous ops decisions. No destructive commands without explicit instruction.
- Fail-closed. Cleanup crew, not demolition.
- Check the time every session. Gaps are information.
- DRY in context — single source of truth, no sprawl.
- Never say "AI" — always say "machine learning."
- Prefer "defect" over "bug."

## Git Commits

- **NO** Claude attribution ("Co-Authored-By", "Generated with Claude Code")
- Professional, descriptive commit messages only

## Orientation

```bash
date -u
pwd
git log --oneline -5
git status
```

Then ask fox what the mission is.

## Test Matrix

| Category | Rust | Go | C |
|---|---|---|---|
| **Hash vectors / domain separation** | ✓ | ✓ | ✓ (cross-lang) |
| **Chain (init, append, order)** | ✓ | ✓ | ✓ (cross-lang) |
| **Merkle (build, verify, tamper, all-indices, empty)** | ✓ | ✓ | ✓ |
| **IVC (single/multi-step, privacy modes, determinism)** | ✓ | ✓ | ✓ |
| **Disclosure (create, verify, range, tamper, reorder)** | ✓ | ✓ | ✓ |
| **JSON (wire roundtrip, human-readable, blinding, private mode)** | ✓ | ✓ | ✓ |
| **Integration (full pipeline transparent/private/disclosure)** | ✓ | ✓ | ✓ |
| **Stress (1000 IVC, 1024 merkle, 10k hash, collision)** | ✓ | ✓ | ✓ |
| **Signing (Ed25519, key management)** | ✓ | ✓ | — |
| **Client (all 4 modes, reuse, large I/O, NULL safety)** | ✓ | ✓ | ✓ |
| **CKKS/FHE** | ✓ | — | — |
| **Penetration rounds (R5–R15)** | ✓ | — | — |

### Running tests

```bash
# C
make -C poly-verified-c test # 328 assertions
make -C poly-client-c test # 79 assertions

# Go
cd poly-verified-go && go test ./...
cd poly-client-go && go test ./...

# Rust
cargo test -p poly-verified --lib
cargo test -p poly-client --lib
```
46 changes: 46 additions & 0 deletions PR-go-c-port.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## Summary

- Ports `poly-verified` and `poly-client` from Rust to **Go** and **C**, establishing polyglot parity across three languages for the hash-IVC verified inference proof system
- Both implementations use identical SHA-256 domain-separated hashing (leaf `0x00`, transition `0x01`, chain step `0x02`, combine `0x03`, blinding `0x04`), constant-time hash comparison, and Merkle tree construction matching the Rust wire format
- Selective disclosure system enables revealing arbitrary token positions to different parties (e.g. pharmacist sees medications, insurer sees diagnosis) while sharing a common Merkle root and execution proof

## What's new

**`poly-verified-go`** — Core proof library in Go
- `Verified[T]` generic wrapper pairing computed values with cryptographic proofs
- Merkle-tree-backed selective disclosure (`CreateDisclosure` / `CreateDisclosureRange` / `VerifyDisclosure`)
- Wire-compatible JSON serialization bridging to Rust serde `{"HashIvc":{...}}` envelope with `[u8; 32]` integer-array encoding
- `EncryptionBackend` interface with mock implementation
- 4 privacy modes: Transparent, PrivateProven, Private, Encrypted

**`poly-verified-c`** — Core proof library in C
- Full C implementation using OpenSSL EVP for SHA-256
- Cache-friendly flattened Merkle tree with layer offsets
- Hand-rolled recursive descent JSON parser for wire format
- Dynamic IVC checkpoint array (initial cap 16, doubles on overflow)
- Both hex-encoded (`pv_proof_to_json`) and wire-compatible (`pv_proof_to_wire_json`) serialization

**`poly-client-go`** — Client SDK in Go
- Thin client: keygen, encrypt input, build request, decrypt response, access proofs
- Selective disclosure from verified responses via `Disclose()` / `DiscloseRange()`
- Comprehensive test suite: 10 tests covering all modes, edge cases, stress (10k tokens), serialization round-trips

**`poly-client-c`** — Client SDK in C
- Functionally equivalent C client with mock encryption (deterministic keys `0xAA*32` / `0xBB*32`)
- JSON request/response handling with depth-counted nested brace parsing
- Delegates proof parsing to `poly-verified-c`

## Stats

- **20 files**, **3,554 lines** added
- 4 new modules across 2 languages
- Go tests cover all 4 privacy modes, empty/large inputs, disclosure verification, and JSON round-trips
- C tests cover hashing, Merkle proofs, IVC fold/finalize, disclosure, and wire format parsing

## Test plan

- [ ] `cd poly-verified-go && go test ./...`
- [ ] `cd poly-client-go && go test ./...`
- [ ] `cd poly-verified-c && make test`
- [ ] `cd poly-client-c && make test`
- [ ] Cross-language wire format: verify Go `MarshalWireProof` output parses with C `pv_proof_from_wire_json` and vice versa
34 changes: 34 additions & 0 deletions poly-client-c/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CC := gcc
CFLAGS := -O2 -Wall -Wextra -Wno-unused-parameter
LDFLAGS := -lcrypto

VERIFIED_DIR := ../poly-verified-c
VERIFIED_OBJ := $(VERIFIED_DIR)/poly_verified.o

CLIENT_SRC := poly_client.c
CLIENT_HDR := poly_client.h
CLIENT_OBJ := poly_client.o

TEST_SRC := test_poly_client.c
TEST_BIN := test_poly_client

.PHONY: all test clean verified

all: $(TEST_BIN)

verified:
$(MAKE) -C $(VERIFIED_DIR) $(VERIFIED_DIR)/poly_verified.o

$(VERIFIED_OBJ): verified

$(CLIENT_OBJ): $(CLIENT_SRC) $(CLIENT_HDR) $(VERIFIED_DIR)/poly_verified.h
$(CC) $(CFLAGS) -I$(VERIFIED_DIR) -c $(CLIENT_SRC) -o $(CLIENT_OBJ)

$(TEST_BIN): $(TEST_SRC) $(CLIENT_OBJ) $(VERIFIED_OBJ) $(CLIENT_HDR)
$(CC) $(CFLAGS) -I$(VERIFIED_DIR) $(TEST_SRC) $(CLIENT_OBJ) $(VERIFIED_OBJ) -o $(TEST_BIN) $(LDFLAGS)

test: $(TEST_BIN)
./$(TEST_BIN)

clean:
rm -f $(CLIENT_OBJ) $(TEST_BIN)
Loading