# PIP-0026 · Signature vectors and conformance suite

A published file of vectors for canonical JSON, signed envelopes and request signatures; the definition of PATH in a request signature; and the suite that checks the open profiles from an operator's public surface, with no credential.

## Why

Every statement PATH signs is Ed25519 over canonical JSON ([Security](/docs/security)). Two implementations agree only when they produce the same bytes from the same object. This PIP publishes those bytes, and the suite that checks a public surface against the open profiles of [Conformance](/docs/conformance).

No signed object, call or register changes.

## The vectors file

`db/data/signing.vectors.json`, in the repository of the reference implementation. The conformance suite ships the same file at `vectors/signing.vectors.json`.

```json
{
  "version": 1,
  "note": "Every seed in this file is a published test key. It signs nothing outside these vectors.",
  "canonical": [
    { "name": "keys-utf16-order", "input": { "b": 1, "a": 2, "é": 3, "Z": 4 }, "canonical": "{\"Z\":4,\"a\":2,\"b\":1,\"é\":3}" }
  ],
  "envelopes": [
    {
      "name": "request-0.2.0",
      "protocol_version": "0.2.0",
      "seed_hex": "…",
      "public_key_hex": "…",
      "envelope": { "type": "path.request", "protocol_version": "0.2.0", "signed_at": "…", "kid": "vector-1", "signature": "…" },
      "signed_bytes": "…"
    }
  ],
  "requests": [
    {
      "name": "query-excluded",
      "method": "POST",
      "request_target": "/api/path/v1/risk/assess?a=1",
      "path": "/api/path/v1/risk/assess",
      "timestamp": "2026-11-20T10:00:00.000Z",
      "body": "…",
      "body_sha256": "…",
      "string_to_sign": "POST\n/api/path/v1/risk/assess\n2026-11-20T10:00:00.000Z\n…",
      "seed_hex": "…",
      "public_key_hex": "…",
      "signature": "…"
    }
  ]
}
```

| Section | Field | Meaning |
|---|---|---|
| `canonical[]` | `input` | A JSON value |
| | `canonical` | Its canonical JSON, as a string |
| `envelopes[]` | `envelope` | A signed envelope: `protocol_version`, `signed_at`, `kid` and `signature` beside the payload |
| | `signed_bytes` | The canonical JSON of `envelope` without `signature`: the bytes the signature covers |
| | `seed_hex`, `public_key_hex` | The Ed25519 test key that signed it |
| `requests[]` | `request_target` | The request-target as sent, query included |
| | `path`, `timestamp`, `body` | PATH, `Path-Timestamp` and the body as sent |
| | `body_sha256` | SHA-256 of the body bytes, lower-case hex |
| | `string_to_sign` | What `Path-Signature` covers |
| | `signature` | `Path-Signature` |

The seeds are published test keys. A verifier never accepts one of them outside these vectors.

### Cases

| Name | What it pins |
|---|---|
| `keys-utf16-order` | Keys sorted by UTF-16 code unit: ASCII, upper case, an accented letter, a key outside the Basic Multilingual Plane, U+FFFD |
| `nested-arrays` | Array order kept, objects inside arrays sorted |
| `null-members-kept` | A `null` member stays |
| `empty-object-and-array` | `{}` and `[]` |
| `numbers` | `0`, `-0` written `0`, `1.5`, `1e+21`, `100000000000000000000`, `1e-7`, `0.000001`, `-12345678901234`, `0.1` |
| `string-escapes` | `"`, `\`, `\n`, `\t`, `\u0007`, `\u001f` escaped; U+007F, U+2028, `/` and an emoji written as they are |
| `unicode-values` | No Unicode normalisation: a precomposed and a decomposed letter give different bytes |
| `deep-nesting` | Twenty-four levels of objects and arrays |
| `receipt-0.1.0` | A `path.receipt` signed `protocol_version` `0.1.0`, without `grammar` |
| `request-0.2.0` | A `path.request` in grammar 2 |
| `resolver-answer-0.2.0` | A `resolver_answer`, whose `commitment` is the digest of its terms ([PIP-0006](/pips/0006)) |
| `sonar-lookup` | A body digested as sent: spacing and key order included |
| `get-no-body` | No body: the digest of the empty string |
| `percent-encoded-path` | A path segment carrying `%3A`, kept encoded |
| `query-excluded` | A request-target with `?a=1`; the query is not part of PATH |

The canonical form is RFC 8785. Numbers follow the ECMAScript serialisation of a double. Strings escape `"`, `\` and U+0000 to U+001F, the latter as `\b`, `\t`, `\n`, `\f`, `\r` or `\u00xx` in lower case. No other character is escaped.

### How an implementation uses it

1. **Canonical.** Parse `input` with the implementation's JSON parser, canonicalise it, and compare the UTF-8 bytes with those of `canonical`.
2. **Envelopes.** Remove `signature` from `envelope`, canonicalise, and compare with `signed_bytes`. Verify `signature` with `public_key_hex`. Sign `signed_bytes` with `seed_hex`: Ed25519 is deterministic, and the result is `signature`.
3. **Requests.** Hash `body` and compare with `body_sha256`. Build `string_to_sign` from `method`, `path`, `timestamp` and `body_sha256`. Verify and sign as for envelopes.
4. **Values JSON cannot carry.** Each implementation tests them itself: a non-finite number is refused; where the language has an undefined value, an undefined array element is written `null` and an undefined member is left out.

A case never changes under the same `version`. A new case is added; changed bytes are a new version of the file.

## PATH in a request signature

`Path-Signature` is Ed25519 over `METHOD \n PATH \n TIMESTAMP \n SHA256(body)`.

| Part | Rule |
|---|---|
| `METHOD` | Upper case |
| `PATH` | The path of the request-target as sent: percent-encoding as sent, the operator's mount prefix included, the query excluded. No scheme, no host |
| `TIMESTAMP` | The `Path-Timestamp` header, as sent |
| `SHA256(body)` | Lower-case hex of the SHA-256 of the body bytes as sent. With no body, the digest of the empty string |

## The suite

`@pathprotocol/conformance`, command `path-conformance`, Node 20 or later.

```bash
npx @pathprotocol/conformance --target https://api.example.com --request 7fk2m9pq3vx8 --receipt q8w2e5r7t9y1u3i6o0p4as
```

| Flag | Meaning |
|---|---|
| `--target <origin>` | The origin that serves `GET /.well-known/path-configuration` |
| `--profiles <list>` | Comma-separated profiles. Default: `PATH-CORE.Discovery`, plus each profile a reference is given for |
| `--request <reference>` | A payment request served at `/path/<reference>` |
| `--receipt <reference>` | A receipt served at `/path/<reference>` |
| `--json` | The report as JSON |

The suite sends no credential. It calls the paths the protocol fixes and the absolute URLs of `endpoints`, and adds no mount prefix.

| Profile | Checks |
|---|---|
| `PATH-CORE.Discovery` | The document is served without credential; `protocol_versions`, `operator`, `endpoints` as absolute URLs; `endpoints.keys` is served; every key entry carries `kid`, `kty`, `crv`, `alg`, `use` and a 32-byte `public_key_hex`; kids are unique |
| `PATH-REQ.Link` | `GET /path/<reference>` with `Accept: application/json` answers a `path.request` with that reference, issued by the target's operator, carrying a `protocol_version` the target lists, `signed_at` and `kid`, and verifying against the issuer's keys |
| `PATH-SETTLE.Receipts` | The same for a `path.receipt`. When the target serves the receipt's transitions, each `supersedes` is the digest of the previous envelope, every envelope verifies, and the chain ends with the served receipt |

A profile this version does not check is reported as not checked. The exit code is `0` when at least one profile was checked and every checked profile passes, `1` otherwise, and `2` on a usage error.

A passing run by a third party is the level **Verified** of [Conformance](/docs/conformance).

## Interface

| Artefact | Change |
|---|---|
| `db/data/signing.vectors.json` | New, version 1 |
| `@pathprotocol/conformance` | New package, version 0.1.0 |

## Compatibility

Informational. No object, call or migration changes.

## Implementation

- `db/scripts/signing-vectors.ts` writes the file from the canonical serialiser of the reference implementation, with an Ed25519 and SHA-256 implementation independent of the one the API signs with. `--check` fails when the file differs.
- The reference implementation and `@pathprotocol/sdk` replay the file in their tests.
- The suite ships a copy, tested equal to `db/data/signing.vectors.json`, and replays it against the verifier it runs on.