Skip to main content

wots_encode

Function wots_encode 

Source
pub fn wots_encode(
    message: &Message,
    epoch: u32,
    public_param: &PublicParam,
    randomness: &Randomness,
) -> Option<[u8; 42]>
Expand description

The target-sum encoding.

D is the encoding hash of message | randomness, truncated to 16 bytes. Each of its two little-endian 64-bit words holds 21 digits of W bits: digit i < 21 at bits 3i of word 0, digit i >= 21 at bits 3(i - 21) of word 1.

The encoding is valid exactly when the leftover top bit of each word (bits 63 and 127) is zero and the digits sum to TARGET_SUM. Grinding the top bits to zero makes each word exactly sum(e_i * 2^{3i}) over its 21 digits, so both words decompose into digits with no slack term.

Returns None when the randomness does not produce a valid encoding, which is the signal the grinding loop retries on.