Invocie

Tech

변조 방지 감사 추적을 위한 해시 체인

ZATCA는 이를 의무화하고, EU 감사인들이 좋아하며, 구현 비용도 저렴합니다. 체인화된 SHA-256이 인보이스 원장을 무결성을 증명할 수 있는 무언가로 어떻게 바꾸는지 살펴봅니다.

Invocie Team · 2026년 1월 8일 · 5 분 분량


A tamper-evident audit trail is one where any modification to historical data is detectable. The classic technique — borrowed from blockchain but vastly simpler — is the hash chain: each record contains the cryptographic hash of the previous one. Mess with any historical record and every subsequent hash changes.

The recipe

For each invoice, compute:

hash_n = SHA256(prev_hash || canonicalize(payload_n))

// where canonicalize() produces a deterministic byte sequence
// (sorted keys, no whitespace, stable number formatting).

Store the hash on the invoice itself. To prove the integrity of any single invoice, you only need to verify that its hash equals the recomputed hash given the prior invoice's hash and the canonicalized payload. ZATCA Phase-2 mandates exactly this scheme.

Why canonicalization is everything

Two byte-different JSON serializations of the same logical object produce different hashes. RFC 8785 (JCS — JSON Canonicalization Scheme) is the standard approach: keys are sorted lexicographically, no insignificant whitespace, numbers in shortest unique form, strings escaped per RFC 8259.

Per-tenant chains, not global

Run a separate chain per tenant rather than one global chain. Two reasons: (1) you can shard storage and compute per tenant without coordinating writes, and (2) a corruption in one tenant's chain doesn't poison everyone's audit trail.

Verifying after the fact

An auditor (or you, defensively) can replay the chain from genesis: hash the first invoice's payload with no prev_hash, check it matches the stored hash, then iterate. Any deviation localizes the tampered record. Web Crypto's subtle.digest gives you SHA-256 in any modern runtime — Node, Deno, or the browser.

Invocie writes a chained hash on every invoice and on every ComplianceLog entry. The two chains are independent: invoices for ZATCA-style proof, logs for operational audit.


관련 글

다지역 e-invoicing API 설계: 현장에서 얻은 교훈

clearance와 post-audit 국가를 동시에 지원하는 인프라를 만든다면, 추상화를 제대로 잡을 기회는 한 번뿐입니다. 우리가 어렵게 얻은 교훈을 공유합니다.

Integrating UAE E-Invoicing With Your ERP: A Technical Guide

A technical walkthrough for the Head of IT and ERP transformation lead: how UAE PINT maps onto SAP, Oracle, Microsoft Dynamics, and custom ERPs, the data you must clean first, and the integration patterns that survive production.

UBL 2.1 쉬운 말로: 현대 전자세금계산서를 떠받치는 XML 표준

세계의 거의 모든 주요 e-invoicing 의무 규정은 내부적으로 UBL 2.1을 내놓습니다. 정말 이해해야 할 부분만 전문 용어 없이 안내합니다.

모든 시장에서 컴플라이언트한 청구서 발행

ZATCA, FTA, Peppol과 글로벌 사후 감사 — 단일 API.

팀에 문의