3. Canonicalization & Hashing
Why this matters
Canonical JSON (normative)
{"batch_id":"0x<32-byte>","device_id":"0x<32-byte>","end_ts":1698883200,"nonce":"0x<32-byte>","quantity_wh":10000,"start_ts":1698796800}From canonical JSON to hashes
evidenceHash = SHA-256( utf8(canonical_json) ) // bytes32, hex, 0x-prefixed, lowercasebytes32 claimId = keccak256(
abi.encodePacked(deviceId, startTs, endTs, quantityWh, evidenceHash)
);Where to canonicalize and sign
Common pitfalls (reject upstream)
Test vector (use in CI)
Helper code
Conformance (simple checklist)
Last updated
