Skip to content

Document provenance: linking versions, and what each property actually costs #13

Done

Description

@MastaP

The problem

stamp certifies one digest. Stamp a document's v1, edit it, stamp v2 — the two tokens are unrelated. Nothing shows that v2 succeeded v1, that no version in between was withheld, that this is the last version, or that the author did not keep a divergent branch and reveal whichever suits. Verification must stay offline against a bundled trust base.

Provenance decomposes into six properties, and they have very different costs:

Property
a Linkage — v2 is the successor of v1
b Order — the sequence is not a permutation
c1 Interior completeness — no version hidden between two shown
c2 Tip completeness — the version shown as last really is last
d Non-forking — no divergent branch exists
e Document identity — these are versions of this document
f Authorship — who made each change

The mechanism: deterministic salts

A mint's SMT leaf address is fully determined by (networkId, salt). Every input is derived:

  • TokenId.fromSalt(networkId, salt) — src/transaction/TokenId.ts
  • MintSigningService.create(tokenId) gives the lock script, from a key its own docstring calls "reproducible by anyone holding the same token id" — src/crypto/MintSigningService.ts
  • MintTransactionState.create(tokenId) = H(CBOR[tokenId, MINT_SUFFIX]) — src/transaction/MintTransactionState.ts
  • StateId = H(lockScript, sourceStateHash) — src/api/StateId.ts

So two mints sharing a salt on one network collide on one leaf: LeafExistsError in the SDK, STATE_ID_EXISTS from the aggregator.

Today MintTransaction.create defaults to salt = TokenSalt.generate(). That randomness, not the burn predicate, is what makes stamps unlinkable. Replace it with salt_n = HKDF(lineageSecret, lineageId, n) and slot n of a lineage admits at most one certified stamp, ever.

That yields (a), (b), (c1) and (d) from independent stamps — no spendable predicate, no key custody, no chained state, no history file. Stamps stay burn-locked and anonymous toward the service.

Non-forking is a trust assumption, not a proof

Worth stating plainly, because it is easy to oversell. The offline verifier checks that a leaf sits under a quorum-signed root. No rule checks that no other value for that key was ever certified, and none can:

  • ExclusionCert.Verify returns ErrExclusionNotImpl — aggregator-go/pkg/api/inclusion_cert.go:232
  • the non-inclusion path returns an empty payload: "Non-inclusion is not implemented yet" — aggregator-go/internal/service/service.go:404
  • GetNoDeletionProof returns the literal placeholder mock_no_deletion_proof — aggregator-go/internal/service/service.go:480

So "no fork" means "the certified SMT is append-only with one value per key" — an invariant of the aggregator, the same trust already extended to the reference time. A lone verifier can never detect a fork; two conflicting tokens together are the evidence. This also means querying whether a state is unspent returns an unproven null, so tip completeness cannot be established by asking the network either.

Tip completeness needs a seal

Nothing else closes (c2). A valid token truncated to a prefix is still a valid token, and the author can show v1..v5 while v6 is certified.

The two designs differ in how strong a seal they can offer:

  • Slot stamps: a seal is a certified, signed statement at slot n+1 that the lineage ends. Slots are independent, so nothing physically prevents a later slot — but the author would then hold a stamp contradicting their own certified seal. Accountability, not impossibility.
  • Document token: the final transfer goes to Burn("sealed"). A burned state has no registered verifier, so a successor is impossible. Ledger-enforced.

Chronological order is not enforced

TokenVerifier verifies each transfer independently and never compares neighbours. The only time checks are against expiresAt and the transfer's own round timestamp. The aggregator's validator checks StateId and authorization, not the predecessor's proof, so states can be precomputed and certified out of order: a later link can carry an earlier reference time.

Either design must therefore verify that reference times increase along the lineage. This is a verification rule we have to add, not a property we inherit.

Design A — slot stamps

Keep the current token shape, burn recipient and anonymity. Payload carries lineageId, position n and prevDigest.

  • For: no key custody, no state file, stateless and offline verification, anonymous toward the service, each stamp independently useful, closest to what the CLI already is.
  • Against: the lineage secret must reach every verifier, so any verifier can squat a future slot. That is denial of service rather than forgery, provided payloads are identity-signed — but it rules this out for public documents.

