Update drp/canon.py
Browse files- drp/canon.py +2 -6
drp/canon.py
CHANGED
|
@@ -8,9 +8,7 @@ DRP_BUNDLE_SPEC = "drp-bundle-v0"
|
|
| 8 |
|
| 9 |
|
| 10 |
def canon(obj: Any) -> bytes:
|
| 11 |
-
"""
|
| 12 |
-
Canonical JSON encoding for stable hashing across machines.
|
| 13 |
-
"""
|
| 14 |
return json.dumps(
|
| 15 |
obj,
|
| 16 |
ensure_ascii=False,
|
|
@@ -28,9 +26,7 @@ def now_utc_iso() -> str:
|
|
| 28 |
|
| 29 |
|
| 30 |
def hash_event(event: Dict[str, Any]) -> str:
|
| 31 |
-
"""
|
| 32 |
-
Hash event excluding its own 'hash' field (if present).
|
| 33 |
-
"""
|
| 34 |
e = dict(event)
|
| 35 |
e.pop("hash", None)
|
| 36 |
return sha256_hex(canon(e))
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def canon(obj: Any) -> bytes:
|
| 11 |
+
"""Canonical JSON encoding (stable for hashing/verifying across machines)."""
|
|
|
|
|
|
|
| 12 |
return json.dumps(
|
| 13 |
obj,
|
| 14 |
ensure_ascii=False,
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
def hash_event(event: Dict[str, Any]) -> str:
|
| 29 |
+
"""Hash event excluding its own 'hash' field (if present)."""
|
|
|
|
|
|
|
| 30 |
e = dict(event)
|
| 31 |
e.pop("hash", None)
|
| 32 |
return sha256_hex(canon(e))
|