Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
47e97b1
feat(core): add signed encrypted manifest wire format
beardthelion Dec 2, 2026
fddf1b8
feat(node): sign encrypted recovery manifest shards
beardthelion Dec 2, 2026
6d694d5
fix(core): scale encrypted manifest sharding
beardthelion Dec 2, 2026
a960422
feat(cli): authenticate arweave encrypted recovery manifests
beardthelion Dec 2, 2026
8d81609
docs: document signed encrypted recovery manifests
beardthelion Dec 2, 2026
a4fa801
fix(node): anchor manifests under canonical repository identity
beardthelion Dec 2, 2026
7a1a681
refactor(cli): simplify authenticated manifest recovery
beardthelion Dec 2, 2026
5f63c0c
style(cli): satisfy workspace lint gates
beardthelion Dec 2, 2026
0fbc3c7
fix(cli): prevent manifest replay and use live pagination
beardthelion Dec 2, 2026
b88e927
fix(cli): enforce exact arweave transaction ceilings
beardthelion Dec 2, 2026
42a2c1b
style(cli): satisfy cursor extraction lint
beardthelion Dec 2, 2026
50701fd
docs: state arweave edge cursor pagination
beardthelion Dec 2, 2026
01a7b01
fix(cli): bound verified manifest retention during recovery
beardthelion Dec 2, 2026
2ba5476
fix(cli): harden arweave recovery feedback fixes
beardthelion Dec 2, 2026
8f183bc
fix(cli): bound replayed manifest cache entries
beardthelion Dec 2, 2026
38ac8fa
Merge origin/main into fix/316-arweave-manifest-authenticity
beardthelion Dec 3, 2026
2cf87b6
fix(cli): keep the recovery presence probe from lazy-fetching
beardthelion Dec 3, 2026
e2e4934
fix(cli): report malformed discovery pages and probe legacy anchors w…
beardthelion Dec 3, 2026
6624e84
test(core): use hex letters in the oid case normalization test
beardthelion Dec 3, 2026
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
126 changes: 126 additions & 0 deletions PROTOCOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,129 @@ they are documented with the node's HTTP API, not here.
serves it over REST (the repo `refs` endpoint maps branch heads to CIDs).
*Planned:* IPNS-backed branch pointers; IPNS is not part of the shipped
wire contract.
## 6. Signed encrypted-blob recovery manifests

Encrypted-blob recovery uses a permanent index that maps git object ids to the
CIDs of encrypted envelopes. Version 2 is the only schema a current client may
use as recovery authority. Version 1 manifests may still exist in permanent
storage, but they are unsigned and current clients MUST NOT fetch or interpret
their bodies as authority.

### Artifact shape

A v2 artifact is one compact JSON object with exactly these fields:

```json
{"schema":"gitlawb/encrypted-manifest/v2","payload":"<payload-json-string>","signature":"<base64url-ed25519>"}
```

The `payload` value is a JSON string, not a nested object. The exact UTF-8
bytes of that string are the signed bytes. When parsed as JSON, the payload has
exactly these fields:

- `schema`: exactly `gitlawb/encrypted-manifest/v2`.
- `repo`: the canonical repository slug described below.
- `owner_did`: the repository owner DID.
- `node_did`: the signing node's canonical Ed25519 `did:key`.
- `timestamp`: an RFC 3339 timestamp.
- `blobs`: an array of objects with exactly `oid` and `cid`.

The signing input is the ASCII bytes `gitlawb-encrypted-manifest-sig/v2\n`
followed by the exact payload-string bytes. The signature is base64url without
padding over a 64-byte Ed25519 signature. Unknown or missing fields, a schema
mismatch, malformed base64url, a wrong signature length, or a signature that
does not verify are all rejection conditions.

The canonical owner key strips a leading `did:key:` only when the remainder
contains no further colon. Other DID spellings remain whole. The canonical
repository slug is `<canonical-owner-key>/<repo-name>`. The signed `owner_did`
must canonicalize to the owner portion of the signed `repo`. Object ids are 40
or 64 lowercase or uppercase hexadecimal characters and must not repeat within
one manifest. Blob CIDs must parse as CIDv1; any CIDv1 codec is valid because
large envelopes may sit behind a chunked root.

A verifier accepts at most 256 KiB of outer artifact bytes and at most 1024
blob entries. Current writers produce complete disjoint shards of at most 256
entries and at most 96 KiB of outer bytes each. No shard index exists because
the entries are disjoint and recovery is their union. A shard that cannot be
made valid must not be published.

### Discovery and retrieval

Discovery tags are hints, never authority. Current discovery uses:

- `App-Name`: `twigpine` or `gitlawb`
- `Schema`: `gitlawb/encrypted-manifest/v2`
- `Repo-Digest`: base64url-unpadded SHA-256 over the exact UTF-8 bytes of the
canonical repository slug

The human-readable `Repo` tag is diagnostic only. It may be truncated by the
uploader's tag rules and is not a v2 discovery key. Legacy v1 probing uses the
old truncated `Repo` tag only as a metadata-only presence check; v1 bodies are
never recovery input.

