Add device keys, revocation and libp2p gossip with sync
- identity: 12-word recovery phrase, device certificates, revocations, device key storage; the identity key is never stored on a node - listing: signed by a device with an embedded certificate, domain-separated signatures, ErrTimeWindow for clock-related failures, region helpers - store: revocations purge a device's listings; keyset-paged Since for sync - p2p: gossipsub topic per geohash region plus a global revocation topic, validators run before relaying, /allmende/1/sync catch-up protocol, bootstrap peers and mDNS - docs: key model, replication and conflict rules Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+59
-14
@@ -9,16 +9,41 @@ running a node; searching is browser-only through any node's HTTP gateway.
|
||||
search API on every node.
|
||||
- **Browsers** never join the P2P network. They fetch from any gateway and
|
||||
**verify signatures themselves**, so a gateway cannot forge listings.
|
||||
- **Sharding**: listings are gossiped per `geohash` region (precision 6, ~1 km)
|
||||
and category. Nodes subscribe to the regions they care about and index them
|
||||
locally.
|
||||
- **Sharding**: a listing carries a precision-6 `geohash` (~1 km) and is gossiped
|
||||
on the topic of its precision-3 *region* (~150 km cell),
|
||||
`/allmende/1/listings/<region>`. Nodes subscribe to the regions they care
|
||||
about, replicate them, and index them locally. Fine-grained filtering
|
||||
(precision, kind, category, price) happens in local search.
|
||||
- **Discovery**: configured bootstrap peers plus mDNS on the local network;
|
||||
gossipsub peer exchange spreads the mesh. A Kademlia DHT can be added later
|
||||
without protocol changes.
|
||||
- **License**: AGPL-3.0, so modified nodes and gateways must publish their source.
|
||||
- **Launch scope**: one German state or metro area.
|
||||
|
||||
## Identity
|
||||
## Identity and keys
|
||||
|
||||
An ed25519 keypair is the identity. No accounts. The public key (64 hex chars)
|
||||
is the `author`.
|
||||
Designed so non-technical people can use it and a compromised node can be
|
||||
revoked. There are no accounts.
|
||||
|
||||
- **Identity key** (ed25519): derived from a **12-word recovery phrase** shown
|
||||
once at first run. Its public key is the `author`. It signs *certificates*
|
||||
and *revocations* only, and is **deleted from the machine** right after
|
||||
enrolling the first device.
|
||||
- **Device key** (ed25519): generated per node, stored on that node. It signs
|
||||
listings and is also the node's libp2p identity, so the node's peer ID derives
|
||||
from the `device` field. There is no separate `endpoint` field.
|
||||
- **Certificate**: `{v, author, device, issued_at, expires_at (<= 1 year), sig}`
|
||||
signed by the identity key. Travels inside every listing.
|
||||
- **Revocation**: `{v, author, device, revoked_at, cert_expires_at, pow, sig}`
|
||||
signed by the identity key, gossiped on `/allmende/1/revocations` (all nodes
|
||||
subscribe), kept until `cert_expires_at`. A revoked device's signatures are
|
||||
void: its listings are purged and refused. The owner restores the identity
|
||||
from the phrase on a new machine, revokes the old device, enrolls a new one
|
||||
and republishes (higher `seq`).
|
||||
- Lost phrase and lost device: start a new identity. Cheap, because listings
|
||||
expire within 30 days anyway.
|
||||
- Signed payloads are domain-separated (`allmende-cert-v1\n`,
|
||||
`allmende-revocation-v1\n`, `allmende-listing-v1\n` prefixes).
|
||||
|
||||
## Listing record
|
||||
|
||||
@@ -28,8 +53,10 @@ Canonical JSON (RFC 8785), integers only. See `internal/listing`.
|
||||
|---|---|
|
||||
| `v` | format version, currently 1 |
|
||||
| `id` | 32 hex, stable across versions |
|
||||
| `author` | hex ed25519 public key |
|
||||
| `seq` | higher replaces lower for same `id` + `author` |
|
||||
| `author` | identity public key (hex) |
|
||||
| `device` | signing device's public key (hex) |
|
||||
| `cert` | certificate binding `device` to `author` |
|
||||
| `seq` | higher replaces lower for the same `author` + `id` (any device of the author may supersede) |
|
||||
| `created_at`, `expires_at` | unix seconds; lifetime <= 30 days, owner re-signs to renew |
|
||||
| `tombstone` | deletion marker: higher `seq`, no content, only routing `geohash` |
|
||||
| `kind` | `rent` or `sale` |
|
||||
@@ -39,10 +66,9 @@ Canonical JSON (RFC 8785), integers only. See `internal/listing`.
|
||||
| `area_m2`, `rooms_x2` | rooms * 2 (2.5 rooms = 5) |
|
||||
| `features`, `title`, `description` | bounded text |
|
||||
| `images` | `{hash, thumb_hash}`, content-addressed, **no location** |
|
||||
| `endpoint` | owner's peer ID |
|
||||
| `delegate` | optional always-on host chosen by the owner |
|
||||
| `delegate` | optional always-on host's peer ID, chosen by the owner |
|
||||
| `pow` | nonce; sha256 of the unsigned canonical bytes has N leading zero bits |
|
||||
| `sig` | ed25519 over the unsigned canonical bytes |
|
||||
| `sig` | device signature over the unsigned canonical bytes (with context prefix) |
|
||||
|
||||
There is **no address, name, phone or email** in the record.
|
||||
|
||||
@@ -70,12 +96,31 @@ owner is offline. Images and contact details need the owner's node or its
|
||||
delegate. UI shows an "owner offline" badge; listings expire if not re-signed
|
||||
within 30 days.
|
||||
|
||||
## Replication
|
||||
|
||||
- **Gossip**: every message is checked by a topic validator *before* it is
|
||||
relayed: canonical encoding, size, signature chain, proof-of-work, region
|
||||
match, not revoked. Invalid messages are rejected (the relaying peer loses
|
||||
score); clock-related failures (expired, future) are ignored without penalty.
|
||||
Publishers flood to all subscribed peers so a listing published right after
|
||||
connecting is not lost before the mesh forms.
|
||||
- **Conflict rules** (identical on every node, so replicas converge): keyed by
|
||||
`(author, id)`; higher `seq` wins; equal `seq` -> smaller hash wins;
|
||||
tombstones are stored like any version so old copies cannot resurrect a
|
||||
deleted listing.
|
||||
- **Sync** (`/allmende/1/sync`): on connecting to a peer (at most every
|
||||
5 minutes) a node pulls revocations first, then each subscribed region,
|
||||
paged by a `(created_at, author, id)` keyset cursor. Tombstones are included
|
||||
so deletions propagate. Currently a full pull; a digest-based incremental
|
||||
sync is future work.
|
||||
|
||||
## Spam
|
||||
|
||||
Proof-of-work per listing plus subscribable blocklists. The format leaves room
|
||||
for vouching signatures later.
|
||||
Proof-of-work per listing and per revocation, plus subscribable blocklists
|
||||
(not built yet). The format leaves room for vouching signatures later.
|
||||
|
||||
## Open
|
||||
|
||||
Buyer/seller messaging (E2E, store-and-forward), reciprocity rules, anti-
|
||||
discrimination (AGG) content rules.
|
||||
discrimination (AGG) content rules, blocklists, peer scoring and rate limits,
|
||||
incremental sync, DHT discovery, HTTP gateway and web UI, image hosting.
|
||||
|
||||
Reference in New Issue
Block a user