Metadata-Version: 2.4
Name: aia-verify
Version: 0.1.1
Summary: Verify an AIA attestation disclosure bundle on your own machine, offline
Author: 013a
License-Expression: Apache-2.0
Project-URL: Homepage, https://013a.tech
Keywords: aia,attestation,audit,verifier,post-quantum,ml-dsa
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: pydantic<3,>=2.13
Requires-Dist: rfc8785<0.2,>=0.1.4
Requires-Dist: cryptography>=42.0.0
Requires-Dist: liboqs-python==0.16.0
Requires-Dist: jsonschema<5,>=4.18
Requires-Dist: referencing<1,>=0.30
Requires-Dist: pypdf<7,>=6.19
Provides-Extra: online
Requires-Dist: web3<9,>=7; extra == "online"
Dynamic: license-file

# aia-verify

Verify an AIA attestation disclosure bundle on your own machine, with no access to the
deployment that made it and no network.

An AIA deployment signs a record of every action its agents take. A **disclosure
bundle** is one record with everything needed to check it: the record, its post-quantum
and classical signatures, the deployment's key history back to its root key, and the
record's place in a sealed batch. [SPECIFICATION.md](SPECIFICATION.md) defines the
format, so you can also check a bundle with code of your own.

## Install

`aia-verify` needs Python 3.10 or newer and the liboqs C library (below). Install it
into a virtual environment from PyPI, or from a wheel you were given:

```bash
python3 -m venv aia-verify && . aia-verify/bin/activate
pip install aia-verify
```

### liboqs

The post-quantum signatures (ML-DSA-87, FIPS 204, on records; SLH-DSA, FIPS 205, on the
key history) are verified by liboqs through `liboqs-python`, which must load the liboqs
release it was made for, 0.16.0. Either route works:

1. **Build liboqs 0.16.0 yourself**, or install your operating system's package of that
   release. A build with only the two mechanisms the verifier uses takes a minute and
   needs git, CMake and a C compiler:

   ```bash
   git clone --depth 1 --branch 0.16.0 https://github.com/open-quantum-safe/liboqs
   cmake -S liboqs -B liboqs/build -DBUILD_SHARED_LIBS=ON -DOQS_BUILD_ONLY_LIB=ON \
     -DOQS_USE_OPENSSL=OFF -DOQS_MINIMAL_BUILD="SIG_ml_dsa_87;SIG_slh_dsa_pure_sha2_256s" \
     -DCMAKE_INSTALL_PREFIX="$HOME/_oqs"
   cmake --build liboqs/build --parallel && cmake --build liboqs/build --target install
   ```

   `liboqs-python` looks in `$HOME/_oqs`, or where `OQS_INSTALL_PATH` points.
2. **Let `liboqs-python` build it.** When it finds no liboqs, its first use downloads the
   matching release and builds all of it into `$HOME/_oqs`. That needs git, CMake, a C
   compiler, network for that one build, and several minutes.

After either route the verifier needs no network.

A key history whose root was created under the round-3 name `SPHINCS+-SHA2-256s-simple`
needs a liboqs release that still has it (0.15 or earlier): see section 4.1 of the
specification.

## Verify a bundle

```bash
aia-verify bundle.json
```

It prints what the record states, one line per check, and the verdict:

```text
  record   01a10823-452d-7451-bdf1-cc53e9e04502  llm_call  2026-10-04T18:18:11.615528Z
  model    example-model:7b  (provider ollama)
  ...
  PASS  bundle-shape       strict parse OK
  PASS  signatures         ML-DSA-87 required + Ed25519 checked
  ...
BUNDLE VALID
```

A failed check is a sentence naming the field that was changed. The exit code is 0 for
a valid bundle, 1 for an invalid one and 2 when the file cannot be read as a bundle.

| Option | What it does |
|---|---|
| `--expected-root FINGERPRINT` | Fail unless the key history ends at this root key, the fingerprint the audited organisation gave you. Without it, the report prints the root for you to compare. |
| `--render report.html` | Also write the record and the verdict as one HTML page. |
| `--language en` or `--language de` | The language of that page, English or German. Without it, your terminal's language (`LANG`) decides, and any other language is English. Each check's own sentence stays in English beneath its explanation. |
| `--document FILE` or `--document FILE=PATH` | For an answer or a search: check a file you hold against the digest each citation of it signed. One changed byte fails those citations; a renamed file still verifies. Give `PATH` when the file name matches several cited documents. Repeatable. |
| `--online [--rpc-url URL]` | Also check the batch root on its public chain. Needs `pip install 'aia-verify[online]'` and network. |

`python -m aia.attest.verify` is the same program.

## Verify an exported answer

```bash
aia-verify answer-<record id>.pdf
```

An answer exported as a PDF carries its signed records and the report its pages print.
The verifier checks that every byte of the file is the one the organisation signed when
it exported it, each embedded record as for a bundle, and that the report is the one the
records render, then prints `ANSWER VALID` or `ANSWER INVALID`. `--document`,
`--expected-root` and `--online` work as for a bundle.

## Verify a comparison

```bash
aia-verify comparison.json --render report.html
```

A comparison of a product's registered dossiers with a site's documents carries the
signed read of every table both sides cite and each person's signed decision. The
verifier checks each record as for a bundle, that the items are the ones compared and
signed, and that each decision shown, reason included, is the one signed for its item,
then prints `COMPARISON VALID` or `COMPARISON INVALID`. One changed byte of a cited table
or one changed word of a decision fails it. Since 0.1.1.

## What a valid bundle proves

The record is unaltered; it was signed by a key the deployment's root key issued and had
not revoked at the record's time; and it sits in the sealed batch whose root the bundle
names. Binding that root key to the organisation is your step: compare the root the
report prints with the fingerprint the organisation communicated, or pass it as
`--expected-root`.

For an answer or a search, the bundle also carries what was asked, the answer and the
passages it was given, each checked against the digests the record signed. A value the
organisation erased since (a person's question, a removed document's text) is reported
withheld: the record still verifies without it.

For an agent's run, the bundle carries every record of the run, the policy each decision
cites with its rules, and the records that registered those policies, the agent's role and
the build's tools in the organisation's chain. Each decision is re-evaluated against its own
policy, so "this step was allowed by this rule" is something you check, not something you
are told.

The bundle's `disclosed_at`, `anchor`, `verification` and informational `policy_context`
snapshot, the batch's `batch_id` and `schema_version`, and the chain's `prev_record_hash`
(of each record it carries) are covered by no check: section 7 of the specification says
why.

## Try it

[`examples/bundle.json`](examples/bundle.json) is a complete bundle signed by keys made
for the example and discarded, so it proves nothing about any deployment;
[`examples/bundle.verified.txt`](examples/bundle.verified.txt) is the output above in
full. Change any byte of a signed field and run it again.

## Source

AIA's release pipeline writes this repository: each release commits the verifier's
code, which is the attestation code an AIA deployment signs with, and tags it. Changes
are not merged here: open an issue, or report a vulnerability privately under the
repository's Security tab.

## Licence

Apache-2.0: [LICENSE](LICENSE) and [NOTICE](NOTICE).