Design B — document token

Genesis to a per-document spend key; one transfer per version carrying the version payload in data; final transfer to Burn("sealed").

  • For: no squatting, and a hard seal.
  • Against:
    • Key loss freezes the lineage, indistinguishable from "the author stopped", and you cannot seal without the key.
    • Key theft lets a thief append or seal; there is no revocation and first certified spend wins. Separate the per-document spend key from the identity key that signs payloads, so theft is a DoS rather than a forgery.
    • Anonymity: the spend key appears in every certification request, so a reused key relinks every version for the service. Rotate per version or accept the linkage.
    • The token file is the only copy. The service stores txHash, not transaction bodies, so a lost file is unrecoverable from the network. A crash between certify and write leaves a stale state and the next revision is rejected; use deterministic masks for crash replay, as the split flow does.
    • Concurrency fails confusingly. Losers get STATE_ID_EXISTS, which is absent from the SDK's CertificationResponse enum, so proof-cli warns "unknown status" and then throws TRANSACTION_HASH_MISMATCH inside waitInclusionProof. There is no multisig predicate.
    • Size: roughly 1.8 KB per certified step with no pruning; 10k versions is about 18 MB, verified sequentially.

Scope either way

  • A new token type. Changing the recipient alone is not enough: the verification context is fail-closed to one type (src/lib/verification.ts) and verify rejects any token with transfers (src/lib/TimestampClient.ts).
  • A second issuance verifier and its own payload layout.
  • Commands: init, revise, seal, history.
  • A verification rule for monotone reference times.
  • Separate spend and identity keys.

What neither design can manufacture

  • Document identity (e). Nothing in-band binds a lineage to a real document. A deterministic token id derived from a public document name is squattable by anyone, because the minter key is universal. This needs a published binding — see Agent identity: offline-verifiable signers via nametag tokens, not an on-chain registry #10.
  • Completeness of work. No oracle can show that an author recorded every edit they made. Provenance of committed versions is not provenance of all work.

Defensible claim

This is the certified succession of versions for this pinned lineage, through this stated endpoint, each certified at the stated time.

Not "every version", and not "the latest version" unless sealed.

Open question

Design A is cleverer and fits the CLI's character; Design B is the one to pick if squatting by verifiers is unacceptable, which it is for any public document. The choice turns on whether lineages are private artifacts shared with chosen verifiers, or public records.

