Documentation / @etherfold/core / canonical_form
Function: canonical_form() ​
canonical_form(
obj):string
Defined in: packages/core/src/utils/hash.ts:50
The BYTES a digest of this value is taken over: key-sorted, whitespace-free, undefined dropped, BigInts stringified with an n suffix.
Extracted from simple_hash rather than copied, because a second canonicalisation is a second answer to "are these two values the same": the stream digest (stream/identity.ts) takes a WIDE hash over these same bytes, and two normalisations that disagreed anywhere would make one digest move where the other did not. A string passes through untouched, which is what makes hashing an already-canonical value idempotent.
Note what changing this would cost: every digest ever computed, and digests are persisted.
Parameters ​
obj ​
any
Returns ​
string