The number of bytes written on success, equal to write_len. If negative, an error: TOO_SMALL — write_len is 0. TOO_BIG — write_len is greater than 512. OUT_OF_BOUNDS — pointers/lengths specified outside of hook memory. INVALID_ARGUMENT — min_tier is outside 1..4. TOO_LITTLE_ENTROPY — entropy is unavailable, stale, or below the specified min_tier.
Each call to entropy_cr_random() uses different derivation input, even within the same hook execution. The per-call input includes the entropy digest, ledger sequence, transaction ID, originating account, hook account, hook hash, chain position, strong/weak execution flag, callback/direct dispatch flag, and an incrementing call counter. Internally, 32-byte blocks are generated via sha512Half and then chained (sha512Half(previous_block)) for additional blocks. This ensures deterministic replay.