Activity

  1. moved this to Todo in Unicityon Oct 17, 2026
  2. ristik commented on Oct 22, 2026

    @ristik
    Member

    What can be done MORE given we have uniqueness proofs:

    • a unique state timestamp ("proof") guaranteeing that there can be only one 'proofed' future version of a document. Or forking to exactly n modified copies for parallel workflows, etc.

    Assumption: initial version is known to verifiers, so they can track entire provenance chain from genesis to final version checking there are no forks, based on known final version.

    Example: if there is a document management workflow requiring sequential approvals, and so that there can not be alternative shadow approved docs;

    Example 2: supply chain, initial version certified by manufacturer, each step adds a transaction to digital twin token, and unlike plain signatures (plus timestamps) there can be no forks in supply chain.

    How: document is part of token state, the state can be transacted only once (by mutating to new state which covers the next version of the tracked artifact). Specifically doc hash goes into 'auxiliary data' field. Split applies as well, so we can trace how many copies was created.

    So the semantics can be:

    Given this accepted origin, this document follows an authorized history whose continuations cannot conflict, except through explicitly authorized branches.

  3. ristik commented on Oct 27, 2026

    @ristik
    Member

    Sketch: document lineage token (fields per the Yellowpaper)

    This makes the idea from my earlier comment more concrete. Section names refer to the Unicity Yellowpaper (execution layer and token appendix).

    Token type. A new constant ty = DOC_LINEAGE. Its type-specific verifier checks reason and auxData as described below.

    Genesis (mint), D_mint = (α, recipient, salt, ty, reason, auxData):

    • auxData = CBOR[0, H(doc_0), meta?]: version index and digest of the initial document. The document itself is not stored.
    • reason: the issuer's signature over (id, ty, auxData), e.g. by the manufacturer or document owner. The mint key is public, so this signature is what makes an origin "accepted". Verifiers pin the origin by id = H(salt, α) or by the issuer key together with H(doc_0).
    • salt: random. id stays unpredictable until genesis is certified, so the token id is published only after the mint.
    • recipient: predicate of whoever may produce the next version. For sequential approval this is the next approver (P_sig/P_p2pkh), or a k-of-n P_tsig for a committee.

    Version step (transfer), D = (recipient, x, auxData):

    • auxData = CBOR[i, H(doc_i)]. No prevDigest is needed, because linkage comes from the state hash chain h_i = H(h_{i-1}, x_i).
    • Who signs. Step i is signed by party i, not by a shared document key. The unlocking argument u is a signature over H(h, txhash) under the predicate that step i-1 placed in recipient. Party i-1 therefore chooses and authenticates its successor, and only the holder of that key can produce version i. The chain of predicates is a chain of custody: verifiers learn who made each change (f), and that each party was named by the previous one.
    • recipient: the key of the next editor or approver, which must be known to the current party. If verifiers are to check identities and not only key continuity, the key must be bound to a party, either as a known identity key or as a per-step key certified by one out of band. A fresh unlinked P2PKH key per step reduces linkability toward the service, but only parties who know the binding can attribute it.
    • x: state mask, chosen by party i. It can be derived as PRF(k_i, i) from that party's secret so that a crash between certification and writing the file can be replayed.

    Seal (terminal burn). Transfer to P_burn(H(b_seal)) with auxData = b_seal = CBOR[SEAL, i, H(doc_final)]. The burn predicate cannot be unlocked, so no successor can exist.

    Tip without a seal. A non-inclusion proof for sid_n = H(P_n, h_n) at a recent round shows that version n had no certified successor as of that round's reference time.

    Authorized branching (n copies). This follows the split construction without the RSMST sums. Split itself is defined for fungible tokens only, so this is a type-specific analogue:

    • Fix child salts and fields beforehand, and compute d_j = H(BRANCH_OUTPUT, id_src, α, recipient_j, salt_j, id_j, ty, auxData_j) with the same field set as split's d_j.
    • Burn the parent to P_burn(H(b_M)) with auxData = b_M = CBOR[BRANCH, [d_1..d_n]].
    • Each child mint carries the certified burned parent in reason. The verifier recomputes d_j and requires it to be in b_M. Each child id can be minted only once, so there are at most n certified branches, each tied to that parent.

    Verification of a final token against a known origin. Run VerifyToken. Then check the type rules: the genesis reason signature, auxData format, i incrementing by one, and the reference time τ_i non-decreasing along the chain (as noted in the issue, this is not implied by the protocol). Finally, check either a seal or branch manifest at the end, or a fresh non-inclusion proof for the tip. Uniqueness of each sid is enforced by BFT Core through the consistency proof of every round, so two conflicting successors of one state cannot both be certified.

    Claim: given this accepted origin, this document follows an authorized history, each step signed by the party the previous step named, whose continuations cannot conflict, except through explicitly authorized branches; it ends in a seal, or was the unspent tip as of round r.

    Relation to Design B

    This is Design B with these refinements:

    • Signers. Design B has a single per-document spend key that signs every version, so the lineage has one controller (or everyone shares that key), and the ledger cannot show who made each step. Here each step is signed by a different party, named by the previous step. The separate identity key that Design B adds for payload signatures is not needed, because the spend key of each step is the authenticated key of that step's author.
    • Key loss and theft affect only the current step's holder, not the whole lineage. P_tsig with k-of-n keys mitigates both for a step that a committee controls.
    • Seal. Same seal, but the burn reason hash commits to the final digest instead of a fixed "sealed" string.
    • Tip. Non-inclusion proofs establish the tip as of a given time, so a seal is not the only way to close (c2).
    • Branching. Added through the burn manifest. The body treats every fork as a failure.
    • Unchanged from the body. The token file is still the only copy of the history, and SDK handling of STATE_ID_EXISTS is still an open issue. Non-forking and tip proofs depend on aggregator-go implementing the consistency and non-inclusion proofs as specified. The current stubs are an implementation gap, not a limit of the protocol.
  4. moved this from Todo to In Dev in Unicityon Nov 5, 2026
  5. MastaP commented on Nov 5, 2026

    @MastaP
    MemberAuthor

    Two points on the sketch that came up while reviewing #16, which implements it faithfully:

    The issuer signature should cover the genesis recipient. As sketched, reason signs (id, ty, auxData), so the issuer endorses the origin document but not who produces revision 1. The chain "each step signed by the party the previous step named" therefore starts with a link the issuer never named. In any delegated mint (the issuer signs, someone else submits), the minter picks the first producer freely, and verification still reports the issuer signature as valid. Adding the encoded recipient predicate to the signed message closes this. It changes the signed format, so it's free now and a breaking change once lineages exist.

    Pinning by issuer key + H(doc_0) isn't unique. The salt is random, so an issuer can mint any number of geneses for the same doc_0, each certified and each with its own fork-free continuation. This can happen innocently too: re-running an interrupted genesis mints a second one. A verifier who pins by issuer and first digest will accept a parallel lineage, which is exactly the shadow approved document the first example is meant to exclude. Only id identifies a single lineage, so verifiers have to get it through a trusted channel at genesis. The "or" in "verifiers pin the origin by id … or by the issuer key together with H(doc_0)" should go.

  6. ahtotruu commented on Nov 10, 2026

    @ahtotruu
    Contributor

    Two points on the sketch that came up while reviewing #16

    Thanks, both points are addressed on the revision-history branch (#16).

    1. The issuer signature now covers the genesis recipient (556402d)

    The genesis reason now signs

    SHA-256(CBOR["unicity-document-lineage", 1, id, ty, recipient, auxData])
    

    where recipient is the mint's recipient predicate in its own tagged CBOR encoding (tag 39032), byte for byte as the mint carries it. The verifier takes the recipient from the mint transaction, so the reason's format (tag 39200 [1, issuer, signature]) is unchanged.

    • Delegated mint: if the issuer signs for one first producer and the submitter names another, the genesis fails with "Issuer signature in the genesis reason does not verify."
    • Finalized at genesis: for a lineage finalized at revision 0, the signed recipient is the burn predicate, so the issuer also endorses that the lineage is final.
    • Format: we took the free moment and changed it in place (still version 1), since no lineage has been released.

    2. Only the token id identifies a lineage (825e059)

    • verify --token-id <hex> checks which lineage the token is. A different id fails with "Token id mismatch", reported ahead of any hash mismatch. A new Lineage id line says matches, differs, or not checked; pass --token-id …, so a passing result that hasn't established which lineage this is says so. The JSON output gains expectedTokenIdMatches.
    • At genesis, stamp-revision prints the token id marked "identifies this lineage; give it to verifiers".
    • Docs: the README and the agent skill say that the issuer key plus H(doc_0) isn't unique, and that verifiers need the id through a trusted channel.
    • Re-running an interrupted genesis now recovers the same lineage instead of minting a second one. The salt is derived as SHA-256(CBOR["unicity-document-lineage/salt", issuer private key, recipient, auxData]), like the state mask of later steps. We considered deriving it from public inputs instead (issuer public key and H(doc_0), with or without the recipient), which would make the issuer+H(doc_0) pin unique. We rejected that because the mint's state id depends only on the token id: anyone who has the document could pre-mint junk into that slot and permanently block the lineage. Keyed on the issuer's private key, nobody else can compute the id before the genesis is certified.
    • One consequence: a second, separate lineage from the same document needs a different issuer or first producer. This could somewhat hinder using a document template multiple times; a simple workaround is to skip stamping blank template and only stamp the "initial revision" when at least some fields have been filled in.
  7. moved this from In Dev to Done in Unicityon Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions