Skip to content

feat(prism-id): login-free prism identity with out-of-band device linking - #1

Open
afflom wants to merge 13 commits into
feat/complete-stitch-prismfrom
claude/project-thread-nkgrlb
Open

afflom wants to merge 13 commits into
feat/complete-stitch-prismfrom
claude/project-thread-nkgrlb

Conversation

@afflom

@afflom afflom commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Milestone 1 of prism id, the foundry's durable, elastic identity provider. Nobody signs in with Google or anything else: a prism comes into being in the browser, and its id is the κ of its genesis record. A second device joins only through an out-of-band offer, such as a QR code. After that, linked devices sync over the substrate bus.

Model first

app/src/Stitch/PrismId.lex.tex (Stitch.PrismId) defines five rules: deviceMaySign, bindAllowed, linkOfferAccepted, boundaryShared and boundaryVisibleTo. It also states nine theorems:

  • unlinked device cannot sign
  • revoked device cannot sign
  • unlinked signer cannot bind
  • invalid bind signature refused
  • used offer refused
  • expired offer refused
  • one identity is private
  • two identities make a boundary shared
  • a non-member sees only published content

The runtime calls the generated bindings for every authorization decision.

Runtime (src/prism-id.js)

  • κ: uor-addr canonical JSON, aligned with LexLean kappa and PrismPM ADR-017. Strings must already be NFC, numbers must be integers, and members are ordered by their UTF-8 bytes.
  • Device keys: non-extractable P-256 keys for signing and key agreement.
  • Prism log: genesis, bind and revoke records, merged as a set union.
  • Linking:
    • a QR link offer
    • a rendezvous topic derived from the offer's secret
    • an HMAC-authenticated request
    • the private boundary key wrapped with ECDH, HKDF and AES-GCM
  • Private content: sealed under the private boundary key.
  • Sync: the sync topic is derived from the boundary key, so only linked devices can find it.
  • Bus: an in-memory bus that implements the publish/subscribe contract the substrate will provide in M2.

Design notes are in docs/prism-id.md. The main decision there: when a revocation and a bind happen concurrently, the revocation wins. A revoke record lists in keep which of the revoked device's binds stay valid, so rotating away from the genesis device keeps the other linked devices.

Product registration

  • prismId is registered as a product component and asset.
  • Architecture indexes are renumbered into canonical order.
  • Facets, bindings and the product register are regenerated.

Verification

  • scripts/author-source.sh ran with the pinned SDK image from prismpm.lock: verified 39 modules; attestation 9502eee0…. The source evidence is retained.
  • npm test: 430 pass, 0 fail, including 11 new tests in tests/prism-id.test.js.
  • Native Prism acceptance (PP5007) is separate and was not run.

Next milestones

  • M2: substrate bus over peers and federation nodes, replacing ntfy.
  • M3: <prism-frame> in foundry, with host permissions keyed by prism context.
  • M4: threshold recovery shares.

Generated by Claude Code

…king

Add Stitch.PrismId (app/src/Stitch/PrismId.lex.tex) with deviceMaySign,
bindAllowed, linkOfferAccepted, boundaryShared and boundaryVisibleTo, and
theorems unlinkedDeviceCannotSign, revokedDeviceCannotSign,
unlinkedSignerCannotBind, invalidBindSignatureRefused, usedOfferRefused,
expiredOfferRefused, singleIdentityBoundaryPrivate,
twoIdentitiesMakeBoundaryShared and nonMemberSeesOnlyPublished.

Add src/prism-id.js: uor-addr canonical JSON and kappa (NFC required,
integers only, UTF-8 member order), non-extractable P-256 device keys,
genesis record (prism id = kappa of genesis), bind and revoke records,
set-union log merge, QR link offer with secret-derived rendezvous topic,
ECDH/HKDF/AES-GCM wrap of the private boundary key, sealed private content,
sync topic derived from the boundary key, and an in-memory bus with the
substrate publish/subscribe contract. Every authorization decision calls the
generated model binding.

