Bech32 convert bits
bech32-convert-bits · version 1.0.0 · Encoding & checksums · free, no key needed
Regroup integers between bit widths using BIP 173 rules, rejecting bad leftover padding.
Use when you need to: convert 8 bit bytes into 5 bit bech32 symbols · convert 5 bit symbols back into 8 bit bytes · regroup integers from one bit width to another.
Decide before calling
Read the versioned contract and the supported scope below. Reuse bech32-convert-bits@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use bech32-convert-bits@1.0.0 for convert 8 bit bytes into 5 bit bech32 symbols. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- convert 8 bit bytes into 5 bit bech32 symbols
- convert 5 bit symbols back into 8 bit bytes
- regroup integers from one bit width to another
- reject non-zero leftover padding
- bip 173 convertbits with an explicit pad flag
- zero-pad leftover bits when the pad flag is true
- change bit grouping without adding a checksum
- expand bytes to the bech32 symbol width
Not supported
- append or check a bech32 checksum
- parse an address string or human-readable part
- apply segwit witness version rules
- encode the Bech32 character set
Behavior
- Implements BIP 173 convertbits. from_bits and to_bits are integers 1 through 8. pad is required: true emits one final zero-padded symbol when bits remain; false rejects that remainder.
- Each input integer must be in 0 .. 2^from_bits-1. Negative zero, NaN, and Infinity are rejected. The input array is not modified.
- pad false fails with invalid_input reason invalid_padding when leftover bits are at least from_bits wide, or when the leftover bits are non-zero. Zero leftover narrower than from_bits is accepted.
- There is no checksum and no HRP. 8-to-5 with pad true is the grouping used before Bech32 encoding; 5-to-8 with pad false is the grouping used after decoding.
- More than 256 input items, or more than 1024 output items, is limit_exceeded. The input length is checked before item values.
- Disclaimer: format transform only; provides no confidentiality, integrity, or authenticity.
Input
data(array of integer, required): max items 256; each min 0; each max 255from_bits(integer, required): min 1; max 8to_bits(integer, required): min 1; max 8pad(boolean, required)
Output
data(array of integer, required): max items 1024; each min 0; each max 255to_bits(integer, required): min 1; max 8
Limits
- max items: 256
- max output items: 1024
Example
Request input:
{
"data": [],
"from_bits": 8,
"to_bits": 5,
"pad": true
}
Response:
{
"result": {
"data": [],
"to_bits": 5
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "bech32-convert-bits",
"version": "1.0.0",
"input": {
"data": [],
"from_bits": 8,
"to_bits": 5,
"pad": true
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/bech32-convert-bits/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"data":[],"from_bits":8,"to_bits":5,"pad":true}'
The machine-readable contract is at /v1/tools/bech32-convert-bits/versions/1.0.0.
CLI
node cli.mjs run bech32-convert-bits 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Bech32 encode: Encode lowercase HRP and 5-bit data as Bech32 or Bech32m text using that checksum.
- Bech32 decode: Decode Bech32 or Bech32m text into a lowercase HRP, 5-bit data, and the checksum variant.
- Bech32 validate: Check Bech32 or Bech32m text and return a reason, without throwing when the checksum fails.
- Pem envelope parse: Parse one RFC 7468 textual envelope into its label and lowercase hex bytes.
- Asn1 oid format: Format numeric object identifier arcs as dotted text or brace notation.
- Ct merkle root compute: Compute the RFC 6962 v1 domain-separated Merkle Tree Hash of raw leaves.