genesis.py python
30 lines 875 B
Raw
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor ⚠ breaking 22 hours ago
1 """Ledger genesis constant and entry factory (§K9.7)."""
2
3 from __future__ import annotations
4
5 import hashlib
6 from datetime import datetime, timezone
7 from typing import Any
8
9 from tools.honesty.canonical import compute_entry_hash
10
11 _GENESIS_SEED = b"overseer-kit-honesty-ledger-v1"
12 GENESIS_PREV = hashlib.sha256(_GENESIS_SEED).hexdigest().lower()
13
14
15 def utc_now_z() -> str:
16 """Return ISO-8601 UTC timestamp with ``Z`` suffix."""
17 return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
18
19
20 def build_genesis_entry(ts: str | None = None) -> dict[str, Any]:
21 """Construct a genesis ledger entry with server-filled hashes."""
22 timestamp = ts or utc_now_z()
23 body: dict[str, Any] = {
24 "v": 1,
25 "ts": timestamp,
26 "kind": "genesis",
27 "prev_hash": GENESIS_PREV,
28 }
29 body["entry_hash"] = compute_entry_hash(body)
30 return body
File History 1 commit
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor 22 hours ago