Register prismId as a product component and asset, renumber the
architecture indexes canonically, regenerate facets, bindings and the
product register, and retain new source evidence from the pinned SDK
(lexlean verify --all: 39 modules). npm test: 430 pass, 0 fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Le2ZWWHa47YS9u3wT
Prism id's next milestone: a recovery device is an ordinary prism/device/1
linked by the ordinary link flow, whose private keys are sealed (AES-GCM,
HKDF from a 32-byte seed) in a public-safe prism/recovery-escrow/1 object
with the private boundary and the log. The owner keeps the seed as a
56-character Crockford recovery code with three check bytes. recoverOnto
opens the escrow and links the new browser's own non-extractable device
through createLinkOffer/acceptLinkRequest/completeLink, so Stitch.PrismId
decides it like any link; a recovery device revoked in a newer log links
nothing. No model rule is added. Lives in src/prism-id.js so the product
register's modeled artifacts are unchanged (contracts.json regenerated).

tests/prism-recovery.test.js: code round trip and typo refusal, recovery
onto a new device with the private boundary, escrow bound to its code,
revoked recovery refused. node --test tests/prism-*.test.js: 15 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
Device records carry a class (browser, native, mobile, embedded) and a
claimed key protection (software, platform, secure-element). Binds carry a
role: member, or delegate with a non-empty action scope. Delegates never
receive the private boundary and cannot bind or revoke.

Model additions in Stitch.PrismId: mayAdminister, linkGate with a
person-confirmed six-digit code, receivesPrivateBoundary, scopeAdmits,
actionAllowed, actionGate/actionFresh (audience, nonce, time window),
hostAdmitsDevice (attestation required when a host demands hardware keys),
boundaryKeyAdmitted. New theorems: delegateCannotBind,
foreignPrismBindRefused, unconfirmedLinkRefused, wrongSecretRefused,
delegateNeverReceivesPrivateBoundary, delegateOutsideScopeRefused,
revokedDeviceActionRefused, replayedActionRefused,
wrongAudienceActionRefused, staleActionRefused,
unattestedDeviceRefusedWhenRequired, staleBoundaryKeyRefused.

Runtime: every revocation carries a new boundary key wrapped to each
remaining member; the sync topic moves with it; stale keys refuse to seal.
Signed actions are bound to an audience with a nonce and verified by hosts
against the prism log. Logs over 4096 records and sync messages over 4 MiB
are refused before parsing.

Cross-runtime conformance: tests/fixtures/prism-id-vectors.json and an
independent standard-library Python verifier.

Threat model: docs/prism-id-threat-model.md (objectives, trust boundaries,
adversaries, assets, STRIDE per element, attack trees, device-class
threats, LINDDUN, assumptions, residuals). Sixteen Prism* threats join the
official Security facet with gate, review and proof evidence.

lexlean verify --all under the pinned SDK: 39 modules. npm test: 441 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Le2ZWWHa47YS9u3wT

afflom commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

The model check failure is not caused by this PR. It is red on the base commit too (4a40d2c, feat/complete-stitch-prism), and it fails the same way: PP5007: application-lean timed out. That is the native Prism acceptance gate, which scripts/author-source.sh already reports as not cleared.

The source authoring and proof steps pass with the same pinned SDK: lexlean verify --all verified 39 modules, and the retained evidence is in this branch. runtime and browser pass.


Generated by Claude Code

claude and others added 10 commits November 13, 2026 22:33
A recovery device (class recovery) is linked through the ordinary link flow;
its keys, keyring and log are sealed under a key derived from a 56-char
Crockford recovery code. recoverOnto links the new browser's own device;
later rotations reach the recovery device as a member, so old codes keep
opening newly sealed content. Revoked recovery devices link nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
ECDSA signatures are malleable and envelopes are keyed by their own kappa,
so anyone could add a second genesis envelope for a prism (same body, other
signature) and resolvePrism refused every log that held both. Resolution now
takes any genesis of the prism whose signature verifies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
- R6: hybrid ECDH + ML-KEM-768 wraps for devices that advertise a kem key;
  classical wraps to such devices are refused (hybridWrapRequired).
- R5: sealed sync messages padded (ISO 7816-4) to power-of-two buckets >= 1 KiB.
- R1: hardenSession keeps only non-extractable HKDF-derived seal/topic keys;
  hardened devices cannot link members or set up recovery (mayShareBoundary).
- R4: threshold recovery (Shamir over GF(256)) with device or paper guardians,
  releaseShare re-wraps to a confirmed new device, recoverPrism binds it,
  revokes every other device and can rotate recovery. Recovery revocations
  take precedence; members cannot revoke or replace the recovery device
  (revocationCounts, recoveryBindAllowed, thresholdMet).
- R3: per-host personas: separate prisms with per-device persona keys, kept in
  step on sync, recovered via keys wrapped to the main recovery device.
