Expand description
Origin-tagged entropy primitives for KDK. Every entropy buffer carries a phantom marker that records where the bytes came from.
Distinct sources are distinct types at compile time — DiceEntropy<6, 16>
cannot be handed to a function expecting DiceEntropy<20, 16>.
§Security
Entropy buffers wrap kdk_zeroize::SensitiveBytes. Anything that crate
guarantees, this one inherits.
Enums§
- Coin
- Origin marker for coin-flip entropy. A coin always has 2 sides.
- Deck
- Origin marker for card-deck entropy.
CARDSis the deck size; the entropy a full shuffle delivers islog₂(CARDS!)bits. - Dice
- Origin arker for dice entropy.
FACESis the die geometry — e.g.Dice<6>for a d6,Dice<20>for a d20. Distinct values yield distinct types at compile time. - Entropy
Error - Errors returned by
crate::dice_to_entropyand friends.
Functions§
- coin_
to_ entropy - Fold a sequence of coin flips into an
N-byte entropy buffer. - deck_
to_ entropy - Fold a sequence of drawn cards into an
N-byte entropy buffer. - dice_
to_ entropy - Fold a sequence of dice rolls into an
N-byte entropy buffer, byte-for-byte compatible with Krux upstream. - max_
draws - Practical upper bound on draw count —
2 * min_draws, capped atCARDS. - max_
flips - Practical upper bound on flip count — 2×
min_flips. - max_
rolls - Practical upper bound on roll count — 2×
min_rolls. - min_
draws - Minimum card draws required to fill an
N-byte entropy buffer from aCARDS-deck. Each entry is the smallestksuch thatlog₂(CARDS! / (CARDS-k)!) ≥ 8·N. - min_
flips - Minimum flips required to fill an
N-byte entropy buffer with a fair coin. - min_
rolls - Minimum rolls required to fill an
N-byte entropy buffer from aFACES-die. Values match Krux upstream byte-for-byte.
Type Aliases§
- Coin
Entropy - Coin-flip entropy.
Nis the buffer length in bytes. - Deck
Entropy - Deck-origin entropy.
CARDSis the card set game,Nthe buffer length in bytes. - Dice
Entropy - Dice-origin entropy.
FACESis the die geometry,Nthe buffer length in bytes.