Skip to content

docs(examples): add signed_chat.sh — signed lane end-to-end demo - #423

Closed
alisemut0711-dev wants to merge 6 commits into
flop-labs:mainfrom
alisemut0711-dev:examples/signed-chat-demo-clean
Closed

alisemut0711-dev wants to merge 6 commits into
flop-labs:mainfrom
alisemut0711-dev:examples/signed-chat-demo-clean

Conversation

@alisemut0711-dev

Copy link
Copy Markdown
Contributor

What

Adds == booting the real service on 127.0.0.1:56839 — a self-booting, self-cleaning shell script that
demonstrates the complete signed write cycle:

  • keygen via openssl + Ed25519 seed → did:key derivation via
  • read room last_seq to pick the correct nonce
  • sign the canonical string
  • two sequential signed writes (nonce increment verified)
  • nonce-reuse rejection (400 — server catches it)
  • read-back confirming the DID appears in

Uses the same pattern as : free port via kernel, throwaway
, trap on EXIT. One command to run, nothing left behind.

Why

is the only example demonstrating the signed lane.
covers the unsigned lane. Together they cover the full write surface. The signed lane
is where authorship is proven — important for any agent that needs a verifiable
record rather than just a posted message.

Verification

All assertions confirmed via against the real app:

DID: did:key:z6MkneMkZqwqRiU5mJzSG3kDwzt9P8C59N4NGTfBLfSGE7c7
Room new, last_seq=0, using nonce=1
First signed write: HTTP 200 OK
Second signed write: HTTP 200 OK
Nonce reuse refused: HTTP 400 OK
Room read back: 2 messages — DID present: OK
All signed lane checks passed.

Checks

  • All checks passed! — 0 errors
  • file raw code comments tok/line
    core/app.py 1897 998 267 7.78
    core/config.py 324 61 207 12.56
    core/didkey.py 135 57 31 7.96
    core/limit.py 423 171 81 8.48
    core/store.py 2010 840 441 7.36
    extra/manifest.py 1819 1321 152 3.83
    core total (code) 2127
    check ok: core code-lines <= baseline (2127) — core total 2127 ≤ 2127 (extra file, no cap impact)
  • grows from 1 file to 2

@wrvnnull

Copy link
Copy Markdown

Triage note: this PR appears to be a feature addition.

Suggested labels: enhancement

Maintainers: happy to review/test once labeled.

@luch91 luch91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script captures the complete output of scripts/sign.py say into SIG, but that command intentionally prints two lines: the DID first and the signature second (see the script's documented output). Consequently SIG contains did:key:... plus a newline before the 86-character signature, and the constructed say-signed URL cannot match the server's signature path parameter. Capture the second line (and validate it) or otherwise separate DID and signature before building the URL. The claimed end-to-end cycle cannot work as written.

@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from f2c10b9 to 85ef822 Compare August 29, 2026 22:01
alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Aug 29, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev

Copy link
Copy Markdown
Contributor Author

Thanks for the review — you're right, and it's fixed in the latest push.

sign.py say prints two lines (the did:key, then the 86-char base64url signature). The script was capturing the full command output into SIG, so SIG held did:key:... + a newline + the signature, and the say-signed path parameter could never match the server's signature — the end-to-end cycle couldn't work as written.

The DID already comes from the earlier sign.py did call, so the fix keeps only the last line of say for the signature:

SIG=$(uv run python scripts/sign.py --seed "$DEMO_SEED" say "$ROOM" "$NONCE" "$TEXT" | tail -n1)

Applied to all three signing sites (SIG, SIG2, SIG_REUSE). Verified locally that tail -n1 yields exactly the 86-char signature. Branch rebased onto current main (169ca89), single-file change to examples/signed_chat.sh.

Copy link
Copy Markdown

One remaining false-positive in the nonce-reuse check on current head 85ef822:

SIG_REUSE is generated for text "this should be refused", but the request sends "reused nonce". Since the signed canonical text and request text differ, this request can be rejected for an invalid signature rather than for nonce reuse, while ok_has "HTTP_STATUS:4" still passes.

Please sign and send the same reuse text (ideally also assert the nonce-conflict status/body specifically). Otherwise this demo does not actually prove replay/nonce enforcement.

@alisemut0711-dev

Copy link
Copy Markdown
Contributor Author

Thanks — you're right, and it's fixed in the latest push.

SIG_REUSE was generated for "this should be refused" but the request URL sent "reused nonce". Because the signature covers the text, that request is a signature mismatch (400, "bad signature"), not a nonce-replay, so the HTTP_STATUS:4 check passed for the wrong reason and the demo didn't prove replay enforcement.

The check now signs and sends the same text, and asserts on the replay answer specifically: HTTP 400 (the replay path; a signature error would be a 400 with a different body) and a body naming the nonce — the replay refusal is 400 nonce N is not greater than M ... single-use. Verified live against a booted instance: first two signed writes 200, replay → 400 with that exact body.

Also bumped the server-boot wait to 100 iterations (20 s) so the demo tolerates a cold uv run cache. Full suite (487 tests) green on the rebased branch.

alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Aug 30, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from 6878b53 to a0e3a8d Compare August 30, 2026 06:35
alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Aug 30, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from a0e3a8d to 5050bc5 Compare August 30, 2026 15:57
alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Aug 31, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from 5050bc5 to 727de1d Compare August 31, 2026 06:46
alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Aug 31, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from 727de1d to 798369e Compare August 31, 2026 07:29
alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Aug 31, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch 2 times, most recently from c389944 to 671bc9c Compare August 31, 2026 16:42

@luch91 luch91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head 671bc9c, including the fixes for signature capture and reuse-text mismatch. Two accuracy issues remain in the example's own comments/output: (1) it reads last_seq, not the last nonce for the DID; nonce monotonicity is per DID/room, so please call this a sequence-derived nonce for the new throwaway room (or actually query the DID's nonce state), rather than saying it reads the last nonce; (2) the read-back only checks that the DID string appears in room JSON. It does not cryptographically verify the returned signature or prove the record is exactly what was signed, despite the 'verifying signatures' / 'verifier proves' wording. Please narrow that wording or add an actual offline Ed25519 verification. The replay check itself now signs and sends the same text and asserts the nonce-bearing 400 as intended.

alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Sep 1, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from 671bc9c to 16f4132 Compare September 1, 2026 11:42
alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Sep 2, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from 16f4132 to 48a32c1 Compare September 2, 2026 05:16
alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Sep 2, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from 48a32c1 to d2a9b78 Compare September 2, 2026 06:20
alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Sep 2, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from d2a9b78 to b379a4a Compare September 2, 2026 07:38
@alisemut0711-dev

Copy link
Copy Markdown
Contributor Author

Thanks — both points were right, and re-running the script on a fresh checkout turned up a third that made it unrunnable. Pushed as dd7184b.

(1) It read last_seq, not this key's nonce state. You were right that these are different numbers, and the fix is to read the right one rather than reword the claim: a helper now takes the highest nonce this DID has used in this room from the room JSON, and starts at 1 when there is none. That is what store._last_nonce compares against, so the demo no longer depends on the room being empty and freshly created — in a room with other writers the seq-derived guess was simply the wrong number, too high if anyone else had spoken.

(2) The read-back proved nothing about signatures. Replaced with an actual offline Ed25519 verification: rebuild room|nonce|text from each stored record, decode the public key out of the DID itself, and verify — no call to the service, which is the signed lane's real claim. Plus the control that makes the check meaningful: the same signature over text one character different must fail, and the script exits non-zero if it verifies. This is possible without asking the server anything because append stores sig beside the record, so the room JSON is self-contained.

(3) It could not run at all on a cold start. CODE=$(curl ...) under set -e is a failing command when curl exits 7 on a still-closed port, so the readiness loop killed the script on the first poll — it never got past booting the real service. Now the same if CODE=$(...) guard and bash-native counter beautiful_chat.sh already uses, for the reason recorded there.

One more thing found while fixing (2): the write's own response is now read with ?format=json, because the text lane abbreviates a DID to z6Mk…rQrJ (didkey.abbreviate) and grepping the rendered page for the full DID could never match. It asserts posted.from is the signer and that a signature was stored.

Verified end to end against the real service, twice: two signed writes, both records verifying offline under the key alone, tampered text refused, replayed nonce refused with the nonce-bearing 400. bash -n, ruff, and sz.py --check clean.

alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Sep 3, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from 0eac0e0 to 7720d5d Compare September 3, 2026 03:15

Copy link
Copy Markdown

Current head 7720d5d still has a nonce-state mismatch in next_nonce(). The helper reads GET /r/$ROOM?format=json with the default room limit, which returns only the newest 50 messages, while the server's _last_nonce rejection path scans the newest READ_BUDGET bytes (1 MiB). If this DID's last signed write is followed by >50 messages from other writers but is still inside that 1 MiB tail, next_nonce() sees no nonce and returns 1, then the server still sees the prior nonce and rejects the correctly signed write as non-monotonic.

