Skip to main content

OCC cryptographic proof signing for LangChain

Project description

occ-langchain

OCC cryptographic proof signing for LangChain and LangGraph.

Every tool call produces an Ed25519-signed proof entry in proof.jsonl, creating a tamper-evident audit log of agent actions.

Install

pip install occ-langchain

Quick Start

Callback Handler (recommended)

from langchain.agents import AgentExecutor
from occ_langchain import OccCallbackHandler

handler = OccCallbackHandler()
executor = AgentExecutor(
    agent=your_agent,
    tools=tools,
    callbacks=[handler],
)
result = executor.invoke({"input": "Search for OCC proofs"})
# proof.jsonl now contains signed proof entries

Wrap Individual Tools

from langchain_community.tools import DuckDuckGoSearchRun
from occ_langchain import OccTool

search = DuckDuckGoSearchRun()
safe_search = OccTool(inner=search)

Wrap All Tools

from occ_langchain import wrap_tools

safe_tools = wrap_tools([search_tool, calc_tool])
executor = AgentExecutor(agent=agent, tools=safe_tools)

Custom Signer

from occ_langchain import OCCSigner, OccCallbackHandler

signer = OCCSigner(state_dir="/tmp/.occ", proof_file="audit.jsonl")
handler = OccCallbackHandler(signer=signer)

Proof Format

Each line in proof.jsonl is a JSON object:

{
  "version": "occ/proof/1",
  "timestamp": "2026-03-20T12:00:00.000Z",
  "signer": "<base64url-ed25519-public-key>",
  "payload": {
    "type": "tool-call",
    "tool": "search",
    "inputHash": "<sha256-hex>",
    "outputHash": "<sha256-hex>"
  },
  "signature": "<base64url-ed25519-signature>",
  "prev": "<sha256-hex-of-previous-proof>"
}

Proofs are chained: each proof's prev field contains the SHA-256 hash of the previous proof's canonical JSON.

Configuration

  • State directory: Keypair stored in .occ/signer-state.json (defaults to CWD)
  • Proof file: Defaults to proof.jsonl in CWD
  • Both configurable via OCCSigner(state_dir=..., proof_file=...)

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

occ_langchain-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

occ_langchain-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file occ_langchain-0.1.0.tar.gz.

File metadata

  • Download URL: occ_langchain-0.1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for occ_langchain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6972418ae01ebcfa7570803b44b463e7f22f98e39114cde25fb169368fb76be8
MD5 783b7c5e0a6d95c721a2d38388d3712c
BLAKE2b-256 bb0ac6e39cdd335e34381caa9bcc740f8f1436249de3561c4346770859d53447

See more details on using hashes here.

File details

Details for the file occ_langchain-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: occ_langchain-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for occ_langchain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae082e00fde26fabc3bde1af1b13ee5de001f3589fa9beeacc5000b068e03fe1
MD5 f4095e5945092dcc0ba9dae13888876b
BLAKE2b-256 20a7d5168bdbb785aa633695f17e440df45648499e693e1846e39478c777a85d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page