Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@ unicity-proof verify document.cbor --file document.pdf --json | jq -r .reference
| 3 | Network error, aggregator rejection, or timeout. |
| 130 | Interrupted. |

### Agents

An agent skill ships in the package at `skills/unicity-proof/SKILL.md`. It is a
short briefing on the traps that matter — binding a proof to a document, what a
timeout does and does not mean, and why a verdict depends on its trust base.
Copy it where your agent looks for skills, for example:

```bash
mkdir -p .claude/skills/unicity-proof
cp "$(npm root -g)/@unicitylabs/proof-cli/skills/unicity-proof/SKILL.md" .claude/skills/unicity-proof/
```

There is no MCP server, and none is planned while the CLI is the better
interface: a tool schema costs thousands of context tokens before any work
happens, where the skill costs a few hundred and is read only when relevant.

### Testnet and custom gateways

```bash
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"files": [
"lib/**/*",
"skills/**/*",
"LICENSE",
"README.md"
],
Expand Down
83 changes: 83 additions & 0 deletions skills/unicity-proof/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
name: unicity-proof
description: Use when stamping a file or digest to prove it existed at a point in time, when verifying or checking an existing proof or .cbor timestamp token, or when generating a signing key for stamps. Covers the hash-binding, exit-code and trust-base traps in the unicity-proof CLI.
---

# Unicity Proof CLI

Stamps a SHA-256 digest into a Unicity token, proving the digest existed at a
certified time. Verification is fully offline. Stamping needs `UNICITY_API_KEY`;
`verify` and `inspect` need nothing.

## Verifying: the mistake that matters

`unicity-proof verify token.cbor` proves the token is a valid timestamp. It does
**not** prove it is a timestamp *of your document*. Whenever you hold the
document, bind the two:

```bash
unicity-proof verify token.cbor --file document.pdf # or --hash <64 hex>
```

Then read `Expected hash matches`. Without `--file` or `--hash` that line tells
you the proof was never tied to anything — a bare `Status OK` on its own
establishes nothing about the file in front of you.

Also read the `Trust base` line. A verdict is only as good as the root of trust
behind it, and `OK` against someone else's trust base means nothing.

## Stamping

The token file **is** the receipt. Default name is
`token_<first 16 hex of the digest>.cbor`; keep it with the document, because
without it the proof is gone.

- **Exit 3 usually cannot tell you whether anything was certified.** `stamp`
submits the request before it waits for the inclusion proof, so a timeout, a
dropped connection or an HTTP error can all arrive after the network already
accepted it — and the CLI does not track the request, so it cannot say.
Assume it may have been certified: re-running spends quota again and can
produce a second token over the same digest. The one unambiguous message is
`Aggregator rejected the certification request`, where the aggregator refused
outright and nothing was certified. Always fix
`Gateway refused the API key` before retrying at all.
- **A failed write after certification is recoverable.** The token is printed to
stderr as hex, and both `verify` and `inspect` accept hex, so save that text.
Do not re-stamp.
- `--sign` exits 2 unless a key is configured. Use it in any automated path that
must never silently produce an anonymous stamp. `--anonymous` forces the
opposite.

## Stamp before the outcome is known

A stamp is evidence only if it was made before the thing it commits to could be
known. Stamp first and reveal later; stamping after the fact proves nothing
about foresight.

## Exit codes

| Code | Meaning |
| --- | --- |
| `0` | Success. For `verify`: valid, and the hash matched if one was given. |
| `1` | Verification failed, hash mismatch, or the input is not a token. |
| `2` | Usage or configuration error. |
| `3` | Network error, aggregator rejection, or timeout. |
| `130` | Interrupted. |

## Machine-readable output

`--json` prints one JSON object on stdout; everything else goes to stderr. Large
integers are decimal strings.

`--out -` writes raw token bytes to stdout with the summary on stderr. With
`--out - --json` the object goes to stdout instead and carries the token as hex
in its `token` field.

## Trust bases

`UNICITY_TRUST_BASE` is deliberately ignored when it comes from a `./.env` that
was merely found in the working directory: a token shipped next to a `.env`
would otherwise verify against whatever root of trust the sender chose. Pass
`--trust-base` explicitly to select one.

Full flag and configuration reference: the project README.
34 changes: 34 additions & 0 deletions tests/unit/SkillTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { readFile } from 'node:fs/promises';
import path from 'node:path';

import { EXIT_INTERRUPTED, EXIT_NETWORK, EXIT_OK, EXIT_USAGE, EXIT_VERIFICATION_FAILED } from '../../src/errors.js';

const SKILL = path.resolve('skills/unicity-proof/SKILL.md');

describe('agent skill', () => {
it('documents exactly the exit codes the CLI returns', async () => {
const skill = await readFile(SKILL, 'utf8');
const documented = [...skill.matchAll(/^\| `(\d+)` \|/gm)].map((match) => Number(match[1]));
expect(documented).toEqual([EXIT_OK, EXIT_VERIFICATION_FAILED, EXIT_USAGE, EXIT_NETWORK, EXIT_INTERRUPTED]);
});

it('quotes gateway messages the CLI can actually print', async () => {
const skill = await readFile(SKILL, 'utf8');
const sources = `${await readFile(path.resolve('src/errors.ts'), 'utf8')}${await readFile(
path.resolve('src/lib/errors.ts'),
'utf8',
)}`;
const quoted = [...skill.matchAll(/`(Could not reach|Gateway |Aggregator )([^`]*)`/g)].map((match) =>
`${match[1]}${match[2]}`.replace(/ \.\.\.$/, ''),
);
expect(quoted.length).toBeGreaterThan(0);
for (const message of quoted) {
expect(sources).toContain(message);
}
});

it('ships inside the package', async () => {
const manifest = JSON.parse(await readFile(path.resolve('package.json'), 'utf8')) as { files: string[] };
expect(manifest.files).toContain('skills/**/*');
});
});
Loading