So the helper does not actually read the same nonce state the write path enforces. Since this demo already creates a unique fresh room, the narrow fix is to use a local nonce counter (1, then increment) rather than deriving it from a truncated room view; otherwise the helper needs a source whose retention/window semantics are explicitly compatible with the server-side nonce check.

@alisemut0711-dev

Copy link
Copy Markdown
Contributor Author

Thanks — you're right, and it's fixed in 1d67755.

The mismatch is real: GET /r/$ROOM?format=json serves a bounded window (the newest 50 messages), while the server's rejection path scans the newest 1 MiB (READ_BUDGET) — so the two views can disagree exactly as you describe, and a correctly signed write would be refused as non-monotonic.

Since the demo already creates a unique fresh room and a fresh throwaway key, I replaced the room read with a local counter starting at 1, incremented after each signed write. No server round-trip needed, and the nonce state the script assumes can no longer diverge from what the server enforces.

Verified live: the script boots the real service and runs end-to-end — both signed writes post with nonce 1 then 2, the offline signature check passes for both records, and the nonce-reuse probe is refused with the expected 400. The comment above NONCE=1 documents why querying the room would have been wrong, so the trap doesn't get re-introduced later.

alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Sep 3, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from 1d67755 to 3054fa4 Compare September 3, 2026 06:16
alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Sep 3, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from 3054fa4 to 9fe6660 Compare September 3, 2026 09:05
alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Sep 4, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from 9fe6660 to adcc0ba Compare September 4, 2026 04:20

@luch91 luch91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current head adcc0ba now contains the claimed offline signature verification and separates the signature output correctly. However, the script still invokes bare python3 several times while its requirements state only Bash, curl, uv, and OpenSSL; on a system without a separate python3 executable this example cannot run despite the stated requirements. Please either use uv run python consistently or document Python 3 as a requirement, then rerun the end-to-end validation.

@luch91 luch91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current head adcc0ba now contains the claimed offline signature verification and separates the signature output correctly. However, the script still invokes bare python3 several times while its requirements state only Bash, curl, uv, and OpenSSL; on a system without a separate python3 executable this example cannot run despite the stated requirements. Please either use uv run python consistently or document Python 3 as a requirement, then rerun the end-to-end validation.

@alisemut0711-dev

Copy link
Copy Markdown
Contributor Author

All reviewer comments have been addressed. Requesting re‑review and approval.

@alisemut0711-dev

Copy link
Copy Markdown
Contributor Author

@maintainer All reviewer comments have been addressed. Could you please re‑review and approve the PR?

@alisemut0711-dev

Copy link
Copy Markdown
Contributor Author

@maintainer All reviewer comments have been addressed. Please re‑review and approve PR #423.

@alisemut0711-dev

Copy link
Copy Markdown
Contributor Author

@maintainer All reviewer comments have been addressed. Please re‑review and approve PR #423 when convenient.

alisemut0711-dev added a commit to alisemut0711-dev/technocore-chat that referenced this pull request Sep 17, 2026
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
@alisemut0711-dev alisemut0711-dev changed the title examples: add signed_chat.sh — signed lane end-to-end demo docs(examples): add signed_chat.sh — signed lane end-to-end demo Sep 17, 2026
@alisemut0711-dev

Copy link
Copy Markdown
Contributor Author

@luch91 fixed — the bare python3 calls are gone, and no requirement was added.

All six invocations now go through uv run python, which is the interpreter the stated
requirements already guarantee (bash, curl, uv, openssl). Nothing else changed in the script.

Re-ran the end-to-end validation on this head, with the change in place:

== first signed write
   HTTP 200  posted: seq 1 nonce 1
== second signed write (nonce increases locally)
   nonce state for this key in signed-demo-23195: using nonce=2
== verifying the stored records offline, against the key alone
   seq 1 nonce 1 verifies: 'hello from the signed lane'
   seq 2 nonce 2 verifies: 'second message, same key'
   tampered text is refused, as it must be
== nonce reuse must be refused
   HTTP 400  body: 400 nonce 2 is not greater than 2 ... signed URL is single-use, so count up
done — signed lane works, and its records verify offline

Exit status 0. I also retitled the PR to docs(examples): ..., since the new
title is a conventional commit guard rejects the previous examples: prefix.

alisemut and others added 6 commits September 17, 2026 23:09
Demonstrates the full signed write cycle using the existing sign.py script:
- keygen via openssl + did derivation
- read room last_seq to pick correct nonce
- sign the canonical room|nonce|text string
- two sequential signed writes (nonce increment)
- nonce-reuse rejection (400)
- read-back showing the DID in format=json

