Virtual Method

OmniTransformerhash

Declaration

void
hash (
  OmniTransformer* self,
  OmniHasher* hasher
)

Description

Hash the transformer.

The resulting hash digest will be used to equate a transformer to another without needing access to subroutines specific to these transformers.

The following invariant must be upheld: (hash_input(xf1) == hash_input(xf2)) == xf1.eq(xf2)

where: - hash_input(xf) represents all bytes fed to hasher by xf.hash(hasher). - xf1 and xf2 are two Transformer instances, possibly crossing a process or software version boundary. When this boundary is crossed, xf1.eq(xf2) means equivalence only in a logical sense because it is impossible to actually perform this method call.

This requirement makes it unsafe to feed the following values:

  • Memory addresses
  • Hash digests generated through a standard mechanism provided by a programming language, such as Rust Hash, .NET GetHashCode

These values are often non-deterministic across processes and runtime versions. Furthermore, they have a relatively small entropy (40 bits for memory address, 32 bits for GetHashCode), making hash collision extremely likely.

A common pattern is to first feed a stable, unique 128-bit transformer type ID to hasher. This distinguishes different transformer implementations with otherwise equal property values.

The type ID is randomly generated, embedded in the source code, and kept unchanged as long as the transformer’s output behavior remains fixed (transformers are modeled as pure functions). It is regenerated whenever an implementation change can affect its output or serialized state, even if its properties are unchanged.

Parameters

hasher

Type: OmniHasher

No description available.

The data is owned by the caller of the method.