API — Configuration
{
"version": "1",
"fmt": { "export": "hex" }, // 'bytes' | 'hex' | 'base64'
"sign": {
"N": 5, // integer ≥ 2
"mode": "S", // 'S' | 'X'
"hash": "SHA-256", // built-in or custom ID
"originSize": 256, // bits; in X-mode == digest length
"pack": "simpleSig", // reserved for future layouts
/* custom digest (optional) */
"func": null, // async (Uint8Array) => Uint8Array | string
"output": "bytes", // 'bytes' | 'hex' | 'base64'
"size": null, // digest length (bits), recommended
"cdn": null // URL to lazy-load a hasher
},
/* bulk registration of multiple custom hashers */
"externalHashers": { }
}
Built-in hash IDs
"SHA-1", "SHA-256", "SHA-384", "SHA-512", "SHA3-256", "SHA3-512", "BLAKE3", "WHIRLPOOL".
Validation rules
-
X-mode requires
originSize == digestLength(hash). - Custom hashers must declare at least
funcorcdn, plusoutput.
Declaringsizeis strongly recommended (enforced at runtime).
Common errors (thrown)
-
Hasher <id> not registered— unknown hash ID or missing descriptor. -
Hasher <id> size mismatch— digest output length differs fromsize. -
Unsupported output <fmt>—outputnot in{bytes, hex, base64}.
verify()never throws; it returnsfalsefor integrity mismatches.