Skip to main content

Crate kdk_entropy

Crate kdk_entropy 

Source
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. CARDS is the deck size; the entropy a full shuffle delivers is log₂(CARDS!) bits.
Dice
Origin arker for dice entropy. FACES is the die geometry — e.g. Dice<6> for a d6, Dice<20> for a d20. Distinct values yield distinct types at compile time.
EntropyError
Errors returned by crate::dice_to_entropy and 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 at CARDS.
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 a CARDS-deck. Each entry is the smallest k such that log₂(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 a FACES-die. Values match Krux upstream byte-for-byte.

Type Aliases§

CoinEntropy
Coin-flip entropy. N is the buffer length in bytes.
DeckEntropy
Deck-origin entropy. CARDS is the card set game, N the buffer length in bytes.
DiceEntropy
Dice-origin entropy. FACES is the die geometry, N the buffer length in bytes.