- R7: admitDevice requires a host-pinned verifier binding the attestation to
  the device signing key (attestationBinds).

Model: 6 definitions and 8 theorems added to Stitch.PrismId, verified under
the pinned SDK (39 modules). Security facet: 5 rows updated, 5 added
(32 threats). 32 prism-id tests pass on node 22 and node 24; npm test 451/451.
Threat model and protocol docs updated with residual status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Le2ZWWHa47YS9u3wT
… resolve

- createRelayBus implements the prism bus contract (publish, subscribe) on
  stitch's own transport: the warm relay with stitch's relay framing across
  devices and origins, BroadcastChannel within one origin. The relay topic is
  a domain-separated hash of the prism topic (at most 64 characters), every
  message names its prism topic, a subscriber delivers only that topic, and a
  bus never hears itself. subscribe first delivers what the relay still holds
  (the warm lifetime), then live messages; fetch returns what it holds.
  Effects (fetch, WebSocket, BroadcastChannel) are injectable.
- resolvePrism takes any genesis of the prism whose signature verifies.
  ECDSA signatures are malleable and envelopes are keyed by their own kappa,
  so a second genesis envelope (same body, other signature) made every log
  that held both unresolvable.

tests/prism-bus.test.js: framing and hashed topics over an ntfy-shaped relay,
a multi-frame message, two devices linking over the rendezvous topic with the
six-digit code then syncing a removal, and the copied genesis. npm test 445
of 446; the one failure (source-authoring, prism-code axioms.mjs missing in
this checkout) fails identically on the base commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
…rsedes recovery codes (drops b85ef0d)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
…og-free recovery, cover traffic

- R6: devices with ML-DSA-65 (FIPS 204) sign every record and action with
  P-256 and ML-DSA; verifiers with ML-DSA refuse a stripped or invalid
  ML-DSA signature (hybridSignatureAccepted); hosts can require it
  (requirePostQuantum). Recovery secrets carry the ML-DSA key.
- R1: device records may bind a passkey (rp, origin, P-256 key). Hosts mark
  actions with requirePresence; the action then needs a user-verified
  WebAuthn assertion whose challenge is SHA-256 of the canonical action body
  (presenceSatisfied). Personas take their own passkey.
- R4: recoverPrism accepts a bus instead of records and rebuilds the log and
  persona logs from retained sealed sync by following rotations wrapped to
  the recovery device. Memory bus retains up to 256 messages per topic.
- R5: createSyncCadence and publishCover send one fixed-size message per
  tick, real or cover; receivers ignore cover messages.
- Device record checks generalized to optional kem, pqsign, presence fields.

Model: 2 definitions and 5 theorems added to Stitch.PrismId, verified under
the pinned SDK (39 modules). Security facet: 33 threats (PrismQuantumForgery
added; origin script, sync observation, recovery loss updated). 37 prism-id
tests pass on node 22 and node 24; npm test 456/456. Threat model gains a
section of designed next closures (D1-D5).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Le2ZWWHa47YS9u3wT
… recovery); relay bus implements retained

The bus contract now names retained(topic). createRelayBus's poll of the
warm relay becomes retained, so log-free recovery and offline catch-up read
stitch's relay. docs/prism-id.md says the relay's 30-minute warm lifetime
bounds both. product/contracts.json rebinds the implementation hash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
…ocations from, refreshing cadence

linkQr(uri) encodes a prism-link URI as an ISO/IEC 18004 QR code (byte
mode, level M, smallest version, lowest-penalty mask) and returns
{size, modules}. Checked against jsQR 1.4.0 over versions 1 to 38; the test
pins one vector's module digest and the finder patterns.

logTopic(prism) is a public topic derived from the prism id alone.
publishLog puts the signed public records there; heardLog merges what the
bus retains on it, skipping other prisms, oversize and malformed messages.
verifyAction takes { bus } and merges heardLog first, so a removed device
that never syncs is refused once another device published its removal.

createSyncCadence({ refresh }) sends a real sync and the public log every
refresh ticks, so the warm relay (30 minutes) keeps a recent copy while any
member is online.

docs/prism-id.md documents all three and lists what stays open (a replayed
old recovery, retention when every member is offline). The threat model is
left unchanged so the retained proof evidence holds; product/contracts.json
rebinds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
feat(prism-id): relay bus, link QR codes, public log for hosts, refreshing cadence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants