Skip to main content

ads-foundation

Authenticated data structures for Python. Merkle trees, hash-chained audit trails, and a generic prover/verifier framework -- all with zero dependencies.

Based on the ADS4All framework from Alzahrani et al., ENASE 2026.

pip install ads-foundation

ProofTrail: tamper-evident audit trails

Track function calls with cryptographic receipts. Each call gets a Merkle proof that can't be forged or altered after the fact.

from ads_foundation import ProofTrailMonitor

monitor = ProofTrailMonitor()

@monitor.track_tool_call
def query_db(customer_id: str) -> dict:
    return {"balance": 15420.50}

with monitor.session(agent_id="support_bot") as session:
    result = query_db("cust_987")

    receipt = session.get_latest_receipt()
    assert session.verify_receipt(receipt)  # Merkle proof checks out
    print(result)  # {"balance": 15420.50} -- decorator is transparent

Merkle trees

Build trees, generate inclusion proofs, verify them. Domain-separated hashing follows the RFC 9162 (Certificate Transparency) pattern.

from ads_foundation import build_merkle, generate_proof, merkle_verify_proof, root_hash

data = [b"tx1", b"tx2", b"tx3", b"tx4"]
tree = build_merkle(data)

proof = generate_proof(2, tree, len(data))     # prove tx3 is in the tree
assert merkle_verify_proof(b"tx3", proof)       # valid
assert not merkle_verify_proof(b"fake", proof)  # invalid

Authenticated data structures

The core abstraction: separate a data structure into a prover (has the data) and a verifier (has only a hash). The verifier can check operations without seeing the data.

from ads_foundation import Auth, prover_context, verifier_context, shallow_hash
from ads_foundation.bst import BST, insert_auth

# Build a tree
tree = BST.insert(5, BST.insert(3, BST.insert(7, None)))
root = shallow_hash(tree)

# Prover: perform an insert, produce a proof
with prover_context() as p:
    auth_tree = Auth.prover(root, tree)
    auth_tree = insert_auth(10, auth_tree, p)
proof = p.get_proof()
new_root = auth_tree.digest()

# Verifier: replay the insert using only the hash + proof
with verifier_context(proof) as v:
    auth_tree_v = Auth.verifier(root)
    auth_tree_v = insert_auth(10, auth_tree_v, v)
assert auth_tree_v.digest() == new_root  # same result, no data needed

What's in the box

Module What it does
hash SHA-256 utilities, shallow_hash() via singledispatch
merkle Balanced binary Merkle tree with proofs
core Auth[T], ProofStream, prover/verifier context managers
bst Authenticated binary search tree
prooftrail Decorator-based audit trail with Merkle receipts
errors ADSError, ProofError, VerificationError

Design choices

  • Zero dependencies. Only stdlib. Optional httpx for cloud submission.
  • Domain separation. Leaf and node hashes use distinct tags (RFC 9162).
  • Constant-time comparisons. All hash checks use hmac.compare_digest.
  • Type-safe. Ships py.typed; full mypy compatibility.

Extending

Any type with an __ads_hash__ method works with the framework:

from dataclasses import dataclass
from ads_foundation import sha256, combine_hashes, shallow_hash

@dataclass(frozen=True)
class MyRecord:
    data: int

    def __ads_hash__(self) -> bytes:
        return combine_hashes(sha256(b"MyRecord"), shallow_hash(self.data))

License

MIT

Metadata

Release files for ads-foundation 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ads-foundation 0.1.0
File Size Uploaded Provenance Actions
ads_foundation-0.1.0.tar.gz 343.6 kB Without provenance Details for ads_foundation-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ads-foundation 0.1.0
File Interpreter ABI Platform Actions
ads_foundation-0.1.0-py3-none-any.whl Python 3 none any Details for ads_foundation-0.1.0-py3-none-any.whl

Total release size: 359.7 kB

Release files / ads_foundation-0.1.0.tar.gz

Download URL ads_foundation-0.1.0.tar.gz
Size 343.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f3583d3613302106ca5c7250cc8879e447f98ab013c227bab0c0312fa9ee0f7c
BLAKE2b-256 checksum
How to use checksums
2acc7417bb12f6a839b3b25e6da62d5bb4ed861cf7b07314789ba235df391048
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.9

Release files / ads_foundation-0.1.0-py3-none-any.whl

Download URL ads_foundation-0.1.0-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
392f7c622df020cd9b91438c1fdf49310d0fc185bb0c540bbd36690b13796606
BLAKE2b-256 checksum
How to use checksums
db398da656f5ee94d76faf58441f1b6f027d9858775878f323c9135cb2636b61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.9

Security for ads-foundation 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page