Verifying Answers¶
An answer from a graph service can be checked at three levels. graphctl does the first automatically.
1. The answer is authentic¶
Every answer has this form:
{
"service": "<public key of the service>",
"payload": {
"v": "datagraph/response/1",
"nonce": "<the nonce you sent>",
"ts": 1796118743997,
"request": "GET /v1/node?id=agent%3Aann",
"basis": [{"graph": "<author>/social/main", "version": 1, "manifest": "<event id>", "root": "<hex>", "size": 13}],
"result": {}
},
"sig": "<BIP-340 signature>"
}
To verify it:
- Compute SHA-256 over the bytes
datagraph/response/1|followed by the exact bytes ofpayloadas received. - Check
sigagainstservicewith BIP-340 Schnorr, and thatserviceis the key you expect. - Check that
nonceis yours andrequestis your request. - Check that
tsis within two minutes of your clock.
request is the method and path, then the query parameters sorted by name without the nonce, and for POST the SHA-256 of the body.
2. The statement is part of the graph¶
proof returns the statements about a node or an edge with a Merkle inclusion proof for each:
graphctl get -op proof -graph "$GRAPHS" -arg id=agent:bob
graphctl get -op proof -graph "$GRAPHS" -arg edge=FOLLOWS -arg from=agent:ann -arg to=agent:bob
A statement is the array [source, node, labels, edge, from, to, key, props]. Its leaf is SHA-256(0x00 || statement bytes), and inner nodes are SHA-256(0x01 || left || right), as in RFC 6962. The proof must lead to the root in basis. graphctl checks this and fails if it does not, or if there is no such statement.
A proof shows that a statement is included. It does not show that a statement is absent, or that a query result is complete.
3. The graph is what the author published¶
audit trusts neither the service nor its root. It reads the registry itself from several indexers, downloads and checks every segment, builds the graph and compares the root:
graphctl audit -graph "$GRAPHS" -relay ws://registry-relay-0:8080 -relay ws://registry-relay-1:8080
It prints both states and exits with status 1 if they differ. A difference can also mean that one side has not yet seen a new version, so compare version first and run it again.
Once the root is known to be right, you can recompute any query result locally, or compare the answers of several services that report the same root.
What is trusted¶
| Property | Depends on |
|---|---|
| A statement was made by the author | The author's signature on the asset and manifest, and the content hash |
| The newest version is used | The indexers, relays and watchdogs the reader consults, and rollback protection in graphd |
| A query was evaluated correctly | The service, unless you audit the root and repeat the query |