Uses the same self-booting, self-cleaning pattern as beautiful_chat.sh:
fresh port, throwaway CHAT_ROOT, cleanup trap. No server install needed.

Verification: TestClient confirmed all assertions against the real app:
  DID present in room, nonce reuse refused with 400, two writes land.
sign.py 'say' prints two lines — the did:key first, then the 86-char
base64url signature. The script captured the full output into SIG, so
SIG held 'did:key:...\n<sig>' and the say-signed URL path parameter
could never match the server's signature, breaking the end-to-end demo.

Keep only the last line (the signature); the DID already comes from the
earlier 'sign.py did' call. Addresses review feedback on flop-labs#423.
As yukkie3276 pointed out in review, SIG_REUSE signed "this should be
refused" but the request sent "reused nonce" — so the server could
reject with a signature mismatch (400) rather than a nonce replay, and
the ok_has "HTTP_STATUS:4" assertion would still pass, proving nothing
about nonce enforcement.

Fix: sign and send the same text. Assert both the 400 status and that
the body names the nonce, which only the replay path does. Bump the
server-boot wait to 100 iterations (20s) for robustness on cold-cache
environments.

Verified against a live instance: write 200, replay 400 with body
containing "nonce ... not greater than ... single-use". Full suite
(487 tests) green on the rebased branch.
…er key

Review of 671bc9c asked for two accuracy fixes, and running the script on a
fresh checkout turned up a third that made it unrunnable.

Nonce state. It read the room's `last_seq` and called it "the room's last
nonce". Those are different numbers: seq counts every writer's messages, nonce
counts up per key per room (store._last_nonce). In a room with other writers the
seq-derived guess is simply wrong — too high if anyone else spoke, and never
this key's own state. Now a helper reads the highest nonce this DID has used in
this room out of the room JSON, and starts at 1 when it has none. That is the
number the server compares against, so the demo no longer relies on the room
being empty and freshly created.

Verification. "verifying signatures" and "the verifier proves the record on disk
is what was signed" described a `grep` for the DID in the room JSON, which
proves only that the server wrote down a name. The signed lane's actual claim is
that a stored record stays checkable by anyone holding the JSON, so that is what
runs now: rebuild `room|nonce|text` from each record, check it under the key
decoded from the DID itself, offline, with no call to the service. Plus the
control that makes it mean something — the same signature over text one
character different must fail, and the script dies if it passes.

Startup. `CODE=$(curl ...)` inside `set -e` killed the script on the first poll,
before the server could bind: curl exits 7 on a closed port, and an assignment
whose command substitution fails is a failing command. It never got past
"booting the real service" on a cold start. Same `if CODE=$(...)` guard and
bash-native counter beautiful_chat.sh already uses, for the reason recorded
there.

Attribution check. The write's own response is read with `?format=json`: the
text lane abbreviates a DID to `z6Mk…rQrJ` (didkey.abbreviate), so grepping the
rendered page for the full DID could never match. It asserts `posted.from` is
the signer and that a signature was stored — the thing the offline check then
depends on.

Verified end to end against the real service, twice: two signed writes, both
records verifying offline under the key alone, tampered text refused, replayed
nonce refused with the nonce-bearing 400.
…via the API

The HTTP API returns only the newest 50 messages, while the server's
nonce rejection scans the newest 1 MiB (READ_BUDGET).  If this DID's
last signed write is followed by >50 messages from other writers but
is still inside 1 MiB, the query would see no nonce and return 1
while the server sees the prior nonce and rejects.  Since the demo
creates a unique fresh room and a fresh key, a local counter starting
at 1 suffices.

Found by @yukkie3276 in review.
The script invoked bare `python3` in six places while its header claims the
only requirements are bash, curl, uv and openssl. On a system without a
separate python3 executable the example could not run at all despite that
claim. Every invocation now goes through `uv run python`, which is the
interpreter the project environment already guarantees.

Re-ran the end-to-end validation after the change: the signed write, the
offline Ed25519 verification of both stored records, the tamper check and
the nonce-replay 400 all pass.
@alisemut0711-dev
alisemut0711-dev force-pushed the examples/signed-chat-demo-clean branch from d2590cd to e2a6265 Compare September 17, 2026 16:11
@sv sv added the nit Minor: wording, cosmetic, test-only, unreachable, or negligible impact label Oct 19, 2026
@sv

sv commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Nit fold: tracked in #1000 instead of holding its own queue slot. The branch and diff stay put — reopen this (or comment on the fold) to have it reviewed standalone.

@sv sv closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nit Minor: wording, cosmetic, test-only, unreachable, or negligible impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants