JouleBridgeDocs
Reference

Event Schema

ProofEnvelope structure, event types, COSE Sign1 format, and canonical JSON specification.

Event Schema

Every event processed by Bridge Kernel follows a strict schema from ingestion through proof generation to ledger persistence.

AdapterEvent

The raw event produced by an adapter after normalization:

{
  "sector": "power",
  "event_type": "meter_reading",
  "source": "inverter-site-a-01",
  "payload": {
    "voltage_v": 230.5,
    "current_a": 12.4,
    "power_kw": 3.1,
    "energy_kwh": 142.8
  },
  "timestamp": "2026-03-08T14:22:01Z",
  "dedupe_key": "inverter-site-a-01:2026-03-08T14:22:01Z"
}

Fields

FieldTypeRequiredDescription
sectorstringYesOperational domain: power, ev, storage, grid, logistics
event_typestringYesEvent semantic: meter_reading, session_end, dispatch, handover
sourcestringYesStable source identity (device ID, gateway ID)
payloadobjectYesSource data after adapter normalization
timestampISO 8601YesSource event time (UTC)
dedupe_keystringRecommendedSource-derived idempotency key

Canonical JSON

Before hashing and signing, events are serialized to canonical JSON:

  1. Sort keys alphabetically at every nesting level
  2. Remove whitespace — no spaces after colons or commas
  3. UTF-8 encoding — all strings normalized to UTF-8

Example:

{"current_a":12.4,"energy_kwh":142.8,"power_kw":3.1,"voltage_v":230.5}

This deterministic serialization ensures two nodes hash the same event bytes identically.

ProofEnvelope

The signed output after the proof pipeline:

{
  "event": { ... },
  "key_id": "key-93ac1f2e2ab1d001",
  "key_version": 4,
  "signature_context": "bridge-kernel-v2",
  "signer_public_key_hex": "9f8a...",
  "payload_hash_hex": "8af3c2b1e9d4f7a2...",
  "signature_hex": "b7e2f1c3d8a9...",
  "signed_at": "2026-03-08T14:22:01.123Z",
  "proof_metadata": {
    "canonical_algorithm": "json-sorted-keys-no-ws-utf8",
    "hash_algorithm": "sha-256",
    "signature_algorithm": "ed25519",
    "replay_window_seconds": 600,
    "node_id": "bridge-prod-site-a"
  }
}

ProofEnvelope fields

FieldTypeDescription
eventobjectThe original AdapterEvent
key_idstringSigning key identifier
key_versionintegerKey version for rotation tracking
signature_contextstringSigning context string
signer_public_key_hexstringEd25519 public key (hex)
payload_hash_hexstringSHA-256 hash of canonical JSON (hex)
signature_hexstringEd25519 signature (hex)
signed_atISO 8601Timestamp when proof was generated
proof_metadataobjectAlgorithms, parameters, and node identity

Verification

To verify a ProofEnvelope:

  1. Extract event and serialize to canonical JSON.
  2. Compute SHA-256 hash of the canonical bytes.
  3. Compare computed hash to payload_hash_hex.
  4. Verify Ed25519 signature_hex using signer_public_key_hex and signature_context.

If any step fails, the proof is invalid.

Ledger record

When persisted to SQLite, the ProofEnvelope is stored as a single row with indexed fields:

ColumnTypeIndexed
event_idTEXTYes (unique)
sectorTEXTYes
event_typeTEXTYes
sourceTEXTYes
timestampTEXTYes
payload_hash_hexTEXTYes
proof_envelopeJSONNo
syncedBOOLEANYes
created_atTEXTYes