AshOnetime.Fingerprint (ash_onetime v0.6.0)

Copy Markdown View Source

Computes SHA-256 fingerprints over exact canonical bytes.

Summary

Functions

Computes the SHA-256 fingerprint over the exact canonical encoding of value.

Functions

compute(value, max_bytes \\ :infinity)

@spec compute(term(), pos_integer() | :infinity) ::
  {:ok, <<_::256>>} | {:error, AshOnetime.Error.t()}

Computes the SHA-256 fingerprint over the exact canonical encoding of value.

The fingerprint is the replay-binding digest: two admissions with the same logical key but different request bodies produce different fingerprints, so a stale response cannot replay against a mutated request. max_bytes (default :infinity) bounds the canonical encoding size; an oversized value returns {:error, :fingerprint_too_large} without hashing. Returns {:ok, <<32-byte digest>>}.