Repository navigation
docs(examples): add signed_chat.sh — signed lane end-to-end demo - #423
alisemut0711-dev wants to merge 6 commits into
Conversation
|
Triage note: this PR appears to be a feature addition. Suggested labels: Maintainers: happy to review/test once labeled. |
luch91
left a comment
There was a problem hiding this comment.
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.
f2c10b9 to
85ef822
Compare
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.
|
Thanks for the review — you're right, and it's fixed in the latest push.
The DID already comes from the earlier SIG=$(uv run python scripts/sign.py --seed "$DEMO_SEED" say "$ROOM" "$NONCE" "$TEXT" | tail -n1)Applied to all three signing sites ( |
|
One remaining false-positive in the nonce-reuse check on current head
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. |
|
Thanks — you're right, and it's fixed in the latest push.
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 Also bumped the server-boot wait to 100 iterations (20 s) so the demo tolerates a cold |
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.
6878b53 to
a0e3a8d
Compare
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.
a0e3a8d to
5050bc5
Compare
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.
5050bc5 to
727de1d
Compare
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.
727de1d to
798369e
Compare
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.
c389944 to
671bc9c
Compare
luch91
left a comment
There was a problem hiding this comment.
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.
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.
671bc9c to
16f4132
Compare
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.
16f4132 to
48a32c1
Compare
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.
48a32c1 to
d2a9b78
Compare
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.
d2a9b78 to
b379a4a
Compare
|
Thanks — both points were right, and re-running the script on a fresh checkout turned up a third that made it unrunnable. Pushed as (1) It read (2) The read-back proved nothing about signatures. Replaced with an actual offline Ed25519 verification: rebuild (3) It could not run at all on a cold start. One more thing found while fixing (2): the write's own response is now read with 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. |
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.
0eac0e0 to
7720d5d
Compare
|
Current head 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. |
|
Thanks — you're right, and it's fixed in The mismatch is real: 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 |
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.
1d67755 to
3054fa4
Compare
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.
3054fa4 to
9fe6660
Compare
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.
9fe6660 to
adcc0ba
Compare
luch91
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
|
All reviewer comments have been addressed. Requesting re‑review and approval. |
|
@maintainer All reviewer comments have been addressed. Could you please re‑review and approve the PR? |
|
@maintainer All reviewer comments have been addressed. Please re‑review and approve PR #423. |
|
@maintainer All reviewer comments have been addressed. Please re‑review and approve PR #423 when convenient. |
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.
|
@luch91 fixed — the bare All six invocations now go through Re-ran the end-to-end validation on this head, with the change in place: Exit status 0. I also retitled the PR to |
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.
d2590cd to
e2a6265
Compare
|
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. |
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:
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:
Checks
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)