pub fn deck_to_entropy<const CARDS: u8, const N: usize>(
cards: &[u8],
) -> Result<DeckEntropy<CARDS, N>, EntropyError>Expand description
Fold a sequence of drawn cards into an N-byte entropy buffer.
Cards are formatted as decimal indices, hyphen-separated, SHA-256
hashed, then truncated to N bytes. Mirrors Krux’s d20 string
shape ("-".join) for multi-digit values.
§Example
use kdk_entropy::{deck_to_entropy, DeckEntropy};
use kdk_zeroize::prelude::*;
// SHA-256("0-1-2-3-...-24")[:16].
let cards: [u8; 25] = [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24,
];
let e: DeckEntropy<52, 16> = deck_to_entropy(&cards).unwrap();
assert_eq!(
e.expose_secret(),
&[
0x92, 0xe2, 0x92, 0xe3, 0x4c, 0x44, 0x48, 0xc1,
0x57, 0x73, 0x1a, 0xff, 0x3d, 0x40, 0x10, 0x38,
]
);