NokiaTube | New address | Mode Phone | Off high quality for Nokia Browser
Skip to content
unicitynetworkPublic

About

Tamper-evident proofs for any file: prove it existed, unchanged, at a point in time, without revealing it. Certified on the Unicity network, verifiable offline. CLI, TypeScript library and agent skill.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Unicity Proof CLI

Proof-of-existence service on the Unicity network. Tokens are standard Unicity tokens produced with the state transition SDK.

Requirements

  • Node.js 22 or newer. Nothing else: every dependency is plain JavaScript.
  • A Unicity gateway API key for stamping, from https://sphere.unicity.network/. Verifying needs no key.

Installation

npm install -g @unicitylabs/proof-cli
unicity-proof --help

Or run it without installing:

npx @unicitylabs/proof-cli --help

To work from a checkout instead:

git clone https://github.com/unicitynetwork/proof-cli.git
cd proof-cli
npm install         # builds through the prepare script
npm link            # optional: puts `unicity-proof` on your PATH

Configuration

Arguments are loaded, in order of precedence, from: flags > variables in shell memory > .env file in the current directory > hardcoded defaults.

Variable Flag Meaning Default
UNICITY_API_KEY --api-key Gateway API key. Needed by stamp only. none
UNICITY_NETWORK --network mainnet or testnet2. Selects the gateway and the bundled trust base for stamp and stamp-revision; an append must name the network its token is from. verify reads the network from the token; only its --network flag overrides that. mainnet
UNICITY_PRIVATE_KEY --key-file secp256k1 private key, 64 hex characters. When set, stamps are signed. none, stamps are anonymous
UNICITY_GATEWAY_URL --gateway Override the gateway URL only. preset gateway
UNICITY_TRUST_BASE --trust-base Override the bundled trust base file. Not read from an automatically discovered ./.env — see below. bundled file
UNICITY_TIMEOUT --timeout Seconds to wait for the inclusion proof. At most 2147483, the longest delay a Node timer can hold. 60
--out Where stamp writes the token. - writes it to stdout, or, with --json, puts the JSON object there instead. token_<first 16 hex of digest>.cbor in the current directory
--dotenv Load this env file instead of ./.env. ./.env if present

A .env.example is in the repository.

UNICITY_TRUST_BASE is the one exception to the precedence above. It names the root of trust, which decides what every verification means, so it is 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 trust base the sender chose. When that happens the CLI says so on stderr and uses the bundled pin. The flag, an explicit --dotenv, and a real environment variable all work as the table says.

Usage

Stamp

unicity-proof stamp <sha256-hex>              # hash supplied
unicity-proof stamp --file <path>              # hash computed locally
unicity-proof stamp --file document.pdf --out document.cbor
unicity-proof stamp --file document.pdf --network testnet2
unicity-proof stamp --file document.pdf --timeout 120
unicity-proof stamp --file document.pdf --json > stamp.json

A stamp prints a summary and writes the token to --out, by default token_<first 16 hex characters of the digest>.cbor in the current directory. The token file is the receipt; keep it with the document.

Stamped        SHA-256 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Network        mainnet (1) via https://gateway.mainnet.unicity.network
Signer         none (anonymous stamp)
Certified at   2026-10-05T11:42:07Z  (reference time 1791200527)
Round          184233  (round timestamp 1791200531, epoch 1)
Token id       321276fcfb19a925b6e5050d5d5de15c82c56dfe7650cc8d0ae6cf7fc336470d
Written        ./token_2cf24dba5fb0a30e.cbor

The hash is 64 hex characters, upper or lower case, with or without a 0x prefix. --out - writes the raw token bytes to stdout, and the summary to stderr, so the two can be separated. With --out - --json the JSON object goes to stdout instead and the raw bytes are not written: the object already carries the token as hex in token. Existing files are not overwritten unless you pass --force.

The destination is checked before the request goes out, so a mistyped or unwritable --out fails with exit code 2 while nothing has been spent.

