Skip to main content

OCC cryptographic proof signing for Google Gemini

Project description

occ-gemini

OCC cryptographic proof signing for Google Gemini.

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

Install

pip install occ-gemini

Quick Start

Wrap a Client (recommended)

from google import genai
from occ_gemini import wrap_client

client = genai.Client(api_key="...")
safe_client = wrap_client(client)
response = safe_client.models.generate_content(
    model="gemini-2.0-flash",
    contents="What's the weather?",
)
# proof.jsonl now contains signed proof entries for any function calls

Decorate Individual Tools

from occ_gemini import occ_tool

@occ_tool
def get_weather(location: str) -> str:
    return f"Sunny in {location}"

Custom Signer

from occ_gemini import OCCSigner, wrap_client

signer = OCCSigner(state_dir="/tmp/.occ", proof_file="audit.jsonl")
safe_client = wrap_client(client, signer=signer)

Legacy API (wrap_model)

wrap_model also accepts a google.genai.Client or a legacy google.generativeai.GenerativeModel:

from occ_gemini import wrap_model

safe_client = wrap_model(client)

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": "get_weather",
    "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_gemini-0.1.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

occ_gemini-0.1.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file occ_gemini-0.1.1.tar.gz.

File metadata

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

File hashes

Hashes for occ_gemini-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f94df3e325b1d27bd6d045ee66257d9fcbf5c78a7fedb2c83ac490acf289a853
MD5 10d755dff92b79398d33cec78f45fd1e
BLAKE2b-256 0b7de2d5d556000a6f0450a6031bd2362d43c0462c03c01d075302cdf1cbbdf3

See more details on using hashes here.

File details

Details for the file occ_gemini-0.1.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for occ_gemini-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce1cfc959d754a5d839dca9914845aeb9019d75ae49bfff64fbd6d89978329a1
MD5 7735afe4c10ece80060e95198d0c5df9
BLAKE2b-256 65aeeea2b8f992e6a4d3e79b974b6edefaba93446af77ca093c7e00f032c1c83

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