# subCard v0

**Status:** working draft, 25 November 2026. Implemented at subcard.org. Breaking changes are possible until v1.
**Editors:** the subCard project. **Reference implementation:** `tools/subcard.py`, `sync/app.py`.

The key words MUST, MUST NOT, SHOULD, SHOULD NOT and MAY are to be interpreted as described in [BCP 14](https://www.rfc-editor.org/info/bcp14) ([RFC 2119](https://www.rfc-editor.org/rfc/rfc2119), [RFC 8174](https://www.rfc-editor.org/rfc/rfc8174)) when, and only when, they appear in all capitals.

## 1. Overview

subCard lets a person or organization publish a contact card under a domain they control, the way DNS lets a domain owner publish records. The owner's node signs every card. Anyone can fetch the card, verify that it comes from the domain, and follow it so they always hold the current version.

The name says what it is: the sub in subCard stands for subscription. A subCard is a subscription to the data on a card, as opposed to a static vCard, which is a copy that goes stale.

| Role | Meaning |
|---|---|
| Owner | The person or organization a card describes |
| Issuer | The domain that vouches for the card, for example `subcard.org` |
| Node | The server that hosts, signs and serves cards for an issuer |
| Follower | A client or another node that holds a copy and keeps it current |

Design rules:

1. The owner's domain is the authority. Copies are caches, never sources.
2. Every card is signed; a card that does not verify MUST be rejected.
3. Notifications are hints, the signed card is the truth.
4. Fields are public or private per field. Private fields never leave the owner's own channels.
5. Plain web standards only: HTTPS, JSON, WebFinger, DNS TXT, vCard, CardDAV.

## 2. Addresses and discovery

A subCard address has the form `user@domain`, for example `harald@subcard.org`.

1. The follower queries [WebFinger (RFC 7033)](https://www.rfc-editor.org/rfc/rfc7033): `GET https://<domain>/.well-known/webfinger?resource=acct:<user>@<domain>`.
2. The JRD lists links with these relation types:

| rel | Target |
|---|---|
| `https://subcard.org/rel/card` | The signed card (JSON). REQUIRED |
| `https://subcard.org/rel/node` | The node's home |
| `https://subcard.org/rel/sync` | The sync base (section 8) |

A card's `id` is its canonical HTTPS URL. `<id>.json` returns the JSON card and `<id>.vcf` returns a vCard rendering of the same public view.

## 3. Card format

A card is a UTF-8 JSON object with media type `application/json`.

| Member | Type | Req. | Meaning |
|---|---|---|---|
| `@context` | string | MUST | `https://subcard.org/ns/v0` |
| `type` | string | MUST | `Card` |
| `id` | URL | MUST | Canonical HTTPS URL of the card |
| `issuer` | domain | MUST | Domain that signs the card. The host of `proof.keys` MUST equal it |
| `alias` | string | SHOULD | The `user@domain` address |
| `kind` | string | MAY | Who the card describes: `individual` (default) or `org` (a company, café, association or other organization). Mirrors vCard 4.0 `KIND` |
| `serial` | integer | MUST | Version of this view, increases on every content change |
| `updated` | RFC 3339 UTC | MUST | Time of the last content change |
| `view` | string | MAY | `public` or `full` (section 5) |
| `status` | string | MAY | For example `demo` |
| `sync` | URL | SHOULD | Sync base for this card (section 8) |
| `claims` | array | MUST | The fields, see below |
| `proof` | object | MUST | Signature (section 6) |

Unknown members MUST be ignored by readers and MUST be preserved inside the signed bytes. v0 cards MUST NOT contain floating-point numbers.

### 3.1 Claims

Each claim is an object:

| Member | Req. | Meaning |
|---|---|---|
| `field` | MUST | Field name from the registry below, or an `x-` prefixed private extension |
| `value` | MUST | String, or an object for structured fields |
| `type` | MAY | String or array, for example `["cell","pref"]`, `home`, `work` |
| `visibility` | MAY | `public` (default) or `private` |
| `ttl` | SHOULD | Seconds a follower MAY use the value before revalidating. Default 86400 |

A field MAY repeat (several `email` claims, for example).

### 3.2 Field registry (v0)

| field | value | vCard 3.0 mapping |
|---|---|---|
| `name` | string, full name | `FN` |
| `n` | `{family, given, suffix?}` | `N` |
| `org` | string | `ORG` |
| `title` | string | `TITLE` |
| `email` | address | `EMAIL;TYPE=INTERNET,<type>` |
| `tel` | E.164 or local format | `TEL;TYPE=<type>,VOICE` |
| `adr` | `{street, locality, region, postcode, country}` | `ADR;TYPE=<type>` |
| `url` | URL | `URL` |
| `facebook`, `linkedin`, `instagram` | user name | `X-SOCIALPROFILE;TYPE=<service>` |
| `geo` | `{lat, lon}`, decimal degrees as strings | `GEO:<lat>;<lon>` |
| `hours` | `{timezone, week, exceptions?}`, see 3.2.1 | Text summary in `NOTE` |
| `note` | string | not exported in v0 |

A card with `kind` `org` maps to vCard `ORG` with the card's name and `X-ABShowAs:COMPANY`, and leaves `N` empty.

#### 3.2.1 Opening hours

`timezone` is an IANA zone such as `Europe/Stockholm`. `week` has the keys `mon` to `sun`; each holds a list of `["HH:MM", "HH:MM"]` intervals, and an empty list means closed. `exceptions` lists dated deviations as `{from, to, closed, hours, note}` with ISO dates. A node SHOULD drop past exceptions and SHOULD give `hours` a short `ttl` (for example 3600), since it changes more often than other fields.

```json
{"field": "hours", "ttl": 3600, "value": {"timezone": "Europe/Stockholm",
  "week": {"mon": [], "tue": [], "wed": [], "thu": [], "fri": [["11:00", "16:00"]], "sat": [["11:00", "16:00"]], "sun": [["11:00", "16:00"]]},
  "exceptions": [{"from": "2026-12-24", "to": "2026-12-26", "closed": true, "hours": [], "note": "Christmas"}]}}
```

### 3.3 Example (test card)

```json
{
  "@context": "https://subcard.org/ns/v0",
  "type": "Card",
  "id": "https://node.example.org/cards/alice",
  "alias": "alice@example.org",
  "issuer": "example.org",
  "serial": 1,
  "updated": "2026-01-01T00:00:00Z",
  "claims": [
    {
      "field": "name",
      "value": "Alice Example",
      "ttl": 86400
    }
  ],
  "proof": {
    "type": "subcard-ed25519-2026",
    "alg": "EdDSA",
    "kid": "1IG2tMH7J2wbJZnOf8LJzQitKf7LMvoAElsuDMVM54Y",
    "keys": "https://example.org/.well-known/subcard/keys.json",
    "created": "2026-01-01T00:00:00Z",
    "sig": "7RLGdTzjeOSqy_BggR-DQzG25jZs3khhG9Do8ip0R7L1GsMw6pgbrRHw6D7roedhNBApYjaqA3dHEe1Y5N-qAw"
  }
}
```

## 4. Keys

### 4.1 Key document

The issuer MUST publish its keys at `https://<issuer>/.well-known/subcard/keys.json`:

```json
{
  "issuer": "subcard.org",
  "updated": "2026-11-25T14:42:54Z",
  "keys": [
    {"kty": "OKP", "crv": "Ed25519", "x": "<base64url>", "kid": "<thumbprint>",
     "use": "sig", "alg": "EdDSA", "status": "active", "created": "..."}
  ]
}
```

- Keys are Ed25519 ([RFC 8032](https://www.rfc-editor.org/rfc/rfc8032)) encoded as JWK ([RFC 8037](https://www.rfc-editor.org/rfc/rfc8037)).
- `kid` is the JWK thumbprint ([RFC 7638](https://www.rfc-editor.org/rfc/rfc7638)), SHA-256, base64url without padding.

### 4.2 Key status

| status | Meaning | Accept a signature? |
|---|---|---|
| `next` | Announced ahead of a rotation | No |
| `active` | The key the node signs with. Exactly one | Yes |
| `retired` | Replaced in a planned rotation; carries `retired` (time) | Only if `proof.created` ≤ `retired` |
| `revoked` | Possibly compromised; carries `revoked` and `reason` | Never |

A node MUST destroy the private key of a retired or revoked key.

### 4.3 DNS anchor

The issuer SHOULD publish a TXT record:

```
_subcard.<issuer>.  TXT  "v=sc0; kid=<kid> [kid=<kid2> ...]"
```

If the record exists, a verifier MUST reject a card whose `proof.kid` is not listed. This binds the key to whoever controls the domain's DNS, so a compromised web server alone cannot substitute a key. [DNSSEC](https://www.rfc-editor.org/rfc/rfc9364) makes the anchor stronger and SHOULD be used where the DNS provider supports it.

### 4.4 Rotation and revocation

Planned rotation:

1. Create a `next` key and publish it in keys.json.
2. List both kids in the TXT record.
3. Make the new key `active`, mark the old one `retired`, destroy its private key, re-sign all cards and emit a `keys` change (section 8).
4. After followers have refreshed (one day is enough with default TTLs), remove the old kid from the TXT record.

Emergency revocation: mark the key `revoked` with a reason, make a new key active at once, re-sign, emit `keys`, and update the TXT record immediately so it no longer lists the revoked kid.

## 5. Visibility and views

Each claim is `public` or `private`. A node produces two views of every card:

| View | Contains | Served to |
|---|---|---|
| `public` | Public claims only | Anyone: `<id>.json`, `<id>.vcf`, sync |
| `full` | All claims | Only the owner's authenticated channels (for example the owner's CardDAV address book) |

- Private claims MUST NOT appear in a public view, in the change log, or in notifications.
- Each view has its own `serial`. A change to private claims bumps only the full view's serial, so the public serial does not reveal that a private field changed.
- Both views are signed with the same key and have the same `id`.

## 6. Signing

### 6.1 Canonical form

The signed bytes are the card including `proof`, but with `proof.sig` removed, serialized as JSON with object members sorted by code point, no insignificant whitespace, UTF-8, and no escaping of non-ASCII characters. With the no-floats rule, this equals [JCS (RFC 8785)](https://www.rfc-editor.org/rfc/rfc8785). Because `proof.kid`, `proof.keys` and `proof.created` are signed, none of them can be changed without breaking the signature.

### 6.2 Proof

| Member | Value |
|---|---|
| `type` | `subcard-ed25519-2026` |
| `alg` | `EdDSA` |
| `kid` | Thumbprint of the signing key |
| `keys` | URL of the key document; host MUST equal `issuer` |
| `created` | RFC 3339 UTC time of signing |
| `sig` | base64url Ed25519 signature over the canonical bytes |

### 6.3 Verification

1. Check that the host of `proof.keys` equals `issuer`, and fetch the key document. Its `issuer` MUST equal the card's `issuer`.
2. Find the key whose `kid` equals `proof.kid` and apply the status rules in 4.2.
3. If `_subcard.<issuer>` TXT exists, `proof.kid` MUST be listed in it.
4. Remove `proof.sig`, build the canonical bytes and verify the signature.
5. A follower that already holds the card MUST NOT accept a lower `serial` for the same view.

## 7. Address-book delivery

A node SHOULD offer vCard 3.0 ([RFC 2426](https://www.rfc-editor.org/rfc/rfc2426)) renderings and MAY offer read-only CardDAV ([RFC 6352](https://www.rfc-editor.org/rfc/rfc6352)) address books with collection sync ([RFC 6578](https://www.rfc-editor.org/rfc/rfc6578)). vCards carry `X-SUBCARD-ID`, `X-SUBCARD-SERIAL` and `X-SUBCARD-KID`, and their `UID` is a UUIDv5 (URL namespace) of the card `id`, so the same card keeps the same contact across updates. Unchanged cards SHOULD keep identical bytes so ETags and sync tokens stay stable.

A card page SHOULD let the reader choose between the two ways to keep a card:

| Choice | What the reader gets | Delivery at subcard.org |
|---|---|---|
| Subscription (subCard) | A contact that follows the card and updates when the owner changes it | One read-only CardDAV book per card, login `follow-<name>` with the public password `subcard`, plus an Apple configuration profile at `/profiles/<name>.mobileconfig` |
| Static card (vCard) | A one-time copy that does not change | `<id>.vcf` |

Subscription books hold only the public view, so the shared password grants nothing that is not already public.

## 8. Sync

The sync base, for example `https://node.subcard.org/sync/v0/`, provides:

| Endpoint | Purpose |
|---|---|
| `state.json` | Snapshot: `cursor` and every public card with `id`, `url`, `serial`, `updated` |
| `log.json` | The most recent change entries (at least 1000) |
| `changes?since=N` | Entries with `seq > N`. `410` with `"reset": true` if N is older than the log; fetch `state.json` and continue from its `cursor` |
| `events` | [Server-Sent Events](https://html.spec.whatwg.org/multipage/server-sent-events.html): `id` = seq, `event` = kind. Resume with `Last-Event-ID` or `?since=N` |
| `subscribe`, `unsubscribe` | Webhooks (8.2) |

### 8.1 Change entries

`{"seq": 7, "kind": "update", "at": "...", "id": "...", "url": "...", "serial": 3}`

| kind | Follower action |
|---|---|
| `update` | Fetch `url`, verify (6.3), accept if the serial is higher |
| `delete` | The owner withdrew the card; stop showing it as current |
| `keys` | Re-fetch the key document and re-verify every held card from this issuer |

`seq` increases strictly within a node. Entries describe public views only.

### 8.2 Webhooks

1. `POST subscribe` with `{"callback": "https://...", "cards": [ids]?, "lease_seconds": n?}`.
2. The node MUST only call HTTPS callbacks on public IP addresses, and SHOULD pin the address it checked for the request.
3. Verification of intent, as in [WebSub](https://www.w3.org/TR/websub/): `GET <callback>?subcard.mode=subscribe&subcard.challenge=X&subcard.lease_seconds=N`; the callback answers `200` with body `X`.
4. The node replies `201 {"id", "secret", "lease_seconds", "cursor"}`. Leases are between one hour and 30 days; renew by subscribing again.
5. Notifications: `POST <callback>` with `{"node", "cursor", "changes": [...]}` and header `X-Subcard-Signature: sha256=<hex HMAC-SHA256(secret, body)>`. `keys` entries go to every subscriber.
6. A node MAY drop subscriptions after repeated failed deliveries.

## 9. Security and privacy considerations

- **Trust chain:** domain → DNS anchor → key document over HTTPS → signature. An attacker needs both the DNS and the web server to substitute a key.
- **Replay:** followers keep the highest serial per view and reject lower ones; signed `updated` and `proof.created` bound how old a card is.
- **Notification spoofing:** harmless by design, because every notification only triggers a fetch and a full verification.
- **Server-side request forgery:** webhook callbacks are limited to public HTTPS addresses (8.2).
- **Private fields:** never in public views, logs or notifications. Nodes SHOULD keep private sources outside version control and restrict them to the node's service account.
- **Enumeration:** `state.json` lists all public cards of a node. A node that does not want this MAY limit it to cards whose owners opted in.
- **Key compromise:** revoke (4.4). Backups can retain destroyed private keys for their retention period; the DNS anchor is what protects followers after a revocation.

## 10. Test vector

Test key (never use for real cards): Ed25519 private seed `000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f`.

```
x   = A6EHv_POEL4dcN0Y50vAmWfk1jCbpQ1fHdyGZBJVMbg
kid = 1IG2tMH7J2wbJZnOf8LJzQitKf7LMvoAElsuDMVM54Y
```

Canonical bytes of the example card in 3.3 (one line):

```
{"@context":"https://subcard.org/ns/v0","alias":"alice@example.org","claims":[{"field":"name","ttl":86400,"value":"Alice Example"}],"id":"https://node.example.org/cards/alice","issuer":"example.org","proof":{"alg":"EdDSA","created":"2026-01-01T00:00:00Z","keys":"https://example.org/.well-known/subcard/keys.json","kid":"1IG2tMH7J2wbJZnOf8LJzQitKf7LMvoAElsuDMVM54Y","type":"subcard-ed25519-2026"},"serial":1,"type":"Card","updated":"2026-01-01T00:00:00Z"}
```

Signature:

```
7RLGdTzjeOSqy_BggR-DQzG25jZs3khhG9Do8ip0R7L1GsMw6pgbrRHw6D7roedhNBApYjaqA3dHEe1Y5N-qAw
```

## 11. Changes from earlier drafts

- The signature now covers the proof metadata (`kid`, `keys`, `created`); earlier drafts signed the card without `proof`.
- Key statuses `next`, `retired` and the DNS anchor are new in this draft.
- New: the `kind` member (individual or organization) and the `geo` and `hours` fields.
- New: subscription (subCard) versus static card (vCard) on card pages, with one CardDAV book per card.
