maxBase58InputLength top-level constant

int const maxBase58InputLength

Maximum accepted base58BtcDecode input length, in characters.

Base58 decoding is inherently O(n^2): every input character walks the whole accumulator. Left unbounded, a ~512,000-character string (small enough to hide inside a DID document) pins a single-threaded isolate for minutes, which is a denial-of-service vector for any caller that decodes attacker-supplied text.

Everything this package decodes is tiny: a multibase public key is a 2-byte multicodec prefix plus a 33-byte compressed point (~48 characters), and a base58btc CID is of the same order. 512 characters decodes ~375 bytes — roughly ten times the largest legitimate input — while bounding the worst-case decode to well under a millisecond.

Implementation

const maxBase58InputLength = 512;