A client requests Arweave transaction bodies from `/raw/<transaction-id>`, not
from the manifest-resolving `/<transaction-id>` endpoint. Transaction ids are
exactly 43 base64url characters before they may appear in a request URL. The
CLI discovery query asks for `sort: HEIGHT_DESC` and reads at most 8 pages or
exactly at most 512 transaction ids. Pagination uses the cursor on the final
edge; Arweave `pageInfo` supplies `hasNextPage`, not `endCursor`. Each GraphQL
page response is capped at 256 KiB.
Discovery plus manifest fetch and verification has a 120 second wall-clock
budget. Hitting a count or time budget means recovery is incomplete and must
produce a warning.

### Verification and trust anchor

The signer DID is anchored outside the artifact. `twigpine clone --expect-node
<did>` supplies the pin explicitly. Without it, the CLI reads the effective
clone node's root metadata once, accepts its `did` field only when it is a
canonical Ed25519 `did:key`, and uses that as the implicit anchor. The implicit
anchor is not independent verification: clone already trusts the selected node
for the base repository and primary recovery. It exists so the ordinary clone
path can use B3. A caller cloning through a replica who needs the origin
node's anchors should pin that origin DID with `--expect-node`; the pin is not
required to equal the replica's self-reported DID. If no valid implicit anchor
can be derived, only Arweave recovery is skipped.

The artifact's `node_did` may be compared with the externally anchored DID,
but it must never supply that anchor. The signed repo must equal the canonical
slug of the repository being cloned. Wrong signer, wrong repository, unsigned
v1 data, malformed identity or timestamp fields, malformed object ids or CIDs,
repeated object ids, and schema drift are all rejected before merge. Clone
passes the effective node to git subprocesses as both `TWIGPINE_NODE` and
`GITLAWB_NODE`, so the git transport and recovery API use the same node.

### Merge and recovery rules

Authentication happens before merge. Entries naming object ids absent from the
cloned tree are discarded before merge retention, local object checks, or
gateway fetches. Surviving entries for the same object rank by:

1. the signed timestamp compared as an RFC 3339 instant;
2. block-height rank as the equal-timestamp tie-break: a pending anchor is
newest, otherwise larger height wins;
3. the lexicographically larger CID as the final deterministic tie-break.

The signed timestamp must outrank inclusion height because anyone can republish
exact old public manifest bytes into a new transaction. Height is gateway-
reported availability metadata only. It is never evidence of authenticity.

Discovery tags remain permissionless hints. A publisher can spam matching tag
queries and crowd honest transactions out of the fixed page, transaction, or
time budgets. The caps bound that abuse and require an incomplete-recovery
warning; they do not prove discovery completeness. Closing that censorship hole
requires owner-bound upload ownership or another issuer-bound discovery
mechanism.

Public-gateway envelope bodies are capped at 32 MiB of object bytes plus 64
KiB of envelope allowance. A body exactly at the cap is valid; a larger body,
a mid-body read failure, or a cross-origin redirect cannot become recovery
input. Redirects are followed only within the same origin, only when path and
query are unchanged, never on a downgrade from https, and only within the
shared ten-hop bound. The default IPFS gateway is path-style `https://ipfs.io`.
Subdomain-only gateways such as `dweb.link` redirect path requests to another
origin and are incompatible with that policy.

Gateway-controlled terminal output is sanitized. At most 20 detailed B3 warning
lines are emitted, followed by one aggregate suppression count.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,33 @@ a cleartext hop to a remote node exposes the pack contents and the `Signature`
header. A remote `http://` node is refused, and `TWIGPINE_ALLOW_INSECURE_HTTP=1`
overrides that for a trusted private network.

### Encrypted-blob recovery trust pins

`twigpine clone` can recover authorized withheld blobs from signed Arweave
manifests when the node cannot supply their encrypted envelopes. The manifest
signer is pinned as a node DID. By default the clone uses the DID reported by
the node selected with `--node` or `TWIGPINE_NODE`, and passes that same node
to the git transport as both `TWIGPINE_NODE` and `GITLAWB_NODE`. This implicit
anchor is part of the clone trust boundary, not independent proof against a
malicious selected node.

Use `--expect-node <did>` when the signer must be pinned explicitly, especially
when cloning through a replica while recovering manifests signed by the origin
node:

```bash
twigpine clone gitlawb://<owner-did>/my-repo \
--node https://replica.example \
--expect-node did:key:z6Mk...
```

The value must be the origin node's canonical Ed25519 `did:key`. One way to
read it is the `did` field of that node's root metadata. A pin mismatch does
not fall back to artifact-supplied identity. Unsigned legacy manifests are
ignored as unauthenticated. Public-gateway fallback uses path-style IPFS
gateway URLs; the default is `https://ipfs.io`, and subdomain-only gateways
such as `dweb.link` are incompatible with the same-origin redirect policy.

### Full lifecycle against an iCaptcha-enforcing node

Public nodes (e.g. `node.twigpine.com`) require two things on writes:
Expand Down
Loading