|
| 1 | +# Fog Envelope Canonicalization and Signing Profile (v0) |
| 2 | + |
| 3 | +This document defines the **recommended evidence profile** for FogVault and FogCompute envelopes until the rules are promoted into first-class schema constraints and ADRs. |
| 4 | + |
| 5 | +## Goals |
| 6 | + |
| 7 | +- deterministic hashing across heterogeneous nodes |
| 8 | +- small, auditable signing surface |
| 9 | +- stable content references independent of transport |
| 10 | +- explicit separation between content hashing, envelope hashing, and settlement logic |
| 11 | + |
| 12 | +## Canonicalization profile |
| 13 | + |
| 14 | +### 1. Canonical JSON |
| 15 | + |
| 16 | +For any JSON payload that is hashed or signed, implementations should: |
| 17 | + |
| 18 | +1. serialize with **JCS** (JSON Canonicalization Scheme; RFC 8785) |
| 19 | +2. encode as UTF-8 bytes |
| 20 | +3. hash with **SHA-256** |
| 21 | + |
| 22 | +This yields the canonical `payloadHash`. |
| 23 | + |
| 24 | +### 2. Content hashing |
| 25 | + |
| 26 | +Raw content referenced by `ContentRef` should be hashed over the raw bytes, not over JSON wrappers. The digest form should be: |
| 27 | + |
| 28 | +```text |
| 29 | +sha256:<lowercase-hex> |
| 30 | +``` |
| 31 | + |
| 32 | +### 3. Signature algorithm |
| 33 | + |
| 34 | +The default signature algorithm for Fog envelopes and receipts should be: |
| 35 | + |
| 36 | +- **Ed25519** for detached signatures |
| 37 | + |
| 38 | +Recommended signature field encoding: |
| 39 | + |
| 40 | +```text |
| 41 | +ed25519:<base64url-signature> |
| 42 | +``` |
| 43 | + |
| 44 | +### 4. Domain separation |
| 45 | + |
| 46 | +To avoid cross-object signature confusion, signers should sign a domain-separated preimage: |
| 47 | + |
| 48 | +```text |
| 49 | +SRCOS-FOG-V1\n |
| 50 | +<object-type>\n |
| 51 | +<object-id>\n |
| 52 | +<payload-hash> |
| 53 | +``` |
| 54 | + |
| 55 | +Where: |
| 56 | +- `<object-type>` is `TopicEnvelope` or `UsageReceipt` |
| 57 | +- `<object-id>` is the object URN |
| 58 | +- `<payload-hash>` is the canonical SHA-256 digest string |
| 59 | + |
| 60 | +### 5. Encryption metadata |
| 61 | + |
| 62 | +When envelopes are encrypted, the authenticated additional data (AAD) should bind at least: |
| 63 | + |
| 64 | +- `topicId` |
| 65 | +- `entryId` or `receiptId` |
| 66 | +- `keyEpoch` |
| 67 | +- `payloadType` |
| 68 | + |
| 69 | +Recommended default content cipher for topic payloads: |
| 70 | + |
| 71 | +- **XChaCha20-Poly1305** |
| 72 | + |
| 73 | +## Verification order |
| 74 | + |
| 75 | +### TopicEnvelope |
| 76 | + |
| 77 | +1. resolve and verify `ContentRef` digests if present |
| 78 | +2. canonicalize `payload` |
| 79 | +3. compute `payloadHash` |
| 80 | +4. verify detached signature |
| 81 | +5. only then evaluate topic semantics / policy |
| 82 | + |
| 83 | +### UsageReceipt |
| 84 | + |
| 85 | +1. canonicalize receipt body |
| 86 | +2. compute `receiptHash` |
| 87 | +3. verify detached signature |
| 88 | +4. verify referenced `WorkOrder` / output refs / settlement mapping |
| 89 | + |
| 90 | +## What this does not settle yet |
| 91 | + |
| 92 | +This v0 profile does **not** yet fix: |
| 93 | + |
| 94 | +- key distribution / rotation mechanics |
| 95 | +- threshold or multisignature receipts |
| 96 | +- CBOR/COSE variants |
| 97 | +- transport-layer framing |
| 98 | +- receipt notarization / timestamp authority integration |
| 99 | + |
| 100 | +Those should land in follow-up ADRs and schema revisions. |
0 commit comments