Skip to content

Add a commitment-based zk redaction layer: pipe tool data by reference#146

Open
lekt9 wants to merge 2 commits into
justrach:mainfrom
lekt9:zk-tool-data-redaction
Open

Add a commitment-based zk redaction layer: pipe tool data by reference#146
lekt9 wants to merge 2 commits into
justrach:mainfrom
lekt9:zk-tool-data-redaction

Conversation

@lekt9
Copy link
Copy Markdown

@lekt9 lekt9 commented May 30, 2026

What

Adds a commitment-based redaction layer so sensitive tool data can be piped
by reference through the agent — the model carries a content-addressed
handle, never the raw bytes, and the executor swaps the handle back to the
real value right before a tool runs (data flows tool → vault → tool).

This is "pointer not payload" as a privacy primitive: the address is revealed,
the value stays hidden.

How

forge_app::redaction (new module):

  • Commitment — a salted sha256(nonce ‖ data). Binding (no other value
    matches) and hiding (the nonce defeats guessing a low-entropy secret), so
    it can be shown to the model without revealing the data.
  • Handlezkref:sha256:<digest>#<label>; the label is non-sensitive
    (e.g. bytes=30). This is all the model ever sees.
  • RedactionVault — an Arc-backed session store: seal(data, label) → Handle,
    open(commitment) → bytes (re-verifies binding), resolve(text) /
    resolve_json(value) swap known handles for their plaintext, leaving unknown
    handles and JSON structure intact.

Wiring: ToolRegistry::call_inner resolves handles in a tool call's
arguments after the args are logged (so logs keep handles, never secrets)
and before dispatch — covering every built-in and MCP tool generically.

Tested

Integration tests (run independently of the crate's unit-test build):

  • commitment binds + hides;
  • a handle pipes a credential by reference without revealing it, and the
    recovered commitment still verifies against the bytes;
  • resolve_json preserves structure and leaves unknown handles untouched.

Honest scope (follow-ups)

  • The seal source — which values get sealed into the vault (a secrets
    provider, or sensitive tool results) — is a deliberate policy decision left
    as the next wire; resolution is the consumer half and is live now.
  • Predicate zero-knowledge (proving a property of the hidden data without
    revealing it) needs a proof system; this PR ships the commit/reveal
    foundation underneath it.

Built on codegraff's existing sha2/dashmap primitives.

lekt9 and others added 2 commits May 31, 2026 01:11
Adds forge_app::redaction: a salted SHA-256 hash commitment (binding +
hiding) and a Handle (commitment + non-revealing label) so a sensitive
tool result can be piped by reference through a content-addressed vault
without the raw bytes entering the model's context. referenced_commitments
recovers handles from a later tool call's arguments so the executor can
resolve them before the tool runs (data flows tool -> vault -> tool).

In-module unit tests plus an integration test (runs independently of the
crate's unit-test build). Orchestrator wiring and predicate (zero-knowledge
proof) layers are follow-ups; this is the commit/reveal foundation.

Co-Authored-By: blackfloofie-a codegraff agent <[email protected]>

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Adds RedactionVault (seal/open/resolve/resolve_json), an Arc-backed session
store: seal a value behind a salted commitment, then resolve its handle back
to the real bytes. Wires resolution into ToolRegistry::call_inner AFTER the
arguments are logged (so logs keep handles, never secrets) and before
dispatch, so a sealed credential/value referenced in a later tool call pipes
by reference instead of through the model. Integration tests cover credential
reuse and JSON-structure-preserving resolution.

The seal source (which values get sealed -- a secrets provider or sensitive
tool results) is the deliberate next wire; predicate (zero-knowledge proof)
verification is a further layer.

Co-Authored-By: blackfloofie-a codegraff agent <[email protected]>

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant