InvalidParameter when options is not an object,
when threshold or shareCount is not a usize (a safe non-negative
integer number or a bigint in [0, 2^64 - 1]), or when secret is
not a Uint8Array, in that order; then TooManyShares,
InvalidThreshold, SecretTooLong, SecretTooShort, SecretNotEvenLen,
checked in that order.
Split
secretintoshareCountshares, anythresholdof which recover it. The secret must be 16–32 bytes and even-length.With
threshold1 every share is a copy of the secret and no randomness is drawn. Otherwisethreshold - 2shares are drawn whole fromrng, thensecret.length - 4bytes for the digest share's tail; the remaining shares are interpolated. That draw order is wire. Draws go through rand'sfillRandomBytes, so rand's generator contract applies: a generator's own error propagates unwrapped, and one without a callablefillBytesfails at the first draw with rand'sRandErrorInvalidGenerator.