Enterprise procurement and a SOC 2 audit eventually converge on the same uncomfortable question for any licensing vendor: prove that your record of what happened was not edited after the fact. An auditor is not satisfied that your database contains a row saying a license was revoked on the third of the month. They want evidence that the row was not written last week, back-dated, and slipped into the history to cover a dispute. For a system whose entire job is to be the authority on who is entitled to what, "trust our table" is not an answer.

The log is exactly the record someone would want to rewrite. A reseller who over-issued, an insider who quietly re-activated a revoked key, a contract fight where the whole case turns on what did the service do, and when — in each one, the audit trail is the target. So the real question is not how to store license events. It is: how do you hand a stranger the history of every activation, deactivation, seat move, and tier change, and let them prove, from first principles and without trusting you, that not one entry was altered, inserted, deleted, or reordered since it was written?

An event is a row the service seals

Keyright writes one event per state-changing operation. The exported shape carries no personal data — only a hash of the full payload, which stays behind the admin boundary:

public enum LicenseEventKind { Activated, Deactivated, SeatMoved, TierChanged, Revoked, Reinstated } public sealed record LicenseEvent( long Seq, // contiguous, 0-based, assigned by the service DateTimeOffset At, // service clock, authoritative LicenseEventKind Kind, Guid LicenseId, string Subject, // seat id, device fingerprint hash, or target tier string Actor, // "svc:fulfillment", "admin:jane" string PayloadHash); // sha256 of the full operation detail 

Two fields make the sequence tamper-evident. Seq is dense and gap-free — the service hands out 0, 1, 2… with no holes — so a missing number is itself a signal. And every event is hashed into a chain: entry N's stored hash is SHA-256(prevHash ‖ canonical(N)), where prevHash is entry N−1's hash and the genesis entry starts from 32 zero bytes. Because SHA-256 depends on every bit of its input, entry N's hash transitively commits to the whole history before it.

Canonical bytes, or the chain is a lie

The chain is only as trustworthy as the bytes you hash. If the verifier re-serializes an event with a different field order, a different timestamp format, or a JSON library that reorders keys, it computes a different hash and reports a break that never happened. The hash must be taken over a canonical encoding — the exact bytes the service hashed — so nothing is left to a serializer's whims:

using System.Buffers.Binary; using System.Globalization; using System.Security.Cryptography; using System.Text; static byte[] Canonicalize(LicenseEvent e) { // Frozen field order. Each field is length-prefixed so that // ("ab","c") and ("a","bc") can never hash to the same bytes. using var ms = new MemoryStream(); void Field(string s) { var b = Encoding.UTF8.GetBytes(s); Span<byte> len = stackalloc byte[4]; BinaryPrimitives.WriteUInt32BigEndian(len, (uint)b.Length); ms.Write(len); ms.Write(b); } Field(e.Seq.ToString(CultureInfo.InvariantCulture)); Field(e.At.ToUniversalTime().ToString("O", CultureInfo.InvariantCulture)); // ISO-8601 round-trip Field(((int)e.Kind).ToString(CultureInfo.InvariantCulture)); Field(e.LicenseId.ToString("N")); Field(e.Subject); Field(e.Actor); Field(e.PayloadHash); return ms.ToArray(); } static byte[] ComputeHash(byte[] prevHash, LicenseEvent e) { using var sha = SHA256.Create(); sha.TransformBlock(prevHash, 0, prevHash.Length, null, 0); var body = Canonicalize(e); sha.TransformFinalBlock(body, 0, body.Length); return sha.Hash!; } 

The length prefix is not decoration. Without it, an attacker could move a character from Actor into Subject and leave the concatenated bytes identical — the hash would not notice. Prefixing each field with its byte length makes the boundaries part of the input.

The signed head: attesting the tip

Chaining seals the past against editing, but a chain has an honest-looking weakness: a prefix of a valid chain is itself a valid chain. Delete the newest ten entries and what remains verifies perfectly. To defend the present, the issuing service signs the current tip — a tiny record naming where the chain ends:

public sealed record SignedChainHead(long Seq, string EntryHash, DateTimeOffset At) { public byte[] Signature { get; init; } = Array.Empty<byte>(); } 

The signature covers the head's canonical bytes bound to the chain id, so it attests "as of this time, this chain ends at this sequence with this hash." A verifier that holds that signed statement cannot be fooled by a truncated tail: the head names a sequence the shortened bundle never reaches.

Each event's hash becomes the next event's prevHash, so any edit, deletion, or reordering breaks every entry after it. The signed head pins where the chain must end, so truncating the newest entries is caught too.

The exportable audit bundle

An auditor should not need access to your admin API, your network, or your goodwill. Everything required to verify the history travels in one self-contained record:

public sealed record AuditBundle( string ChainId, // binds to this deployment; folded into the genesis hash byte[] GenesisPrevHash, // 32 zero bytes IReadOnlyList<LicenseEvent> Events, // contiguous, ascending by Seq IReadOnlyList<string> EntryHashes, // hex, one per event, exactly as stored SignedChainHead Head, string SigningKeyId); // which pinned public key verifies the head 

The bundle carries the events, the stored hash of each one, the signed head, and a key id — never the key itself. The verifier resolves that id to a public key it already pins out of band. The trust anchor lives with the auditor, not inside the document they are examining.

The offline SDK verifier

Here is the whole security model, and it runs with no network, no server, and no trust in the party who produced the bundle:

public enum AuditVerdict { Intact, Broken } public sealed record AuditResult(AuditVerdict Verdict, long? FirstBadSeq, string Reason); public static AuditResult Verify(AuditBundle b, Func<string, byte[]?> resolvePinnedKey) { // 1. The head must be signed by a key we already trust — never one from the bundle. var pub = resolvePinnedKey(b.SigningKeyId); if (pub is null) return new(AuditVerdict.Broken, b.Head.Seq, $"unknown signing key '{b.SigningKeyId}'"); if (!Ed25519.Verify(b.Head.Signature, CanonicalHead(b.ChainId, b.Head), pub)) return new(AuditVerdict.Broken, b.Head.Seq, "head signature invalid"); // 2. Walk the chain from genesis, recomputing every hash. var prev = b.GenesisPrevHash; long expectedSeq = b.Events.Count > 0 ? b.Events[0].Seq : 0; for (int i = 0; i < b.Events.Count; i++) { var e = b.Events[i]; if (e.Seq != expectedSeq) // insertion, deletion, reorder return new(AuditVerdict.Broken, e.Seq, $"sequence gap: expected {expectedSeq}"); var computed = ComputeHash(prev, e); var stored = Convert.FromHexString(b.EntryHashes[i]); if (!CryptographicOperations.FixedTimeEquals(computed, stored)) return new(AuditVerdict.Broken, e.Seq, "hash mismatch: entry altered or moved"); prev = computed; expectedSeq++; } // 3. The signed head must commit to the last entry we actually verified. var tipHex = Convert.ToHexString(prev).ToLowerInvariant(); if (b.Head.Seq != expectedSeq - 1 || !string.Equals(tipHex, b.Head.EntryHash, StringComparison.OrdinalIgnoreCase)) return new(AuditVerdict.Broken, b.Head.Seq, "head does not match the last entry: tail truncated"); return new(AuditVerdict.Intact, null, $"{b.Events.Count} events verified to seq {b.Head.Seq}"); } 

Three independent checks catch three different attacks. Editing any field — back-dating a revocation, renaming the actor, swapping a payload — changes that entry's hash, so step 2 fails at the altered sequence and every entry after it. Deleting or reordering an entry breaks both invariants at once: the dense Seq no longer lines up with expectedSeq, and the recomputed hash no longer matches because prevHash is now wrong. Truncating the tail passes the walk — a prefix is a valid chain — but step 3 catches it, because the signed head names sequence 43 and the shortened bundle's last verified hash does not match it. An insertion in the middle is the same as a reorder: it shifts every subsequent sequence number and corrupts every subsequent hash.

Notice what the verifier never does. It never asks the server whether the chain is valid. It never trusts the hashes in EntryHashes as authoritative — it recomputes them and compares. And it never trusts the key in the bundle — resolvePinnedKey is the auditor's own trust store. That is what makes the verdict defensible: it depends only on public keys the auditor already held and arithmetic they ran themselves.

How you wire it

Chaining is on for every state-changing operation. Export a range as a bundle over the admin API, hand it to the auditor with nothing else, and point them at the SDK's KeyrightAudit.Verify. Community Edition includes the chained event writer and the offline verifier; signed-head attestation and scheduled bundle export are tier-gated features. Pin the signing key the same way you pin the license-verification key (pinning the verification key) so the auditor's trust anchor matches your issuing key.

When this breaks, honestly

A broken verdict is not always an attack, and treating it as one trains your team to ignore the alert. A schema migration that adds a field to the canonical encoding rehashes everything after it — so you start a fresh chain segment at the boundary and sign the old head rather than re-hashing in place. A restore from backup that loses entries written after the snapshot is a real gap, but an expected one; the last signed head you exported tells the auditor exactly how many events are missing. And a non-monotonic clock can make At go backward without breaking a single hash — the chain commits to the order you wrote events, not to honest wall-clock time, which is precisely why time trust lives in the signed head and not in the per-event timestamp.

Takeaway

A licensing audit log earns an auditor's trust only when it defends itself. Chain every event to the hash of the one before it over a canonical, length-prefixed encoding; keep personal data out of the exported record by committing to a payload hash instead of the payload; sign the chain head so truncation cannot hide; and package events, stored hashes, and the signed head into one bundle a stranger can verify offline against a key they already pinned. The result is a history you can hand to SOC 2, to procurement, or to opposing counsel and prove, from first principles, that no activation, deactivation, seat move, or tier change was rewritten since the last moment anyone witnessed the tip. See the licensing model on the Keyright product page and the admin surface in the Keyright docs.