bech32.mb_decode

Synopsis

local bech32 = require 'bech32'

bech32.mb_decode(output: byte_span, input: byte_span) (1)
bech32.mb_decode(input: byte_span) -> byte_span (2)

Description

Repack bits.

Perform 5bit groups to 8bit groups conversion where each group — either 5bit or 8bit — is encoded as a single byte. 5bit groups only use the lower bits of a byte (meaning the highest possible value in each byte for the 5bit groups bytestream will be 0x1F). 8bit groups concatenate the lower bits from consecutive byte-encoded 5bit groups to create each byte (the value 0 is used as padding if necessary).

Raises an error on incomplete input (e.g. missing 5bit group to finish the last 8bit group, non-zero bits in the padding bits of a 5bit group, …​).