<!-- XE-0059 · docs/openapi: chat read proof described two ways; following the /chat/auth/challenge description (raw bytes, no pub_key) fails with 403/401 (Minor) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0059>. The page is the record; this is the same page for reading.*

XE-0059 · Bounty

# docs/openapi: chat read proof described two ways; following the /chat/auth/challenge description (raw bytes, no pub\_key) fails with 403/401 (Minor)

Accepted
claimed Minor
[xe#80](https://github.com/xeprotocol/xe/issues/80)
filed 2026-10-26 20:44 UTC
by BoomGone

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Minor

Area
:   SDK / docs / web

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-10 11:38 UTC

Told
:   2026-11-10 00:15 UTC

### Patches

None linked.

### History

- [61397](https://bounty.xe.network/log/61397) 2026-11-10 00:15 UTC reply.mirrored
- [61354](https://bounty.xe.network/log/61354) 2026-11-10 00:15 UTC reply.sent
- [17824](https://bounty.xe.network/log/17824) 2026-11-07 16:08 UTC proposal.adopted
- [17823](https://bounty.xe.network/log/17823) 2026-11-07 16:08 UTC ticket.award
- [17822](https://bounty.xe.network/log/17822) 2026-11-07 16:08 UTC proposal.rejected
- [6891](https://bounty.xe.network/log/6891) 2026-11-05 13:45 UTC proposal.created
- [1816](https://bounty.xe.network/log/1816) 2026-11-02 19:16 UTC proposal.created
- [1470](https://bounty.xe.network/log/1470) 2026-11-02 10:11 UTC note.added
- [791](https://bounty.xe.network/log/791) 2026-10-29 14:22 UTC note.added
- [790](https://bounty.xe.network/log/790) 2026-10-29 14:22 UTC ticket.facts area
- [594](https://bounty.xe.network/log/594) 2026-10-29 14:04 UTC github.labels
- [463](https://bounty.xe.network/log/463) 2026-10-29 14:04 UTC ticket.status triaging → accepted

[Full history](https://bounty.xe.network/log?ref=XE-0059) · [JSON](https://bounty.xe.network/v1/tickets/XE-0059) · [markdown](https://bounty.xe.network/XE-0059.md)

### Report

- Suggested tier: Minor ("documentation errors")
- Area: docs and openapi.json for `GET /chat/auth/challenge`, `/chat/messages`, `/chat/contacts`, `/chat/events`
- Found: 2026-10-26, node `xe/92d83d1`, openapi.json 1.0.0

## Summary

The OpenAPI document and https://test.network/docs/api give two different recipes for the chat read ownership proof:

1. `getChatAuthChallenge` description: "Sign it with your account key (**ed25519 over the raw challenge bytes**) and pass **account, challenge, and sig**".
2. `sig` parameter and the `ownershipProof` security scheme: "ed25519 signature over **sha256("xe/chat-read-auth/v1\\0" \|\| challenge)**", with `pub_key` required.

The node implements only the second (`api/chat_auth.go`, `chatSignTarget`). Following the endpoint description, the first thing a developer reads, fails twice: the raw signature is refused with 403, and leaving out `pub_key` (as both the challenge and the `listChatMessages` descriptions suggest) is refused with 401\.

## Evidence

Tested on 2026-10-26 against our own empty inbox only, on `https://ldn.core.test.network` and `https://test.network/api/v1` (same result on both):

```
A raw challenge bytes (challenge description): 403 {"error":"ownership proof failed: signature verification failed"}
B sha256(domain||challenge) (sig parameter)  : 200 []
C as B but no pub_key (endpoint descriptions): 401 {"error":"chat read requires an ownership proof (pub_key + challenge + sig); GET /chat/auth/challenge first"}
```

Code (`api/chat_auth.go`, master `9787859`):

```
const chatAuthDomain = "xe/chat-read-auth/v1\x00"

func chatSignTarget(tokenBytes []byte) []byte {
	h := sha256.New()
	h.Write([]byte(chatAuthDomain))
	h.Write(tokenBytes)
	...
```

Places that say "raw challenge bytes" or omit `pub_key`:

- openapi.json, `GET /chat/auth/challenge` description
- openapi.json, `GET /chat/messages` description ("pass account, challenge, and sig")
- https://test.network/docs/api and llms-full.txt (same text, generated from the spec)

Places that are correct: the `sig` and `pub_key` parameter descriptions, the `ownershipProof` scheme, and the "Authentication" paragraph of the developer portal.

## Steps to reproduce

The script below reads the test seed from a local `.env`, signs a fresh challenge three ways and reads only the signer's own inbox.

Run with `python3 chat_auth_test.py https://ldn.core.test.network`.

```
# Test the documented chat read proofs against our own (empty) inbox only.
# The seed is read from .env and never printed.
import hashlib, json, sys, urllib.request, urllib.error, urllib.parse
from pathlib import Path
from nacl.signing import SigningKey

ENV = Path(".env")  # file with XE_TEST_SEED_HEX=<64 hex>
seed = bytes.fromhex([l.split("=", 1)[1] for l in ENV.read_text().splitlines() if l.startswith("XE_TEST_SEED_HEX=")][0])
sk = SigningKey(seed)
pub = bytes(sk.verify_key).hex()
acct = hashlib.sha256(b"xe/account/v1" + bytes(sk.verify_key)).hexdigest()
BASE = sys.argv[1]

def get(path):
    try:
        with urllib.request.urlopen(BASE + path, timeout=30) as r: return r.status, r.read().decode()
    except urllib.error.HTTPError as e: return e.code, e.read().decode()

def challenge():
    return json.loads(get("/chat/auth/challenge")[1])["challenge"]

def read(sig_target_fn, include_pub=True):
    ch = challenge()
    sig = sk.sign(sig_target_fn(bytes.fromhex(ch))).signature.hex()
    q = {"account": acct, "challenge": ch, "sig": sig}
    if include_pub: q["pub_key"] = pub
    s, b = get("/chat/messages?" + urllib.parse.urlencode(q)); return s, b[:160]

raw = lambda b: b
hashed = lambda b: hashlib.sha256(b"xe/chat-read-auth/v1\x00" + b).digest()
print("A raw challenge bytes (challenge description):", *read(raw))
print("B sha256(domain||challenge) (sig parameter)  :", *read(hashed))
print("C as B but no pub_key (endpoint descriptions):", *read(hashed, include_pub=False))
```

## Impact

Integrators following the endpoint description cannot read chat. Documentation only; replay protection was checked and works (a second use of a challenge returns `challenge already used`, and a challenge from one node is refused by another with `challenge not issued by this node`).

## Suggested fix

Change the challenge and `listChatMessages` descriptions to: "Sign sha256("xe/chat-read-auth/v1\\0" \|\| challenge bytes) with your account key and pass account, pub\_key, challenge and sig."

## Payout

XE address: `6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc` (same as #75).

### Thread

**XE desk**team2026-11-10 00:15 UTCgithub

Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is
updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0059.