If the inclusion proof does not arrive within the timeout, stamp exits with code 3 and nothing is written. The network may still certify the request, but the CLI does not track it: run stamp again, or raise --timeout on a slow connection. A gateway answer of HTTP 429 means the API key's quota is exhausted for now; that is also exit code 3.

Should the write fail anyway — a full disk, or permissions changing underneath — the stamp has already been certified and paid for, so the token is printed to stderr as hex rather than lost. verify and inspect both accept hex, so saving that text recovers the stamp in full; there is no need to stamp again.

Signed stamps

By default a stamp proves only that the hash existed. To also prove that you stamped it, sign with a key:

unicity-proof keygen --out my.key                 # once; mode 0600, 64 hex characters
unicity-proof stamp --file document.pdf --key-file my.key

keygen --out - prints the private key to stdout instead of writing a file, as a bare hex line or, with --json, as the object's privateKey. That field is present on this path only: a key written to a file stays in the file, and the JSON reports its path and public key alone.

keygen writes the key to a new file that is 0600 from creation and puts it in place only when complete, so the key is never visible through a wider file. It never writes through a symlink: without --force a symlink at --out is refused like any existing file, and with --force the link itself is replaced.

Or put UNICITY_PRIVATE_KEY=<64 hex> in .env and every stamp is signed. Two flags control this explicitly:

  • --sign fails with exit code 2 unless a key is configured. Use it in scripts that must never produce an anonymous stamp.
  • --anonymous produces an unsigned stamp even when a key is configured.

The signer's compressed public key is printed on every stamp and verify, as Signer, or none for anonymous stamps. Publish your public key wherever people need to recognise it; the key alone does not say who you are.

Stamp revisions (document lineage)

stamp-revision links successive revisions of a document in one lineage token (design: #13). Each call certifies one revision and either names who may produce the next, or finalizes the document:

# Revision 0: creates doc.lineage, signed by alice, and names bob as the next producer.
unicity-proof stamp-revision --file doc.pdf --token-file doc.lineage --key-file alice.key --recipient-key <bob's public key>
# Revision 1: only bob's key can append; bob names carol (key read from a file holding 66 hex characters).
unicity-proof stamp-revision --file doc.pdf --token-file doc.lineage --key-file bob.key --recipient-key-file carol.pub
# Revision 2: carol finalizes the document; no revision can follow.
unicity-proof stamp-revision --file doc.pdf --token-file doc.lineage --key-file carol.key --finalize
  • Exactly one of <sha256-hex> and --file, and exactly one of --recipient-key, --recipient-key-file and --finalize, is required. --token-file and --key-file are always required; UNICITY_PRIVATE_KEY is not consulted.
  • If --token-file does not exist, a new lineage is minted. Its mint reason is the --key-file holder's signature over the token id, type, recipient and revision, which is what makes the origin "accepted". Because the recipient is signed, the issuer names the producer of revision 1 (or the burn, with --finalize), just as each later revision names its successor: whoever submits the mint cannot substitute another.
  • The token id identifies the lineage, and nothing else does. It is printed when the lineage is created, marked (identifies this lineage; give it to verifiers); pass it on through a channel the verifiers trust, and have them check it with verify --token-id. The issuer key and the first revision's hash are not enough: the same issuer can start any number of certified lineages from the same document, each with its own fork-free history, and verification cannot tell them apart.
  • The salt, and so the token id, is derived from the issuer's private key, the recipient and revision 0, not drawn at random. Running an interrupted genesis again with the same file, key, digest and recipient therefore recovers the same lineage instead of starting a parallel one. Nobody without the issuer's key can compute the token id before the genesis is certified, so nobody can mint into its slot first. Starting a second, separate lineage from the same document needs a different first producer (or issuer).
  • A genesis that was already certified is recovered, never re-created. Whether the earlier run was interrupted, its token file went elsewhere, or a second lineage was meant, the same inputs give the same lineage:
    • The output says Revision 0 (existing lineage, recovered), and a note on stderr, printed even with --quiet, says that this is the existing lineage and how to start a separate one.
    • Before writing, the command asks the aggregator whether revision 1 exists. If it shows a proof that verifies against the trust base, the lineage has moved on: nothing is written, and the command exits 1, naming the token id, when revision 1 was certified and by whom. Get the current token file from whoever holds the lineage.
    • If the aggregator cannot be asked, or shows a proof that does not verify, the file is written with a warning. The check can find later revisions but never rule them out: the aggregator issues no proofs of absence.
  • A new lineage's token file is created exclusively. If a file appears at --token-file while the genesis is being certified, it is left alone and the command exits 2; the genesis is printed as hex, and running the same command with another --token-file recovers it there. A --token-file that is a symlink to a missing file is refused the same way. --force overwrites a file that appeared, or creates the file a symlink points to. It only applies to a new lineage: with an existing token file, --force is a usage error, because the file would be appended to and never replaced.
  • If it exists, it must be a valid lineage token for the selected network whose latest revision names the --key-file key; otherwise the command fails before contacting the gateway (exit 1 for an invalid token, 2 for the wrong key). The revision is a transfer signed with that key under its P_sig predicate; its recipient is P_sig of the next producer. On any write failure the full token is printed as hex.
  • The token file never holds a partial token. It is written to a temporary file next to it, fsynced, and only then put in place (linked for a new lineage, renamed over the old file for an append), and the directory is fsynced after that. A failed or interrupted write leaves the previous file, or for a new lineage no file at all. An append keeps the file's mode, and if --token-file is a symlink, for example into a shared or synced folder, the file it points to is updated and the link is kept. On a filesystem without hard links, a new lineage is created in place instead and removed again if the write fails; only a crash during that write can leave a partial file. If a token file is not a token, the error says how to recover: move it away and run the same command again.
  • --finalize makes this revision the final one, a seal: its auxiliary data is CBOR["seal", i, SHA-256(doc_i)] and its recipient is the burn predicate P_burn(SHA-256(auxiliary data)), which no key can unlock. Appending to a finalized lineage fails before contacting the gateway (exit 2). On a new lineage, --finalize mints revision 0 as a seal: a single-revision document that is final from the start.
  • One append at a time. An append holds a lock file next to the token file, .<name>.lock (after symlinks are resolved), from before it reads any journal until it has written the token file. A second append to the same file meanwhile exits 2 before submitting anything, naming the process that holds the lock. The lock is removed when the run ends, also after an error, a timeout or Ctrl-C; only a run that is killed outright, or a power loss, leaves it behind. It holds no data, so when no run is active it is always safe to delete. An append also exits 2, before submitting, if the token file changed between being read and being locked: run it again on the current file.
  • Another stamp-revision run never rolls the token file back. The lock makes sure of that between runs. On top of it, an append replaces the token file only if it still holds what the run started from, so a program that ignores the lock is caught too, unless it writes in the instant between that check and the replace: there is no atomic compare-and-replace. If the file changed, it is left as it is. When it already holds this run's revision (the same lineage, verified, and the same transfer), nothing is lost: the run says so on stderr and completes. Otherwise the run prints its token as hex, keeps its journal, and exits 2.
  • Interrupted appends are recovered from a journal. Before an append is submitted, the revision is recorded in a journal next to the token file, .<name>.<tag>.pending, where the tag is the first 16 hex digits of the transfer's SHA-256 (for example .doc.lineage.3f2a9c0e1b7d4a65.pending), and echoed to stderr; --quiet leaves the echo out once the journal is written. A journal is removed only once its outcome is known: when the token file holds its revision, or when a proof that verifies shows its revision's slot holds another transfer. The aggregator keeps only a hash of each transfer, so until then the journal is the only record of what was certified; do not delete it by hand.
    • If the command is interrupted after submitting, running stamp-revision again on the same token file recovers the revision from the journal, whatever it is given this time. If the digest and recipient are the same, that completes the command. If not, the recovered revision is still written and echoed to stderr, the requested one is not appended, and the command exits 1.
    • Without the journal, the same command with the same file, key, digest and recipient still recovers the revision, because the state mask of each step is derived from the producer's key and the spent state. With any other digest or recipient it exits 1, saying the revision was already certified with different content, and echoes what it tried to stderr even with --quiet. Only the interrupted run's digest and recipient can recover it then, which is what the echo is for.
    • A revision that an earlier run submitted but that is not certified yet may still be: the aggregator can certify a request that was waiting for its round. Its journal is kept, and listed on stderr even with --quiet, and this run's revision is journaled beside it. Whichever is certified is written to the token file, and the other journals for that revision are then removed. A run that is interrupted again leaves every journal in place for the next one.
    • Two runs that journal the same transfer share its journal. A journal with the same name and other content stops the command with exit 2, and nothing is removed that the command did not create.
    • A journal the command cannot place (for another lineage, for a later revision than the token file holds, or unreadable) stops it with exit 2 and is left alone.
    • A new lineage needs no journal: its genesis is derived from its inputs, and running it again with the same file, key, digest and recipient recovers it (see above).
  • In --json output, recovered is true when an earlier run had already certified the revision and this run only recovered it; the text output marks such a revision (recovered).
  • Network options behave as for stamp, so a testnet2 lineage needs --network testnet2 (or UNICITY_NETWORK=testnet2) on every append, not just at creation. The network is not taken from the token, because it also decides which gateway the API key is sent to. An append whose token file is from another network than the one configured stops with exit 2 before anything is submitted, and the message says what to change.

verify and inspect recognise lineage tokens by their token type and list every revision with its hash, signer, next producer and certification time:

unicity-proof verify doc.lineage                                   # is this a valid lineage?
unicity-proof verify doc.lineage --token-id <id from the issuer>   # ...and the one I was given?
unicity-proof verify doc.lineage --token-id <id> --file doc.pdf    # ...and which revision is this file?
Status         OK  (inclusion proofs, consensus signatures, issuer signature and revision chain verified against the bundled testnet2 trust base)
Trust base     bundled testnet2 pin
Expected hash  matches revision 1; superseded by revision 2
Lineage id     matches
Token type     document lineage
Network        testnet2 (4)
Token id       5394db437e25b271272701e70e3f211ab4be2449fbe5b5d33664afa630b92357
Issuer         031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f
Revisions      3
Next producer  034bf90f6fb27ac089cd5649adf2cf28c8d9711c66e5191cbceef04a2b7c85a368

Revision 0     SHA-256 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
  Signed by    031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f
  Passes to    034bf90f6fb27ac089cd5649adf2cf28c8d9711c66e5191cbceef04a2b7c85a368
  Certified at 2026-11-05T11:45:48Z  (reference time 1793879148)
  Round        184233  (round timestamp 1793879149, epoch 1)
…

With --token-id, the lineage passes only if its token id is that one; Lineage id says whether it matched, or that it was not checked, in which case nothing has established which lineage this is. A different id is a failure, reported before any hash mismatch. --token-id is refused for tokens that are not lineages. With --file or --hash, the lineage passes if any revision carries that digest; Expected hash says which one, and whether a later revision supersedes it. A match on the last revision is marked (the final) when that revision is a seal, and (the latest in this file) otherwise. Only a seal (--finalize) proves that no later revision exists: every earlier state of a lineage is itself a valid token, so an unsealed file can be missing revisions certified since, whether through an old copy or trailing revisions dropped, and verification, being offline, cannot tell. A digest no revision carries is a failure. Signed by on revision 0 is the issuer from the genesis reason; on later revisions it is the key the previous revision passed to, which the transfer's signature was checked against. Next producer is who may append the next revision, or none; the lineage is finalized after a seal, which is marked (final). In --json output a lineage has "tokenType": "lineage", finalized, a revisions array (each with sealed), expectedTokenIdMatches (null when no --token-id was given) and matchingRevisions (positions of the matching revisions, or null when no hash was given) in place of the timestamp fields.

Format: token type SHA-256("unicity-document-lineage"); auxiliary data CBOR[i, SHA-256(doc_i)] on the genesis (i = 0) and on each transfer, or CBOR["seal", i, SHA-256(doc_i)] on the final revision, whose recipient is then the burn predicate with reason SHA-256(auxiliary data); genesis reason CBOR tag 39200 over [1, issuer public key, signature], the signature covering SHA-256(CBOR["unicity-document-lineage", 1, token id, token type, recipient, auxiliary data]), where recipient is the mint's recipient predicate in its tagged CBOR encoding (tag 39032). Verification additionally requires the indices to increase by one, the reference times not to decrease along the chain, and a revision to be burned exactly when it is a seal, with the burn reason as above.

Verify

unicity-proof verify document.cbor                      # is this a valid Unicity timestamp?
unicity-proof verify document.cbor --file document.pdf  # ...and is it for this file?
unicity-proof verify document.cbor --hash 2cf24dba…9824 # ...or for this digest?
cat document.cbor | unicity-proof verify -              # from stdin; binary or hex
Status         OK  (inclusion proof, consensus signatures and payload verified against the bundled mainnet trust base)
Network        mainnet (1)
Trust base     bundled mainnet pin
Hash           SHA-256 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Expected hash  matches
Signer         031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f
Certified at   2026-10-05T11:42:07Z  (reference time 1791200527)
Round          184233  (round timestamp 1791200531, epoch 1)
Token id       321276fcfb19a925b6e5050d5d5de15c82c56dfe7650cc8d0ae6cf7fc336470d

Verification is offline. The CLI picks the trust base that matches the token's network, so a testnet2 token verifies without flags. The first line is the verdict: Status OK with exit code 0, or Status FAIL: <reason> with exit code 1. Without --file or --hash the token is checked for validity only; the Expected hash line reminds you that it was not tied to a document.

The Trust base line says which root of trust produced that verdict — bundled <network> pin, or the path of an override. It is worth reading: a verdict is only as good as the trust base behind it, and OK against someone else's trust base means nothing. For that reason the root of trust is never taken from a .env file found in the working directory; pass --trust-base to choose one deliberately.

Inspect

unicity-proof inspect document.cbor

Prints the same fields as verify without checking anything, under an UNVERIFIED banner. Useful for looking at tokens from other networks or other token types. A lineage token is shown revision by revision, as by verify.

Scripting

Every command accepts --json and prints one JSON object on stdout; everything else goes to stderr. Large integers are decimal strings. referenceTimeIso is null when the token carries a reference time no date can represent; referenceTime always holds the raw value.

unicity-proof verify document.cbor --file document.pdf --json | jq -r .referenceTimeIso
Exit code Meaning
0 Success. For verify: valid, and the hash (and, for a lineage, the token id) matched if one was given.
1 Verification failed, hash or token id mismatch, or the input is not a token. For stamp-revision: the revision was already certified with different content, or a recovered genesis's lineage has moved on.
2 Usage or configuration error.
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:

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

unicity-proof stamp --file document.pdf --network testnet2 --api-key sk_ddc3cfcc001e4a28ac3fad7407f99590
unicity-proof stamp --file document.pdf --gateway https://gateway.example --trust-base ./bft-trustbase.json
unicity-proof stamp --file document.pdf --gateway http://localhost:3000 --allow-insecure   # local aggregator only

The testnet2 key above is the shared public demo key published in the sphere-sdk README, where it is documented as public rather than secret; capacity is shared, so get your own key for sustained use. Trust bases for mainnet and testnet2 ship inside the package. The CLI never downloads a trust base at run time.

Library

The package is importable as well as runnable. Verification has its own entry point that cannot reach a gateway: no aggregator client, no JSON-RPC transport, and no node: import anywhere in its module graph — 80 modules against the 137 behind the package root, and nothing that can open a socket or read a file, which is what a browser bundle needs.

import { readFile } from 'node:fs/promises';

import { Token } from '@unicitylabs/state-transition-sdk/lib/transaction/Token.js';
import { bundledTrustBase, networkNameForId, verify } from '@unicitylabs/proof-cli/verify';

const token = await Token.fromCBOR(new Uint8Array(await readFile('document.cbor')));
const network = networkNameForId(token.networkId.id);
if (network === undefined) {
  throw new Error(`No bundled trust base for network ${token.networkId.id}.`);
}

// digest is the document's own SHA-256. Without it the result says only that
// some hash was certified, not that it was yours.
const result = await verify(token, bundledTrustBase(network), { expectedDigest: digest });
console.log(result.status, result.reason, result.referenceTime);

Stamping needs a gateway and an API key, so it lives at the package root, which re-exports everything above:

import { resolveNetwork, stamp } from '@unicitylabs/proof-cli';

const token = await stamp(digest, resolveNetwork({ network: 'testnet2' }), process.env.UNICITY_API_KEY);

Those two entry points are the whole public API; Node refuses deep imports into the implementation. Anything they do not export is internal and may change in any release. tests/unit/PublicApiTest.ts pins both export lists, and fails if a module in this package starts importing from node: or if the verification entry point gains a path to the aggregator.

What a stamp proves

A verified token shows that a transaction containing your hash was certified by the Unicity Network in a specific round, and records the round's reference time, which is at or before the consensus-signed round timestamp. If the stamp is signed, it also shows that the holder of the printed key signed the hash, and that this signature existed no later than the certified time.

It does not prove when the aggregator received the request. The proof authenticates the time the aggregator recorded; the guarantee that this time is honest rests on the network's consensus layer, the same way a classic timestamp authority's receipt rests on the authority. The protocol specification states this explicitly.

Development

npm ci
npm run build
npm test            # builds, then runs the unit suite and the end-to-end suites
npm run lint

There are two test layers. Unit tests exercise the library and the CLI logic offline, using the SDK's in-memory aggregator for genuine certified transactions. End-to-end tests run the built binary: an offline suite that always runs, and a network suite that stamps on a real network and skips itself unless a test key is configured:

# .env (gitignored) or the shell. Deliberately not UNICITY_API_KEY, so tests never spend the production key.
UNICITY_TEST_API_KEY=sk_your_test_key
UNICITY_TEST_NETWORK=testnet2            # or mainnet

npm run test:e2e                                   # network suite runs when the key is set
UNICITY_E2E_WRITE_FIXTURES=1 npm run test:e2e      # also refreshes tests/fixtures/<network>-*.cbor

CI has no key, so the network suite is skipped there. A free testnet2 key comes from https://sphere.unicity.network/ or from the gateway's wallet-auth endpoints, POST /auth/challenge and POST /auth/verify, documented in the aggregator-subscription repository. Note that the mainnet free plan currently allows no requests at all, so mainnet stamping needs a paid key.

Design decisions

  • Stamps are not transferable, and nobody owns them. The token's recipient predicate is the SDK's burn predicate, which no key can ever unlock. A timestamp is an attestation, not an asset; moving it would prove nothing and would only invite wallets to treat it as something owned. Wallets never see these tokens anyway: Unicity has no token discovery, and a burn-locked token fails every wallet's ownership check.
  • Identity is carried in the stamp, not in ownership. The payload holds the signer's public key and a signature over the hash. stamp adds them when a key is configured (--key-file or UNICITY_PRIVATE_KEY); --sign insists on it and --anonymous suppresses it. The mint itself is signed by the SDK's universal mint key, so a recipient key alone would prove nothing; the payload signature is what turns "a token exists" into "this key attested this hash".
  • Anonymous by default. Every established timestamping service, from RFC 3161 authorities to OpenTimestamps, takes a bare hash. Identity, when wanted, is added by signing first and timestamping the signature. This tool does the same.
  • One fixed token type, one payload format. All timestamps share a token type and a four-element CBOR payload: version, 32-byte digest, optional signer, optional signature. A dedicated issuance verifier checks the payload during the SDK's own token verification, and the verifier registry stays fail-closed.
  • Verification is offline against pinned trust bases. Trust bases for mainnet and testnet2 ship inside the package and are refreshed by a reviewed script. Fetching the root of trust from the network being verified would defeat the purpose.
  • stamp is stateless. If the proof does not arrive in time, run it again. An abandoned request costs one API call and nothing else. A resume feature was considered and rejected as not worth a stateful CLI.
  • The time reported is the round's reference time. It is bound into the certified leaf and checked by the SDK against the consensus-signed round timestamp. Both are printed.
  • Thin wrapper, minimal footprint. Node 22, the SDK and commander. No native modules, no dotenv, no runtime downloads. The tool lives in its own repository and depends on the published SDK, exactly as users do.

Appendix

Token file format

A token file is the raw CBOR of the SDK's Token.toCBOR(), with no wrapper around it. It is the same encoding Sphere wallets use on the wire, so any SDK-based tool reads it with Token.fromCBOR(). Outermost first:

tag 39040 [ version = 2, genesis, transfers ]
  transfers = []                                 always empty: the token is burn-locked
  genesis   = [ mintTransaction, inclusionProof ]

  mintTransaction = tag 39041 [ version = 2, networkId, recipient, salt, tokenType, justification, data, expiresAt ]
    networkId       1 for mainnet, 4 for testnet2
    recipient       tag 39032 [ engine = 1, code = bstr(02), reason = bstr("unicity-timestamp") ]   burn predicate
    salt            bstr(32), random; the token id is SHA-256(CBOR[salt, networkId])
    tokenType       bstr(32) = SHA-256("unicity-timestamp") = dd671898…1ee16193
    justification   null
    data            bstr holding the timestamp payload, see below
    expiresAt       null, the deadline is assigned by the service

  inclusionProof = tag 39033 [ version = 1, certificationData, referenceTime, inclusionCertificate, unicityCertificate ]
    referenceTime   Unix seconds; the certified time, printed as "Certified at"
    inclusionCertificate         sparse Merkle tree path proving the leaf under the certified root
    unicityCertificate           consensus certificate; its inputRecord.timestamp is the round timestamp,
                                 always >= referenceTime, and its seal carries the validator quorum signatures

The timestamp payload, the bytes inside data:

[ version = 1,     uint
  digest,          bstr(32)   the SHA-256 digest that was stamped
  signer,          bstr(33)   compressed secp256k1 public key, or null
  signature ]      bstr(65)   recoverable secp256k1 signature r‖s‖recovery, or null
  • signer and signature are both present or both null. Both null is an anonymous stamp.
  • The signature covers SHA-256(CBOR["unicity-timestamp", 1, digest]), not the bare digest, so it cannot be mistaken for a signature over the digest in another protocol.
  • An anonymous payload for digest 2cf24dba…938b9824 is 38 bytes: 84 01 5820 <32 digest bytes> f6 f6.

Verification runs the SDK's checks on the genesis: transaction hash and certification data match the proof, referenceTime does not exceed the round timestamp, the Merkle path leads to the certified root, the shard matches, the unicity certificate's quorum signatures verify against the pinned trust base, and the mint unlock script is valid. On top of that the CLI's issuance policy requires the burn recipient, no justification, a payload that decodes, which includes a valid signer key, and a verifying signature.

Deferred decisions

These are recorded here so they are not forgotten; none blocks using the tool.

  1. Token type registration. The timestamp token type is fixed and deterministic:

    TIMESTAMP_TOKEN_TYPE = SHA-256("unicity-timestamp")
                         = dd671898ac55e0a3a9e22f07120cef94943d25fdf1dd0485aab077b21ee16193
    

    Reproduce it with printf 'unicity-timestamp' | shasum -a 256. Registering this id in the unicity-ids token registry, so wallets and explorers can label it, is deferred until the format has settled. The id itself does not change when that happens; the payload carries its own version number.

About

Tamper-evident proofs for any file: prove it existed, unchanged, at a point in time, without revealing it. Certified on the Unicity network, verifiable offline. CLI, TypeScript library and agent skill.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages