Metadata-Version: 2.4
Name: tersign
Version: 0.1.6
Summary: Tersign — the evidence layer for the agent economy. Offline verification of counter-signed receipts, chains, and evidence bundles. Zero dependencies.
Author: Tersign
License: MIT
Project-URL: Homepage, https://tersign.ai
Project-URL: Repository, https://github.com/tersignhq/tersign-py
Keywords: x402,evidence,receipts,agent-economy,eip-712,rfc-8785,verification
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# tersign (Python)

```bash
pip install tersign
```


Tersign — the evidence layer for the agent economy. This package is the
**verification-first Python SDK**: zero dependencies, standard library only —
the verify path a tribunal, examiner, or CI job can run with nothing installed.

```bash
python3 -m tersign verify receipt.json            # offline — no network, ever
python3 -m tersign verify 0x<digest> --ledger …   # chain lookup (explicit network)
```

```python
from tersign import verify_receipt, digest_of, chain_link_digest, verify_link, verify_commitment

result = verify_receipt(signed_receipt)        # {'valid': True, 'signer': '0x…', 'digest': '0x…'}
```

What it covers (v0.1):

- **RFC 8785 (JCS) canonical form** + the Tersign artifact digest
  (`keccak256(utf8(JCS(v)))`) and chain-link constructor — byte-compatible with
  the TypeScript reference, pinned by shared cross-implementation vectors.
- **EIP-712 recovery** for the upstream `x402 receipt` domain (the merged
  offer-receipt extension) — pure-python secp256k1, canonical low-s only.
- **Counter-signature verification** (`verify_link`): EIP-191 over the raw
  32-byte chain-link digest, recovered against the published ledger signer
  (`https://tersign.ai/v1/ledger`).
- **Chain commitment recompute** (`verify_commitment`): since 2026-08-28 each
  anchor stamps a chain commitment — an accumulator over every counter-signed
  link — so one anchored digest covers the whole prefix; rows anchored earlier
  bind the head record only and say so (`subjectSchema`).

**The bundled copy is a convenience, not a trust root.** A frozen bundle ships this verify
core inside itself, which is fine for a worked example and wrong for evidence handed to you by
an interested party — a bundle can ship a checker that blesses it. For adversarial input fetch
the checker out-of-band from `https://tersign.ai/verify/v1/` (digests at `SHA256SUMS` beside
it) and diff it against the bundled copy; a difference is itself the finding.

**Check this package against the public corpus yourself.** Since 0.1.4 the sdist carries the
subset of the [two-sided conformance corpus](https://github.com/tersignhq/evidence-record-conformance)
these primitives decide — 19 vectors across canonical bytes, digest recompute, chain link and
chain commitment, both accept and reject arms. `python3 -m unittest discover -s tests` runs
them. A package whose job is letting you check us without trusting us should ship the means to
check the package.

Issuing/signing lives in the TypeScript SDK (npm
[`tersign`](https://www.npmjs.com/package/tersign)); this package is the
independent second implementation of the verification surface —
cross-implementation by construction. Frozen evidence bundles
(`tersign-evidence-bundle-v1`) ship their own copy of this verify core inside
the artifact, so bundle verification never depends on an install.

No console script on purpose: the `tersign` bin name belongs to the npm
package; the Python surface is `python3 -m tersign`.
