Skip to main content

Module bitmap

Module bitmap 

Source
Expand description

EVM-compatible uint256 bitmap operations and deterministic selection-group derivation.

Pure, anchor-free. Moved verbatim from the Molpha program’s utils/bitmap.rs (MolphaErrorDataUpdateError).

Functions§

bitmap_bit_set
Solidity uint256 layout: bit pos has weight 1 << pos, pos == 0 is the integer LSB.
bitmap_clear_bit
bitmap_is_subset
bitmap_is_subset_u256
sub ⊆ sup when both are already loaded as U256.
bitmap_load
EVM uint256 bitmap loaded from Solidity bytes32 (big-endian).
bitmap_popcount_evm
bitmap_set_bit
bitmap_store
Serialize an EVM uint256 bitmap to bytes32 for storage / hashing.
derive_group_bitmap
Port of NodeGroupBitmapLib.derive from the EVM reference.
effective_selection_size
Selection slot count: min(node_count, signatures_required + redundancy_buffer).
for_each_set_bit
Iterate set bit positions in ascending order (EVM signer order).
for_each_set_bit_u256
Visit set bits in ascending order; returns the peeled bitmap (zero when fully consumed).
get_index
Bitmap bit index of the signer at 0-based rank pos when signers are ordered by ascending bit index (same order as EVM Validator.verify combines pubkeys).
validate_bitmap_upper_bits_clear
validate_bitmap_upper_bits_clear_u256
Reject signers with bits outside [0, node_count).