Skip to main content

Official Python SDK for the CertiSigma attestation & verification API

Project description

CertiSigma Python SDK

Official Python client for the CertiSigma cryptographic attestation API.

PyPI npm License: MIT

Installation

pip install certisigma

Or from source:

cd sdk/python
pip install -e .

Quick Start

from certisigma import CertiSigmaClient, hash_file, hash_bytes

client = CertiSigmaClient(api_key="cs_live_your_key_here")

# 1. Compute the SHA-256 hash of your file
file_hash = hash_file("contract.pdf")

# 2. Attest — creates a timestamped, signed proof of existence
result = client.attest(file_hash, source="my-app")
print(f"Attestation: {result.id} at {result.timestamp}")
print(f"ECDSA signature: {result.signature}")

# 3. Verify — confirm the hash was attested
check = client.verify(file_hash)
print(f"Exists: {check.exists}, Level: {check.level}")

# Or hash raw bytes
data_hash = hash_bytes(b"any raw content")
result = client.attest(data_hash)

Hashing Utilities

Standalone SHA-256 hash functions -- compute hashes without attestation:

from certisigma import hash_file, hash_bytes

# Hash a file (streamed, constant memory)
file_hash = hash_file("/path/to/document.pdf")
print(f"SHA-256: {file_hash}")

# Hash raw bytes
data_hash = hash_bytes(b"raw content")

# Verify a file against a known hash
assert hash_file("/path/to/document.pdf") == file_hash

Or hash + attest in one step:

result = client.attest_file("/path/to/document.pdf")
print(f"Attested: {result.hash_hex}")

Async Support

import asyncio
from certisigma import AsyncCertiSigmaClient

async def main():
    async with AsyncCertiSigmaClient(api_key="cs_live_xxx") as client:
        result = await client.attest("abcdef..." * 4 + "0" * 16)
        print(result.id)

asyncio.run(main())

Batch Operations

# Attest up to 100 hashes in one call
batch = client.batch_attest(
    ["aabb..." * 4, "ccdd..." * 4],
    source="monthly-invoices"
)
print(f"Created: {batch.created}, Existing: {batch.existing}")

# Verify batch
results = client.batch_verify(["aabb..." * 4, "ccdd..." * 4])
print(f"Found: {results.found}/{results.count}")

Metadata Management

# Update claim metadata
result = client.update_metadata("att_1234", source="pipeline-v2", extra_data={"project": "alpha"})

# Soft-delete claim
client.delete_metadata("att_1234")

# Get evidence
evidence = client.get_evidence("att_1234")
print(evidence.level, evidence.t0)

Client-Side Encryption (Zero Knowledge)

Requires: pip install certisigma[crypto]

from certisigma.crypto import generate_key, encrypt_metadata, decrypt_metadata

# Generate a key (store securely — server never sees it)
key = generate_key()

# Encrypt before sending
encrypted = encrypt_metadata({"secret": "classified"}, key)
result = client.attest(hash_hex, extra_data=encrypted, client_encrypted=True)

# Decrypt after retrieving
plaintext = decrypt_metadata(result.extra_data, key)

Error Handling

from certisigma import (
    CertiSigmaError,
    AuthenticationError,
    RateLimitError,
    QuotaExceededError,
)

try:
    client.attest(hash_hex)
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")
except QuotaExceededError:
    print("Monthly quota reached")
except CertiSigmaError as e:
    print(f"API error {e.status_code}: {e}")

Configuration

Parameter Default Description
api_key (required) Bearer token (cs_live_...)
base_url https://api.certisigma.ch API endpoint
timeout 30.0 Request timeout in seconds

Requirements

  • Python 3.10+
  • httpx >= 0.25.0
  • cryptography >= 44.0.0 (optional, for certisigma.crypto)

License

MIT — Ten Sigma Sagl, Lugano, Switzerland

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

certisigma-1.2.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

certisigma-1.2.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file certisigma-1.2.1.tar.gz.

File metadata

  • Download URL: certisigma-1.2.1.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for certisigma-1.2.1.tar.gz
Algorithm Hash digest
SHA256 d2e538cffac4694962095de89d6cc7088d90a31cb8e4f064723804abb1a4d62e
MD5 706f9f912119e0e6316f7e5560f6c11e
BLAKE2b-256 9bd36b69461ae8679e3842abb954c6231d2b37927312902467f57f28970a2280

See more details on using hashes here.

File details

Details for the file certisigma-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: certisigma-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for certisigma-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6a52061bbff3b6905f44e3571a89273764157c1c2e0e5765e915639ab21e80e2
MD5 d7cad72b0247ad8d8fe8cbde8856f5c0
BLAKE2b-256 7a46718b556a2d96f4cae4c80cfbc6f1d3cb1503ffb3b9167511c9c66bf203e9

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