Skip to content

computeEntryHash

computeEntryHash<ChangesType>(entry, serializeChange): Promise<Uint8Array<ArrayBufferLike>>

Defined in: packages/core/src/acl-chain.ts:239

Compute the canonical hash of an ACLEntry.

Hashes only the entry’s payload fields (everything except the signature), so the hash is stable across signers and serialization round-trips. The resulting digest is used in two places:

  • As the value embedded in the next entry’s ACLEntry.parentHash field, forming the chain’s hash-linked backbone.
  • As an element of ACLChain’s internal _entryHashes array, which tracks the most recent entry’s hash so the next append can stamp the correct parentHash.

Note: this hash is not used as a deduplication key. _ingestEntryInternal deliberately does not deduplicate by hash — sequence-number and parent-hash checks enforce chain integrity instead.

The encoding is length-prefixed to avoid ambiguity between adjacent variable-length fields:

u32 BE sequenceNumber
u64 BE timestamp (only low 53 bits are meaningful in JS)
u32 BE parentHash.length || parentHash bytes
u32 BE signerKeyId.length || signerKeyId bytes
u32 BE change.length || change bytes

ChangesType

Omit<ACLEntry<ChangesType>, "signature">

The entry to hash. The signature field is ignored.

(change) => Uint8Array

Adapter that converts the opaque ChangesType into a Uint8Array for hashing.

Promise<Uint8Array<ArrayBufferLike>>