Files
rand-tools/docs/ARCHITECTURE.md
T
zemion 4f61d001ab
Verify / verify (push) Canceled after 0s
Release Random Tools 0.2.0
2026-09-02 12:28:20 +02:00

12 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Architecture
Random Tools is a static React/Vite application wrapped in the shared Toolbox shell. `random/source.ts` exposes one common interface over two deliberately distinct local sources: browser WebCrypto with rejection-sampled integers, and the versioned `toolbox-helpers` xoshiro128** seeded generator. Secure mode never falls back to deterministic mode.
`random/generators.ts` builds bounded numbers, strings, identifiers, dice, samples, shuffles, passphrases and normal samples on that interface. `random/draws.ts` adds local binary coin flips, standard playing-card deals, shuffled inclusive integer sequences, Gregorian calendar-date sampling, exact decimal-digit fractions and equal-area points on a spherical surface model. Date sampling can filter weekdays and use a partial FisherYates mapping for selection without replacement; it does not allocate every date in a large range.
`random/weighted.ts` parses bounded two-column quoted CSV and ranks each item by an exponential-race key, yielding an exact weighted sample without replacement. `random/recipes.ts` validates a 2 MiB, schema-versioned executable recipe and runs it only through the deterministic source; every algorithm then applies its normal count/list/alphabet bounds. Recipe output includes the generator identity and state after execution.
`random/ceremony.ts` creates 32-byte WebCrypto reveal nonces. A SHA-256 commitment is domain-separated and binds the normalized ceremony ID, participant name and canonical unpadded Base64url nonce. Finalization validates every commitment, rejects duplicate/missing/changed entries, sorts normalized participant names by a locale-independent code-unit order, and hashes the complete verified reveal set under a separate final-seed domain. It cannot enforce the social publication order.
Each successful result includes source identity, parameters and deterministic state where applicable. Most operations are synchronous and bounded; custom word-list identity and ceremony hashes use the asynchronous browser Web Crypto digest API without a worker. Custom lists are trimmed, emptied lines are dropped and uniqueness is checked once before both selection and metadata are derived. Weighted input is capped at 100,000 items/4,000,000 UTF-16 units; recipes and ceremony documents at 2 MiB; ceremonies at 1,000 participants. The application contains no third-party network client; its CSP limits connections to its own origin for loading the local application shell.