bech32-0.11.0/.cargo_vcs_info.json0000644000000001360000000000100121610ustar { "git": { "sha1": "c2aac494b9932802b99ed648aac34be0822d63e1" }, "path_in_vcs": "" }bech32-0.11.0/.github/workflows/fuzz.yml000064400000000000000000000027651046102023000161010ustar 00000000000000name: Fuzz on: [push, pull_request] jobs: fuzz: if: ${{ !github.event.act }} runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: fuzz_target: [decode_rnd, encode_decode, parse_hrp] steps: - name: Install test dependencies run: sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev - uses: actions/checkout@v2 - uses: actions/cache@v2 id: cache-fuzz with: path: | ~/.cargo/bin fuzz/target target key: cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} - name: Checkout Toolchain uses: dtolnay/rust-toolchain@stable - name: fuzz run: cd fuzz && ./fuzz.sh "${{ matrix.fuzz_target }}" - run: echo "${{ matrix.fuzz_target }}.rs" >executed_${{ matrix.fuzz_target }} - uses: actions/upload-artifact@v2 with: name: executed_${{ matrix.fuzz_target }} path: executed_${{ matrix.fuzz_target }} verify-execution: if: ${{ !github.event.act }} needs: fuzz runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/download-artifact@v2 - name: Display structure of downloaded files run: ls -R - run: find executed_* -type f -exec cat {} + | sort > executed - run: ls fuzz/fuzz_targets | sort > expected - run: diff expected executed bech32-0.11.0/.github/workflows/rust.yml000064400000000000000000000111321046102023000160640ustar 00000000000000on: [push, pull_request] name: Continuous Integration jobs: Stable: name: Test - stable toolchain runs-on: ubuntu-latest strategy: fail-fast: false steps: - name: Checkout Crate uses: actions/checkout@v3 - name: Checkout Toolchain # https://github.com/dtolnay/rust-toolchain uses: dtolnay/rust-toolchain@stable - name: Running test script env: DO_LINT: true DO_DOCS: true DO_FEATURE_MATRIX: true run: ./contrib/test.sh Beta: name: Test - beta toolchain runs-on: ubuntu-latest strategy: fail-fast: false steps: - name: Checkout Crate uses: actions/checkout@v3 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@beta - name: Running test script env: DO_FEATURE_MATRIX: true run: ./contrib/test.sh Nightly: name: Test - nightly toolchain runs-on: ubuntu-latest strategy: fail-fast: false steps: - name: Checkout Crate uses: actions/checkout@v3 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@nightly - name: Running test script env: DO_DOCSRS: true DO_FMT: true DO_BENCH: true run: ./contrib/test.sh MSRV: name: Test - 1.48.0 toolchain runs-on: ubuntu-latest strategy: fail-fast: false steps: - name: Checkout Crate uses: actions/checkout@v3 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@1.48.0 - name: Running test script env: DO_FEATURE_MATRIX: true run: ./contrib/test.sh EmbeddedWithAlloc: name: no_std with alloc runs-on: ubuntu-latest strategy: fail-fast: false steps: - name: Checkout Crate uses: actions/checkout@v3 - name: Set up QEMU run: sudo apt update && sudo apt install -y qemu-system-arm gcc-arm-none-eabi - name: Checkout Toolchain uses: dtolnay/rust-toolchain@nightly with: targets: thumbv7m-none-eabi - name: Run env: RUSTFLAGS: "-C link-arg=-Tlink.x" CARGO_TARGET_THUMBV7M_NONE_EABI_RUNNER: "qemu-system-arm -cpu cortex-m3 -machine mps2-an385 -nographic -semihosting-config enable=on,target=native -kernel" run: cd embedded/with-allocator && cargo run --target thumbv7m-none-eabi EmbeddedNoAlloc: name: no_std no alloc runs-on: ubuntu-latest strategy: fail-fast: false steps: - name: Checkout Crate uses: actions/checkout@v3 - name: Set up QEMU run: sudo apt update && sudo apt install -y qemu-system-arm gcc-arm-none-eabi - name: Checkout Toolchain uses: dtolnay/rust-toolchain@nightly with: targets: thumbv7m-none-eabi - name: Run env: RUSTFLAGS: "-C link-arg=-Tlink.x" CARGO_TARGET_THUMBV7M_NONE_EABI_RUNNER: "qemu-system-arm -cpu cortex-m3 -machine mps2-an385 -nographic -semihosting-config enable=on,target=native -kernel" run: cd embedded/no-allocator && cargo run --target thumbv7m-none-eabi Arch32bit: name: Test 32-bit version runs-on: ubuntu-latest steps: - name: Checkout Crate uses: actions/checkout@v3 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@stable - name: Add architecture i386 run: sudo dpkg --add-architecture i386 - name: Install i686 gcc run: sudo apt-get update -y && sudo apt-get install -y gcc-multilib - name: Install target run: rustup target add i686-unknown-linux-gnu - name: Run tests on i686 run: cargo test --target i686-unknown-linux-gnu Cross: name: Cross test if: ${{ !github.event.act }} runs-on: ubuntu-latest steps: - name: Checkout Crate uses: actions/checkout@v3 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@stable - name: Install target run: rustup target add s390x-unknown-linux-gnu - name: install cross run: cargo install cross --locked - name: run cross test run: cross test --target s390x-unknown-linux-gnu API: name: Check for changes to the public API runs-on: ubuntu-latest strategy: fail-fast: false steps: - name: Checkout Crate uses: actions/checkout@v3 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@nightly - name: Install cargo-public-api run: cargo install --locked cargo-public-api - name: Running API checker script run: ./contrib/check-for-api-changes.sh bech32-0.11.0/.gitignore000064400000000000000000000002371046102023000127430ustar 00000000000000**/target *.o /Cargo.lock /embedded/no-allocator/Cargo.lock /embedded/no-allocator/.cargo /embedded/with-allocator/Cargo.lock /embedded/with-allocator/.cargo bech32-0.11.0/CHANGELOG.md000064400000000000000000000027501046102023000125660ustar 00000000000000# 0.11.0 - 2024-02-23 The `0.10.0` release contains API breaking changes compared to `0.10.0-beta` and because of semver rules (which we adhere to) cannot be released with that version number, we had to yank it and re-do the release as `0.11.0` - sorry. # 0.10.0 - 2024-02-22 - yanked Release the new `primitives` module! This release is a total re-write of the crate - enjoy. Right before doing this release we added a few API improvements to the `primitives::decode` module: - Add accessor functions to the `decode` types [#167](https://github.com/rust-bitcoin/rust-bech32/pull/167) - Add `CheckedHrpstring::fe32_iter` function [#174](https://github.com/rust-bitcoin/rust-bech32/pull/174) - Make a couple of the functions on `CheckedHrpstring` struct public [#173](https://github.com/rust-bitcoin/rust-bech32/pull/173) # 0.10.0-beta Re-implement the crate level API using the new `primitives` module. # 0.10.0-alpha This release introduces a new `primitives` module that is basically a new implementation of the whole crate. We also add a `segwit` module but we have not yet settled on the exact new API in `lib.rs`, hence the `alpha` release. # 0.9.1 - [Support bech32 encoding without a checksum](https://github.com/rust-bitcoin/rust-bech32/pull/66) # 0.9.0 - [Enable edition 2018](https://github.com/rust-bitcoin/rust-bech32/pull/57) bumping MSRV to 1.41.1 - [Implement `From for u8`](https://github.com/rust-bitcoin/rust-bech32/pull/58) bech32-0.11.0/Cargo.toml0000644000000021270000000000100101610ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "bech32" version = "0.11.0" authors = [ "Clark Moody", "Andrew Poelstra", "Tobin Harding", ] description = "Encodes and decodes the Bech32 format and implements the bech32 and bech32m checksums" documentation = "https://docs.rs/bech32/" readme = "README.md" keywords = [ "base32", "encoding", "bech32", "bitcoin", "cryptocurrency", ] categories = [ "encoding", "cryptography::cryptocurrencies", ] license = "MIT" repository = "https://github.com/rust-bitcoin/rust-bech32" [features] alloc = [] default = ["std"] std = ["alloc"] [target."cfg(mutate)".dev-dependencies] bech32-0.11.0/Cargo.toml.orig000064400000000000000000000012131046102023000136350ustar 00000000000000[package] name = "bech32" version = "0.11.0" authors = ["Clark Moody", "Andrew Poelstra", "Tobin Harding"] repository = "https://github.com/rust-bitcoin/rust-bech32" documentation = "https://docs.rs/bech32/" description = "Encodes and decodes the Bech32 format and implements the bech32 and bech32m checksums" readme = "README.md" keywords = ["base32", "encoding", "bech32", "bitcoin", "cryptocurrency"] categories = ["encoding", "cryptography::cryptocurrencies"] license = "MIT" edition = "2018" [features] default = ["std"] std = ["alloc"] alloc = [] [target.'cfg(mutate)'.dev-dependencies] mutagen = { git = "https://github.com/llogiq/mutagen" } bech32-0.11.0/LICENSE-MIT000064400000000000000000000020371046102023000124070ustar 00000000000000Copyright (c) 2017 Clark Moody Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. bech32-0.11.0/README.md000064400000000000000000000031671046102023000122370ustar 00000000000000Rust Bech32 =========== [![Docs.rs badge](https://docs.rs/bech32/badge.svg)](https://docs.rs/bech32/) [![Continuous Integration](https://github.com/rust-bitcoin/rust-bech32/workflows/Continuous%20Integration/badge.svg)](https://github.com/rust-bitcoin/rust-bech32/actions?query=workflow%3A%22Continuous+Integration%22) Rust implementation of the Bech32 encoding format described in [BIP-0173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki) and Bech32m encoding format described in [BIP-0350](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki). You can find some usage examples in the [documentation](https://docs.rs/bech32/). Bitcoin-specific address encoding is handled by the `bitcoin-bech32` crate. ## MSRV This library should always compile with any combination of features on **Rust 1.48.0**. ## Githooks To assist devs in catching errors _before_ running CI we provide some githooks. If you do not already have locally configured githooks you can use the ones in this repository by running, in the root directory of the repository: ``` git config --local core.hooksPath githooks/ ``` Alternatively add symlinks in your `.git/hooks` directory to any of the githooks we provide. ## Benchmarks We use a custom Rust compiler configuration conditional to guard the benchmark code. To run the benchmarks use: `RUSTFLAGS='--cfg=bench' cargo +nightly bench`. ## API changes All PRs that change the public API of `rust-bech32` must include a patch to the `api/` text files. For PRs that include API changes, add a separate patch to the PR that is the diff created by running `contrib/check-for-api-changes.sh`. bech32-0.11.0/api/README.md000064400000000000000000000005101046102023000127750ustar 00000000000000API text files ============== Each file here lists the public API when built with some set of features enabled. To create these files run `../contrib/check-for-api-changes.sh`: Requires `cargo-public-api`, install with: `cargo +stable install cargo-public-api --locked`. ref: https://github.com/enselic/cargo-public-api bech32-0.11.0/api/all-features.txt000064400000000000000000003033011046102023000146470ustar 00000000000000#[non_exhaustive] pub enum bech32::DecodeError #[non_exhaustive] pub enum bech32::EncodeError #[non_exhaustive] pub enum bech32::EncodeIoError #[non_exhaustive] pub enum bech32::primitives::decode::CharError #[non_exhaustive] pub enum bech32::primitives::decode::CheckedHrpstringError #[non_exhaustive] pub enum bech32::primitives::decode::ChecksumError #[non_exhaustive] pub enum bech32::primitives::decode::PaddingError #[non_exhaustive] pub enum bech32::primitives::decode::SegwitHrpstringError #[non_exhaustive] pub enum bech32::primitives::decode::UncheckedHrpstringError #[non_exhaustive] pub enum bech32::primitives::gf32::FromCharError #[non_exhaustive] pub enum bech32::primitives::gf32::TryFromError #[non_exhaustive] pub enum bech32::primitives::hrp::Error #[non_exhaustive] pub enum bech32::primitives::segwit::WitnessLengthError #[non_exhaustive] pub enum bech32::segwit::EncodeError #[non_exhaustive] pub struct bech32::primitives::decode::CodeLengthError #[non_exhaustive] pub struct bech32::primitives::decode::SegwitCodeLengthError(pub usize) #[non_exhaustive] pub struct bech32::primitives::segwit::InvalidWitnessVersionError(pub bech32::primitives::gf32::Fe32) #[non_exhaustive] pub struct bech32::segwit::DecodeError(pub bech32::primitives::decode::SegwitHrpstringError) #[repr(transparent)] pub struct bech32::Fe32(_) #[repr(transparent)] pub struct bech32::primitives::gf32::Fe32(_) impl !core::panic::unwind_safe::RefUnwindSafe for bech32::EncodeIoError impl !core::panic::unwind_safe::UnwindSafe for bech32::EncodeIoError impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32 impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32m impl bech32::primitives::checksum::Checksum for bech32::primitives::NoChecksum impl bech32::primitives::checksum::PackedFe32 for bech32::primitives::checksum::PackedNull impl bech32::primitives::checksum::PackedFe32 for u128 impl bech32::primitives::checksum::PackedFe32 for u32 impl bech32::primitives::checksum::PackedFe32 for u64 impl bech32::primitives::gf32::Fe32 impl bech32::primitives::hrp::Hrp impl core::clone::Clone for bech32::DecodeError impl core::clone::Clone for bech32::EncodeError impl core::clone::Clone for bech32::primitives::Bech32 impl core::clone::Clone for bech32::primitives::Bech32m impl core::clone::Clone for bech32::primitives::NoChecksum impl core::clone::Clone for bech32::primitives::checksum::PackedNull impl core::clone::Clone for bech32::primitives::decode::CharError impl core::clone::Clone for bech32::primitives::decode::CheckedHrpstringError impl core::clone::Clone for bech32::primitives::decode::ChecksumError impl core::clone::Clone for bech32::primitives::decode::CodeLengthError impl core::clone::Clone for bech32::primitives::decode::PaddingError impl core::clone::Clone for bech32::primitives::decode::SegwitCodeLengthError impl core::clone::Clone for bech32::primitives::decode::SegwitHrpstringError impl core::clone::Clone for bech32::primitives::decode::UncheckedHrpstringError impl core::clone::Clone for bech32::primitives::gf32::Fe32 impl core::clone::Clone for bech32::primitives::gf32::FromCharError impl core::clone::Clone for bech32::primitives::gf32::TryFromError impl core::clone::Clone for bech32::primitives::hrp::Error impl core::clone::Clone for bech32::primitives::hrp::Hrp impl core::clone::Clone for bech32::primitives::segwit::InvalidWitnessVersionError impl core::clone::Clone for bech32::primitives::segwit::WitnessLengthError impl core::clone::Clone for bech32::segwit::DecodeError impl core::clone::Clone for bech32::segwit::EncodeError impl core::cmp::Eq for bech32::DecodeError impl core::cmp::Eq for bech32::EncodeError impl core::cmp::Eq for bech32::primitives::Bech32 impl core::cmp::Eq for bech32::primitives::Bech32m impl core::cmp::Eq for bech32::primitives::NoChecksum impl core::cmp::Eq for bech32::primitives::checksum::PackedNull impl core::cmp::Eq for bech32::primitives::decode::CharError impl core::cmp::Eq for bech32::primitives::decode::CheckedHrpstringError impl core::cmp::Eq for bech32::primitives::decode::ChecksumError impl core::cmp::Eq for bech32::primitives::decode::CodeLengthError impl core::cmp::Eq for bech32::primitives::decode::PaddingError impl core::cmp::Eq for bech32::primitives::decode::SegwitCodeLengthError impl core::cmp::Eq for bech32::primitives::decode::SegwitHrpstringError impl core::cmp::Eq for bech32::primitives::decode::UncheckedHrpstringError impl core::cmp::Eq for bech32::primitives::gf32::Fe32 impl core::cmp::Eq for bech32::primitives::gf32::FromCharError impl core::cmp::Eq for bech32::primitives::gf32::TryFromError impl core::cmp::Eq for bech32::primitives::hrp::Error impl core::cmp::Eq for bech32::primitives::hrp::Hrp impl core::cmp::Eq for bech32::primitives::segwit::InvalidWitnessVersionError impl core::cmp::Eq for bech32::primitives::segwit::WitnessLengthError impl core::cmp::Eq for bech32::segwit::DecodeError impl core::cmp::Eq for bech32::segwit::EncodeError impl core::cmp::Ord for bech32::primitives::Bech32 impl core::cmp::Ord for bech32::primitives::Bech32m impl core::cmp::Ord for bech32::primitives::NoChecksum impl core::cmp::Ord for bech32::primitives::hrp::Hrp impl core::cmp::PartialEq for bech32::DecodeError impl core::cmp::PartialEq for bech32::EncodeError impl core::cmp::PartialEq for bech32::primitives::Bech32 impl core::cmp::PartialEq for bech32::primitives::Bech32m impl core::cmp::PartialEq for bech32::primitives::NoChecksum impl core::cmp::PartialEq for bech32::primitives::checksum::PackedNull impl core::cmp::PartialEq for bech32::primitives::decode::CharError impl core::cmp::PartialEq for bech32::primitives::decode::CheckedHrpstringError impl core::cmp::PartialEq for bech32::primitives::decode::ChecksumError impl core::cmp::PartialEq for bech32::primitives::decode::CodeLengthError impl core::cmp::PartialEq for bech32::primitives::decode::PaddingError impl core::cmp::PartialEq for bech32::primitives::decode::SegwitCodeLengthError impl core::cmp::PartialEq for bech32::primitives::decode::SegwitHrpstringError impl core::cmp::PartialEq for bech32::primitives::decode::UncheckedHrpstringError impl core::cmp::PartialEq for bech32::primitives::gf32::Fe32 impl core::cmp::PartialEq for bech32::primitives::gf32::FromCharError impl core::cmp::PartialEq for bech32::primitives::gf32::TryFromError impl core::cmp::PartialEq for bech32::primitives::hrp::Error impl core::cmp::PartialEq for bech32::primitives::hrp::Hrp impl core::cmp::PartialEq for bech32::primitives::segwit::InvalidWitnessVersionError impl core::cmp::PartialEq for bech32::primitives::segwit::WitnessLengthError impl core::cmp::PartialEq for bech32::segwit::DecodeError impl core::cmp::PartialEq for bech32::segwit::EncodeError impl core::cmp::PartialOrd for bech32::primitives::Bech32 impl core::cmp::PartialOrd for bech32::primitives::Bech32m impl core::cmp::PartialOrd for bech32::primitives::NoChecksum impl core::cmp::PartialOrd for bech32::primitives::hrp::Hrp impl core::convert::AsRef for bech32::primitives::gf32::Fe32 impl core::convert::From for bech32::primitives::decode::UncheckedHrpstringError impl core::convert::From for bech32::primitives::decode::CheckedHrpstringError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for bech32::EncodeError impl core::convert::From for bech32::EncodeIoError impl core::convert::From for bech32::primitives::decode::SegwitCodeLengthError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for bech32::segwit::EncodeError impl core::convert::From for bech32::segwit::DecodeError impl core::convert::From for bech32::DecodeError impl core::convert::From for bech32::primitives::decode::CheckedHrpstringError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for u8 impl core::convert::From for bech32::primitives::decode::UncheckedHrpstringError impl core::convert::From for bech32::segwit::EncodeError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for bech32::segwit::EncodeError impl core::convert::From for bech32::primitives::gf32::TryFromError impl core::convert::From for bech32::EncodeError impl core::convert::From for bech32::segwit::EncodeError impl core::convert::From for bech32::primitives::gf32::TryFromError impl core::convert::From for bech32::EncodeIoError impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::error::Error for bech32::DecodeError impl core::error::Error for bech32::EncodeError impl core::error::Error for bech32::EncodeIoError impl core::error::Error for bech32::primitives::decode::CharError impl core::error::Error for bech32::primitives::decode::CheckedHrpstringError impl core::error::Error for bech32::primitives::decode::ChecksumError impl core::error::Error for bech32::primitives::decode::CodeLengthError impl core::error::Error for bech32::primitives::decode::PaddingError impl core::error::Error for bech32::primitives::decode::SegwitCodeLengthError impl core::error::Error for bech32::primitives::decode::SegwitHrpstringError impl core::error::Error for bech32::primitives::decode::UncheckedHrpstringError impl core::error::Error for bech32::primitives::gf32::FromCharError impl core::error::Error for bech32::primitives::gf32::TryFromError impl core::error::Error for bech32::primitives::hrp::Error impl core::error::Error for bech32::primitives::segwit::InvalidWitnessVersionError impl core::error::Error for bech32::primitives::segwit::WitnessLengthError impl core::error::Error for bech32::segwit::DecodeError impl core::error::Error for bech32::segwit::EncodeError impl core::fmt::Debug for bech32::DecodeError impl core::fmt::Debug for bech32::EncodeError impl core::fmt::Debug for bech32::EncodeIoError impl core::fmt::Debug for bech32::primitives::checksum::PackedNull impl core::fmt::Debug for bech32::primitives::decode::CharError impl core::fmt::Debug for bech32::primitives::decode::CheckedHrpstringError impl core::fmt::Debug for bech32::primitives::decode::ChecksumError impl core::fmt::Debug for bech32::primitives::decode::CodeLengthError impl core::fmt::Debug for bech32::primitives::decode::PaddingError impl core::fmt::Debug for bech32::primitives::decode::SegwitCodeLengthError impl core::fmt::Debug for bech32::primitives::decode::SegwitHrpstringError impl core::fmt::Debug for bech32::primitives::decode::UncheckedHrpstringError impl core::fmt::Debug for bech32::primitives::gf32::Fe32 impl core::fmt::Debug for bech32::primitives::gf32::FromCharError impl core::fmt::Debug for bech32::primitives::gf32::TryFromError impl core::fmt::Debug for bech32::primitives::hrp::Error impl core::fmt::Debug for bech32::primitives::hrp::Hrp impl core::fmt::Debug for bech32::primitives::segwit::InvalidWitnessVersionError impl core::fmt::Debug for bech32::primitives::segwit::WitnessLengthError impl core::fmt::Debug for bech32::segwit::DecodeError impl core::fmt::Debug for bech32::segwit::EncodeError impl core::fmt::Display for bech32::DecodeError impl core::fmt::Display for bech32::EncodeError impl core::fmt::Display for bech32::EncodeIoError impl core::fmt::Display for bech32::primitives::decode::CharError impl core::fmt::Display for bech32::primitives::decode::CheckedHrpstringError impl core::fmt::Display for bech32::primitives::decode::ChecksumError impl core::fmt::Display for bech32::primitives::decode::CodeLengthError impl core::fmt::Display for bech32::primitives::decode::PaddingError impl core::fmt::Display for bech32::primitives::decode::SegwitCodeLengthError impl core::fmt::Display for bech32::primitives::decode::SegwitHrpstringError impl core::fmt::Display for bech32::primitives::decode::UncheckedHrpstringError impl core::fmt::Display for bech32::primitives::gf32::Fe32 impl core::fmt::Display for bech32::primitives::gf32::FromCharError impl core::fmt::Display for bech32::primitives::gf32::TryFromError impl core::fmt::Display for bech32::primitives::hrp::Error impl core::fmt::Display for bech32::primitives::hrp::Hrp impl core::fmt::Display for bech32::primitives::segwit::InvalidWitnessVersionError impl core::fmt::Display for bech32::primitives::segwit::WitnessLengthError impl core::fmt::Display for bech32::segwit::DecodeError impl core::fmt::Display for bech32::segwit::EncodeError impl core::hash::Hash for bech32::primitives::Bech32 impl core::hash::Hash for bech32::primitives::Bech32m impl core::hash::Hash for bech32::primitives::NoChecksum impl core::hash::Hash for bech32::primitives::gf32::Fe32 impl core::hash::Hash for bech32::primitives::hrp::Hrp impl core::marker::Copy for bech32::primitives::Bech32 impl core::marker::Copy for bech32::primitives::Bech32m impl core::marker::Copy for bech32::primitives::NoChecksum impl core::marker::Copy for bech32::primitives::checksum::PackedNull impl core::marker::Copy for bech32::primitives::gf32::Fe32 impl core::marker::Copy for bech32::primitives::gf32::FromCharError impl core::marker::Copy for bech32::primitives::gf32::TryFromError impl core::marker::Copy for bech32::primitives::hrp::Hrp impl core::marker::Send for bech32::DecodeError impl core::marker::Send for bech32::EncodeError impl core::marker::Send for bech32::EncodeIoError impl core::marker::Send for bech32::primitives::Bech32 impl core::marker::Send for bech32::primitives::Bech32m impl core::marker::Send for bech32::primitives::NoChecksum impl core::marker::Send for bech32::primitives::checksum::PackedNull impl core::marker::Send for bech32::primitives::decode::CharError impl core::marker::Send for bech32::primitives::decode::CheckedHrpstringError impl core::marker::Send for bech32::primitives::decode::ChecksumError impl core::marker::Send for bech32::primitives::decode::CodeLengthError impl core::marker::Send for bech32::primitives::decode::PaddingError impl core::marker::Send for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::Send for bech32::primitives::decode::SegwitHrpstringError impl core::marker::Send for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::Send for bech32::primitives::gf32::Fe32 impl core::marker::Send for bech32::primitives::gf32::FromCharError impl core::marker::Send for bech32::primitives::gf32::TryFromError impl core::marker::Send for bech32::primitives::hrp::Error impl core::marker::Send for bech32::primitives::hrp::Hrp impl core::marker::Send for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::Send for bech32::primitives::segwit::WitnessLengthError impl core::marker::Send for bech32::segwit::DecodeError impl core::marker::Send for bech32::segwit::EncodeError impl core::marker::StructuralPartialEq for bech32::DecodeError impl core::marker::StructuralPartialEq for bech32::EncodeError impl core::marker::StructuralPartialEq for bech32::primitives::Bech32 impl core::marker::StructuralPartialEq for bech32::primitives::Bech32m impl core::marker::StructuralPartialEq for bech32::primitives::NoChecksum impl core::marker::StructuralPartialEq for bech32::primitives::checksum::PackedNull impl core::marker::StructuralPartialEq for bech32::primitives::decode::CharError impl core::marker::StructuralPartialEq for bech32::primitives::decode::CheckedHrpstringError impl core::marker::StructuralPartialEq for bech32::primitives::decode::ChecksumError impl core::marker::StructuralPartialEq for bech32::primitives::decode::CodeLengthError impl core::marker::StructuralPartialEq for bech32::primitives::decode::PaddingError impl core::marker::StructuralPartialEq for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::StructuralPartialEq for bech32::primitives::decode::SegwitHrpstringError impl core::marker::StructuralPartialEq for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::StructuralPartialEq for bech32::primitives::gf32::Fe32 impl core::marker::StructuralPartialEq for bech32::primitives::gf32::FromCharError impl core::marker::StructuralPartialEq for bech32::primitives::gf32::TryFromError impl core::marker::StructuralPartialEq for bech32::primitives::hrp::Error impl core::marker::StructuralPartialEq for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::StructuralPartialEq for bech32::primitives::segwit::WitnessLengthError impl core::marker::StructuralPartialEq for bech32::segwit::DecodeError impl core::marker::StructuralPartialEq for bech32::segwit::EncodeError impl core::marker::Sync for bech32::DecodeError impl core::marker::Sync for bech32::EncodeError impl core::marker::Sync for bech32::EncodeIoError impl core::marker::Sync for bech32::primitives::Bech32 impl core::marker::Sync for bech32::primitives::Bech32m impl core::marker::Sync for bech32::primitives::NoChecksum impl core::marker::Sync for bech32::primitives::checksum::PackedNull impl core::marker::Sync for bech32::primitives::decode::CharError impl core::marker::Sync for bech32::primitives::decode::CheckedHrpstringError impl core::marker::Sync for bech32::primitives::decode::ChecksumError impl core::marker::Sync for bech32::primitives::decode::CodeLengthError impl core::marker::Sync for bech32::primitives::decode::PaddingError impl core::marker::Sync for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::Sync for bech32::primitives::decode::SegwitHrpstringError impl core::marker::Sync for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::Sync for bech32::primitives::gf32::Fe32 impl core::marker::Sync for bech32::primitives::gf32::FromCharError impl core::marker::Sync for bech32::primitives::gf32::TryFromError impl core::marker::Sync for bech32::primitives::hrp::Error impl core::marker::Sync for bech32::primitives::hrp::Hrp impl core::marker::Sync for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::Sync for bech32::primitives::segwit::WitnessLengthError impl core::marker::Sync for bech32::segwit::DecodeError impl core::marker::Sync for bech32::segwit::EncodeError impl core::marker::Unpin for bech32::DecodeError impl core::marker::Unpin for bech32::EncodeError impl core::marker::Unpin for bech32::EncodeIoError impl core::marker::Unpin for bech32::primitives::Bech32 impl core::marker::Unpin for bech32::primitives::Bech32m impl core::marker::Unpin for bech32::primitives::NoChecksum impl core::marker::Unpin for bech32::primitives::checksum::PackedNull impl core::marker::Unpin for bech32::primitives::decode::CharError impl core::marker::Unpin for bech32::primitives::decode::CheckedHrpstringError impl core::marker::Unpin for bech32::primitives::decode::ChecksumError impl core::marker::Unpin for bech32::primitives::decode::CodeLengthError impl core::marker::Unpin for bech32::primitives::decode::PaddingError impl core::marker::Unpin for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::Unpin for bech32::primitives::decode::SegwitHrpstringError impl core::marker::Unpin for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::Unpin for bech32::primitives::gf32::Fe32 impl core::marker::Unpin for bech32::primitives::gf32::FromCharError impl core::marker::Unpin for bech32::primitives::gf32::TryFromError impl core::marker::Unpin for bech32::primitives::hrp::Error impl core::marker::Unpin for bech32::primitives::hrp::Hrp impl core::marker::Unpin for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::Unpin for bech32::primitives::segwit::WitnessLengthError impl core::marker::Unpin for bech32::segwit::DecodeError impl core::marker::Unpin for bech32::segwit::EncodeError impl core::ops::arith::Add for bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Add for &bech32::primitives::gf32::Fe32 impl core::ops::arith::AddAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div for &bech32::primitives::gf32::Fe32 impl core::ops::arith::DivAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul for &bech32::primitives::gf32::Fe32 impl core::ops::arith::MulAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub for &bech32::primitives::gf32::Fe32 impl core::ops::arith::SubAssign for bech32::primitives::gf32::Fe32 impl core::ops::bit::BitXor for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::RefUnwindSafe for bech32::DecodeError impl core::panic::unwind_safe::RefUnwindSafe for bech32::EncodeError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::Bech32 impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::Bech32m impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::NoChecksum impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CharError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CheckedHrpstringError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::ChecksumError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CodeLengthError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::PaddingError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::SegwitCodeLengthError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::SegwitHrpstringError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::UncheckedHrpstringError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32::Fe32 impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32::FromCharError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32::TryFromError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::Error impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::Hrp impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::segwit::InvalidWitnessVersionError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::segwit::WitnessLengthError impl core::panic::unwind_safe::RefUnwindSafe for bech32::segwit::DecodeError impl core::panic::unwind_safe::RefUnwindSafe for bech32::segwit::EncodeError impl core::panic::unwind_safe::UnwindSafe for bech32::DecodeError impl core::panic::unwind_safe::UnwindSafe for bech32::EncodeError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::Bech32 impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::Bech32m impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::NoChecksum impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CharError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CheckedHrpstringError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::ChecksumError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CodeLengthError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::PaddingError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::SegwitCodeLengthError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::SegwitHrpstringError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::UncheckedHrpstringError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32::Fe32 impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32::FromCharError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32::TryFromError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::Error impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::Hrp impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::segwit::InvalidWitnessVersionError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::segwit::WitnessLengthError impl core::panic::unwind_safe::UnwindSafe for bech32::segwit::DecodeError impl core::panic::unwind_safe::UnwindSafe for bech32::segwit::EncodeError impl<'a, I, Ck> core::iter::traits::iterator::Iterator for bech32::primitives::encode::ByteIter<'a, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'a, I, Ck> core::iter::traits::iterator::Iterator for bech32::primitives::encode::CharIter<'a, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::CharIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::CharIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::CharIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::CharIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::CharIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'hrp, I, Ck> bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> core::clone::Clone for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator + core::clone::Clone, Ck: bech32::primitives::checksum::Checksum + core::clone::Clone impl<'hrp, I, Ck> core::cmp::Eq for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator + core::cmp::Eq, Ck: bech32::primitives::checksum::Checksum + core::cmp::Eq impl<'hrp, I, Ck> core::cmp::PartialEq for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator + core::cmp::PartialEq, Ck: bech32::primitives::checksum::Checksum + core::cmp::PartialEq impl<'hrp, I, Ck> core::iter::traits::iterator::Iterator for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::marker::Send, I: core::marker::Send impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl<'hrp, I, Ck> core::marker::StructuralPartialEq for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::marker::Sync, I: core::marker::Sync impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::marker::Unpin, I: core::marker::Unpin impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::panic::unwind_safe::RefUnwindSafe, I: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::panic::unwind_safe::UnwindSafe, I: core::panic::unwind_safe::UnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl<'hrp> bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::iter::traits::iterator::Iterator for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::marker::Send for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::marker::Sync for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::marker::Unpin for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::panic::unwind_safe::UnwindSafe for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'s> bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::fmt::Debug for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::fmt::Debug for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::fmt::Debug for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::decode::ByteIter<'s> impl<'s> core::iter::traits::iterator::Iterator for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::iter::traits::iterator::Iterator for bech32::primitives::decode::ByteIter<'s> impl<'s> core::iter::traits::iterator::Iterator for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::ByteIter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::marker::Send for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::marker::Send for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::ByteIter<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::ByteIter<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::ByteIter<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::ByteIter<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::UncheckedHrpstring<'s> impl bech32::primitives::checksum::Engine impl core::default::Default for bech32::primitives::checksum::Engine impl core::marker::StructuralPartialEq for bech32::primitives::checksum::Engine impl core::clone::Clone for bech32::primitives::checksum::Engine where ::MidstateRepr: core::clone::Clone impl core::cmp::Eq for bech32::primitives::checksum::Engine where ::MidstateRepr: core::cmp::Eq impl core::cmp::PartialEq for bech32::primitives::checksum::Engine where ::MidstateRepr: core::cmp::PartialEq impl core::fmt::Debug for bech32::primitives::checksum::Engine where ::MidstateRepr: core::fmt::Debug impl core::marker::Copy for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Copy impl core::marker::Send for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Send impl core::marker::Sync for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Sync impl core::marker::Unpin for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Unpin impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::checksum::Engine where ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::checksum::Engine where ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl core::clone::Clone for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator + core::clone::Clone, Ck: bech32::primitives::checksum::Checksum + core::clone::Clone impl core::cmp::Eq for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator + core::cmp::Eq, Ck: bech32::primitives::checksum::Checksum + core::cmp::Eq impl core::cmp::PartialEq for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator + core::cmp::PartialEq, Ck: bech32::primitives::checksum::Checksum + core::cmp::PartialEq impl core::iter::traits::iterator::Iterator for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl core::marker::Send for bech32::primitives::iter::Checksummed where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl core::marker::StructuralPartialEq for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl core::marker::Sync for bech32::primitives::iter::Checksummed where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl core::marker::Unpin for bech32::primitives::iter::Checksummed where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::Checksummed where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::Checksummed where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl> core::clone::Clone for bech32::primitives::iter::FesToBytes impl> core::clone::Clone for bech32::primitives::iter::BytesToFes impl> core::cmp::Eq for bech32::primitives::iter::FesToBytes impl> core::cmp::Eq for bech32::primitives::iter::BytesToFes impl> core::cmp::PartialEq for bech32::primitives::iter::FesToBytes impl> core::cmp::PartialEq for bech32::primitives::iter::BytesToFes impl> core::marker::StructuralPartialEq for bech32::primitives::iter::FesToBytes impl> core::marker::StructuralPartialEq for bech32::primitives::iter::BytesToFes impl bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator impl bech32::primitives::iter::ByteIterExt for I where I: core::iter::traits::iterator::Iterator impl bech32::primitives::iter::Fe32IterExt for I where I: core::iter::traits::iterator::Iterator impl core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::iter::BytesToFes where I: core::iter::traits::iterator::Iterator + core::iter::traits::exact_size::ExactSizeIterator impl core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::iter::FesToBytes where I: core::iter::traits::iterator::Iterator + core::iter::traits::exact_size::ExactSizeIterator impl core::iter::traits::iterator::Iterator for bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator impl core::iter::traits::iterator::Iterator for bech32::primitives::iter::BytesToFes where I: core::iter::traits::iterator::Iterator impl core::iter::traits::iterator::Iterator for bech32::primitives::iter::FesToBytes where I: core::iter::traits::iterator::Iterator impl core::marker::Send for bech32::primitives::encode::WitnessVersionIter where I: core::marker::Send impl core::marker::Send for bech32::primitives::iter::BytesToFes where I: core::marker::Send impl core::marker::Send for bech32::primitives::iter::FesToBytes where I: core::marker::Send impl core::marker::Sync for bech32::primitives::encode::WitnessVersionIter where I: core::marker::Sync impl core::marker::Sync for bech32::primitives::iter::BytesToFes where I: core::marker::Sync impl core::marker::Sync for bech32::primitives::iter::FesToBytes where I: core::marker::Sync impl core::marker::Unpin for bech32::primitives::encode::WitnessVersionIter where I: core::marker::Unpin impl core::marker::Unpin for bech32::primitives::iter::BytesToFes where I: core::marker::Unpin impl core::marker::Unpin for bech32::primitives::iter::FesToBytes where I: core::marker::Unpin impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::WitnessVersionIter where I: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::BytesToFes where I: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::FesToBytes where I: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::WitnessVersionIter where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::BytesToFes where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::FesToBytes where I: core::panic::unwind_safe::UnwindSafe pub bech32::DecodeError::Checksum(bech32::primitives::decode::ChecksumError) pub bech32::DecodeError::Parse(bech32::primitives::decode::UncheckedHrpstringError) pub bech32::EncodeError::Fmt(core::fmt::Error) pub bech32::EncodeError::TooLong(bech32::primitives::decode::CodeLengthError) pub bech32::EncodeIoError::TooLong(bech32::primitives::decode::CodeLengthError) pub bech32::EncodeIoError::Write(std::io::error::Error) pub bech32::primitives::decode::CharError::InvalidChar(char) pub bech32::primitives::decode::CharError::MissingSeparator pub bech32::primitives::decode::CharError::MixedCase pub bech32::primitives::decode::CharError::NothingAfterSeparator pub bech32::primitives::decode::CheckedHrpstringError::Checksum(bech32::primitives::decode::ChecksumError) pub bech32::primitives::decode::CheckedHrpstringError::Parse(bech32::primitives::decode::UncheckedHrpstringError) pub bech32::primitives::decode::ChecksumError::CodeLength(bech32::primitives::decode::CodeLengthError) pub bech32::primitives::decode::ChecksumError::InvalidLength pub bech32::primitives::decode::ChecksumError::InvalidResidue pub bech32::primitives::decode::CodeLengthError::code_length: usize pub bech32::primitives::decode::CodeLengthError::encoded_length: usize pub bech32::primitives::decode::PaddingError::NonZero pub bech32::primitives::decode::PaddingError::TooMuch pub bech32::primitives::decode::SegwitHrpstringError::Checksum(bech32::primitives::decode::ChecksumError) pub bech32::primitives::decode::SegwitHrpstringError::InvalidWitnessVersion(bech32::primitives::gf32::Fe32) pub bech32::primitives::decode::SegwitHrpstringError::NoData pub bech32::primitives::decode::SegwitHrpstringError::Padding(bech32::primitives::decode::PaddingError) pub bech32::primitives::decode::SegwitHrpstringError::TooLong(usize) pub bech32::primitives::decode::SegwitHrpstringError::Unchecked(bech32::primitives::decode::UncheckedHrpstringError) pub bech32::primitives::decode::SegwitHrpstringError::WitnessLength(bech32::primitives::segwit::WitnessLengthError) pub bech32::primitives::decode::UncheckedHrpstringError::Char(bech32::primitives::decode::CharError) pub bech32::primitives::decode::UncheckedHrpstringError::Hrp(bech32::primitives::hrp::Error) pub bech32::primitives::gf32::FromCharError::Invalid(char) pub bech32::primitives::gf32::FromCharError::NotAscii(char) pub bech32::primitives::gf32::TryFromError::InvalidByte(u8) pub bech32::primitives::gf32::TryFromError::NotAByte(core::num::error::TryFromIntError) pub bech32::primitives::hrp::Error::Empty pub bech32::primitives::hrp::Error::InvalidAsciiByte(u8) pub bech32::primitives::hrp::Error::MixedCase pub bech32::primitives::hrp::Error::NonAsciiChar(char) pub bech32::primitives::hrp::Error::TooLong(usize) pub bech32::primitives::segwit::WitnessLengthError::InvalidSegwitV0 pub bech32::primitives::segwit::WitnessLengthError::TooLong pub bech32::primitives::segwit::WitnessLengthError::TooShort pub bech32::segwit::EncodeError::Fmt(core::fmt::Error) pub bech32::segwit::EncodeError::TooLong(bech32::primitives::decode::SegwitCodeLengthError) pub bech32::segwit::EncodeError::WitnessLength(bech32::primitives::segwit::WitnessLengthError) pub bech32::segwit::EncodeError::WitnessVersion(bech32::primitives::segwit::InvalidWitnessVersionError) pub const bech32::Checksum::CHECKSUM_LENGTH: usize pub const bech32::Checksum::CODE_LENGTH: usize pub const bech32::Checksum::GENERATOR_SH: [Self::MidstateRepr; 5] pub const bech32::Checksum::TARGET_RESIDUE: Self::MidstateRepr pub const bech32::hrp::BC: _ pub const bech32::hrp::BCRT: _ pub const bech32::hrp::TB: _ pub const bech32::primitives::Bech32::CHECKSUM_LENGTH: usize pub const bech32::primitives::Bech32::CODE_LENGTH: usize pub const bech32::primitives::Bech32::GENERATOR_SH: [u32; 5] pub const bech32::primitives::Bech32::TARGET_RESIDUE: u32 pub const bech32::primitives::Bech32m::CHECKSUM_LENGTH: usize pub const bech32::primitives::Bech32m::CODE_LENGTH: usize pub const bech32::primitives::Bech32m::GENERATOR_SH: [u32; 5] pub const bech32::primitives::Bech32m::TARGET_RESIDUE: u32 pub const bech32::primitives::NoChecksum::CHECKSUM_LENGTH: usize pub const bech32::primitives::NoChecksum::CODE_LENGTH: usize pub const bech32::primitives::NoChecksum::GENERATOR_SH: [bech32::primitives::checksum::PackedNull; 5] pub const bech32::primitives::NoChecksum::TARGET_RESIDUE: bech32::primitives::checksum::PackedNull pub const bech32::primitives::checksum::Checksum::CHECKSUM_LENGTH: usize pub const bech32::primitives::checksum::Checksum::CODE_LENGTH: usize pub const bech32::primitives::checksum::Checksum::GENERATOR_SH: [Self::MidstateRepr; 5] pub const bech32::primitives::checksum::Checksum::TARGET_RESIDUE: Self::MidstateRepr pub const bech32::primitives::checksum::PackedFe32::ONE: Self pub const bech32::primitives::checksum::PackedFe32::WIDTH: usize pub const bech32::primitives::checksum::PackedNull::ONE: Self pub const bech32::primitives::gf32::Fe32::A: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::C: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::D: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::E: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::F: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::G: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::H: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::J: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::K: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::L: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::M: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::N: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::P: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::Q: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::R: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::S: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::T: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::U: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::V: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::W: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::X: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::Y: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::Z: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_0: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_2: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_3: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_4: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_5: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_6: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_7: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_8: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_9: bech32::primitives::gf32::Fe32 pub const bech32::primitives::hrp::BC: _ pub const bech32::primitives::hrp::BCRT: _ pub const bech32::primitives::hrp::TB: _ pub const bech32::primitives::segwit::MAX_STRING_LENGTH: usize = 90usize pub const bech32::primitives::segwit::VERSION_0: Fe32::Q pub const bech32::primitives::segwit::VERSION_1: Fe32::P pub const bech32::segwit::VERSION_0: Fe32::Q pub const bech32::segwit::VERSION_1: Fe32::P pub const fn bech32::primitives::hrp::Hrp::parse_unchecked(hrp: &str) -> Self pub const u128::ONE: Self pub const u32::ONE: Self pub const u64::ONE: Self pub enum bech32::Bech32 pub enum bech32::Bech32m pub enum bech32::NoChecksum pub enum bech32::primitives::Bech32 pub enum bech32::primitives::Bech32m pub enum bech32::primitives::NoChecksum pub fn &bech32::primitives::gf32::Fe32::add(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::add(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::div(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::div(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::mul(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::mul(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::ByteIterExt::bytes_to_fes(self) -> bech32::primitives::iter::BytesToFes pub fn bech32::Checksum::sanity_check() pub fn bech32::DecodeError::clone(&self) -> bech32::DecodeError pub fn bech32::DecodeError::eq(&self, other: &bech32::DecodeError) -> bool pub fn bech32::DecodeError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::DecodeError::from(e: bech32::primitives::decode::UncheckedHrpstringError) -> Self pub fn bech32::DecodeError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::EncodeError::clone(&self) -> bech32::EncodeError pub fn bech32::EncodeError::eq(&self, other: &bech32::EncodeError) -> bool pub fn bech32::EncodeError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::EncodeError::from(e: bech32::primitives::decode::CodeLengthError) -> Self pub fn bech32::EncodeError::from(e: core::fmt::Error) -> Self pub fn bech32::EncodeError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::EncodeIoError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::EncodeIoError::from(e: bech32::primitives::decode::CodeLengthError) -> Self pub fn bech32::EncodeIoError::from(e: std::io::error::Error) -> Self pub fn bech32::EncodeIoError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::Fe32IterExt::fes_to_bytes(self) -> bech32::primitives::iter::FesToBytes pub fn bech32::Fe32IterExt::with_checksum(self, hrp: &bech32::primitives::hrp::Hrp) -> bech32::primitives::encode::Encoder<'_, Self, Ck> pub fn bech32::decode(s: &str) -> core::result::Result<(bech32::primitives::hrp::Hrp, alloc::vec::Vec), bech32::DecodeError> pub fn bech32::encode(hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result pub fn bech32::encode_lower(hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result pub fn bech32::encode_lower_to_fmt(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeError> pub fn bech32::encode_lower_to_writer(w: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeIoError> pub fn bech32::encode_to_fmt(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeError> pub fn bech32::encode_to_writer(w: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeIoError> pub fn bech32::encode_upper(hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result pub fn bech32::encode_upper_to_fmt(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeError> pub fn bech32::encode_upper_to_writer(w: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeIoError> pub fn bech32::encoded_length(hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result pub fn bech32::primitives::Bech32::clone(&self) -> bech32::primitives::Bech32 pub fn bech32::primitives::Bech32::cmp(&self, other: &bech32::primitives::Bech32) -> core::cmp::Ordering pub fn bech32::primitives::Bech32::eq(&self, other: &bech32::primitives::Bech32) -> bool pub fn bech32::primitives::Bech32::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::Bech32::partial_cmp(&self, other: &bech32::primitives::Bech32) -> core::option::Option pub fn bech32::primitives::Bech32m::clone(&self) -> bech32::primitives::Bech32m pub fn bech32::primitives::Bech32m::cmp(&self, other: &bech32::primitives::Bech32m) -> core::cmp::Ordering pub fn bech32::primitives::Bech32m::eq(&self, other: &bech32::primitives::Bech32m) -> bool pub fn bech32::primitives::Bech32m::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::Bech32m::partial_cmp(&self, other: &bech32::primitives::Bech32m) -> core::option::Option pub fn bech32::primitives::NoChecksum::clone(&self) -> bech32::primitives::NoChecksum pub fn bech32::primitives::NoChecksum::cmp(&self, other: &bech32::primitives::NoChecksum) -> core::cmp::Ordering pub fn bech32::primitives::NoChecksum::eq(&self, other: &bech32::primitives::NoChecksum) -> bool pub fn bech32::primitives::NoChecksum::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::NoChecksum::partial_cmp(&self, other: &bech32::primitives::NoChecksum) -> core::option::Option pub fn bech32::primitives::checksum::Checksum::sanity_check() pub fn bech32::primitives::checksum::Engine::clone(&self) -> bech32::primitives::checksum::Engine pub fn bech32::primitives::checksum::Engine::default() -> Self pub fn bech32::primitives::checksum::Engine::eq(&self, other: &bech32::primitives::checksum::Engine) -> bool pub fn bech32::primitives::checksum::Engine::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::checksum::Engine::input_fe(&mut self, e: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::checksum::Engine::input_hrp(&mut self, hrp: bech32::primitives::hrp::Hrp) pub fn bech32::primitives::checksum::Engine::input_target_residue(&mut self) pub fn bech32::primitives::checksum::Engine::new() -> Self pub fn bech32::primitives::checksum::Engine::residue(&self) -> &::MidstateRepr pub fn bech32::primitives::checksum::HrpFe32Iter<'hrp>::new(hrp: &'hrp bech32::primitives::hrp::Hrp) -> Self pub fn bech32::primitives::checksum::HrpFe32Iter<'hrp>::next(&mut self) -> core::option::Option pub fn bech32::primitives::checksum::HrpFe32Iter<'hrp>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::checksum::PackedFe32::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn bech32::primitives::checksum::PackedFe32::unpack(&self, n: usize) -> u8 pub fn bech32::primitives::checksum::PackedNull::bitxor(self, bech32::primitives::checksum::PackedNull) -> bech32::primitives::checksum::PackedNull pub fn bech32::primitives::checksum::PackedNull::clone(&self) -> bech32::primitives::checksum::PackedNull pub fn bech32::primitives::checksum::PackedNull::eq(&self, other: &bech32::primitives::checksum::PackedNull) -> bool pub fn bech32::primitives::checksum::PackedNull::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::checksum::PackedNull::mul_by_x_then_add(&mut self, usize, u8) -> u8 pub fn bech32::primitives::checksum::PackedNull::unpack(&self, usize) -> u8 pub fn bech32::primitives::decode::AsciiToFe32Iter<'s>::len(&self) -> usize pub fn bech32::primitives::decode::AsciiToFe32Iter<'s>::next(&mut self) -> core::option::Option pub fn bech32::primitives::decode::AsciiToFe32Iter<'s>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::decode::ByteIter<'s>::len(&self) -> usize pub fn bech32::primitives::decode::ByteIter<'s>::next(&mut self) -> core::option::Option pub fn bech32::primitives::decode::ByteIter<'s>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::decode::CharError::clone(&self) -> bech32::primitives::decode::CharError pub fn bech32::primitives::decode::CharError::eq(&self, other: &bech32::primitives::decode::CharError) -> bool pub fn bech32::primitives::decode::CharError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CharError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::byte_iter(&self) -> bech32::primitives::decode::ByteIter<'_> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::data_part_ascii_no_checksum(&self) -> &'s [u8] pub fn bech32::primitives::decode::CheckedHrpstring<'s>::fe32_iter>(&self) -> bech32::primitives::decode::AsciiToFe32Iter<'_> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CheckedHrpstring<'s>::hrp(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::decode::CheckedHrpstring<'s>::new(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::CheckedHrpstring<'s>::remove_witness_version(&mut self) -> core::option::Option pub fn bech32::primitives::decode::CheckedHrpstring<'s>::validate_segwit(self) -> core::result::Result, bech32::primitives::decode::SegwitHrpstringError> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::validate_segwit_padding(&self) -> core::result::Result<(), bech32::primitives::decode::PaddingError> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::validate_witness_program_length(&self, witness_version: bech32::primitives::gf32::Fe32) -> core::result::Result<(), bech32::primitives::segwit::WitnessLengthError> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::witness_version(&self) -> core::option::Option pub fn bech32::primitives::decode::CheckedHrpstringError::clone(&self) -> bech32::primitives::decode::CheckedHrpstringError pub fn bech32::primitives::decode::CheckedHrpstringError::eq(&self, other: &bech32::primitives::decode::CheckedHrpstringError) -> bool pub fn bech32::primitives::decode::CheckedHrpstringError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CheckedHrpstringError::from(e: bech32::primitives::decode::ChecksumError) -> Self pub fn bech32::primitives::decode::CheckedHrpstringError::from(e: bech32::primitives::decode::UncheckedHrpstringError) -> Self pub fn bech32::primitives::decode::CheckedHrpstringError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::decode::ChecksumError::clone(&self) -> bech32::primitives::decode::ChecksumError pub fn bech32::primitives::decode::ChecksumError::eq(&self, other: &bech32::primitives::decode::ChecksumError) -> bool pub fn bech32::primitives::decode::ChecksumError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::ChecksumError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::decode::CodeLengthError::clone(&self) -> bech32::primitives::decode::CodeLengthError pub fn bech32::primitives::decode::CodeLengthError::eq(&self, other: &bech32::primitives::decode::CodeLengthError) -> bool pub fn bech32::primitives::decode::CodeLengthError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CodeLengthError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::decode::Fe32Iter<'s>::next(&mut self) -> core::option::Option pub fn bech32::primitives::decode::Fe32Iter<'s>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::decode::PaddingError::clone(&self) -> bech32::primitives::decode::PaddingError pub fn bech32::primitives::decode::PaddingError::eq(&self, other: &bech32::primitives::decode::PaddingError) -> bool pub fn bech32::primitives::decode::PaddingError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::PaddingError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::decode::SegwitCodeLengthError::clone(&self) -> bech32::primitives::decode::SegwitCodeLengthError pub fn bech32::primitives::decode::SegwitCodeLengthError::eq(&self, other: &bech32::primitives::decode::SegwitCodeLengthError) -> bool pub fn bech32::primitives::decode::SegwitCodeLengthError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::SegwitCodeLengthError::from(e: bech32::primitives::decode::CodeLengthError) -> Self pub fn bech32::primitives::decode::SegwitCodeLengthError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::decode::SegwitHrpstring<'s>::byte_iter(&self) -> bech32::primitives::decode::ByteIter<'_> pub fn bech32::primitives::decode::SegwitHrpstring<'s>::data_part_ascii_no_witver_no_checksum(&self) -> &'s [u8] pub fn bech32::primitives::decode::SegwitHrpstring<'s>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::SegwitHrpstring<'s>::has_valid_hrp(&self) -> bool pub fn bech32::primitives::decode::SegwitHrpstring<'s>::hrp(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::decode::SegwitHrpstring<'s>::new(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::SegwitHrpstring<'s>::new_bech32(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::SegwitHrpstring<'s>::witness_version(&self) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::decode::SegwitHrpstringError::clone(&self) -> bech32::primitives::decode::SegwitHrpstringError pub fn bech32::primitives::decode::SegwitHrpstringError::eq(&self, other: &bech32::primitives::decode::SegwitHrpstringError) -> bool pub fn bech32::primitives::decode::SegwitHrpstringError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::decode::ChecksumError) -> Self pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::decode::PaddingError) -> Self pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::decode::UncheckedHrpstringError) -> Self pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::segwit::WitnessLengthError) -> Self pub fn bech32::primitives::decode::SegwitHrpstringError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::data_part_ascii(&self) -> &'s [u8] pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::has_valid_checksum(&self) -> bool pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::hrp(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::new(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::remove_checksum(self) -> bech32::primitives::decode::CheckedHrpstring<'s> pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::remove_witness_version(&mut self) -> core::option::Option pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::validate_and_remove_checksum(self) -> core::result::Result, bech32::primitives::decode::ChecksumError> pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::validate_checksum(&self) -> core::result::Result<(), bech32::primitives::decode::ChecksumError> pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::witness_version(&self) -> core::option::Option pub fn bech32::primitives::decode::UncheckedHrpstringError::clone(&self) -> bech32::primitives::decode::UncheckedHrpstringError pub fn bech32::primitives::decode::UncheckedHrpstringError::eq(&self, other: &bech32::primitives::decode::UncheckedHrpstringError) -> bool pub fn bech32::primitives::decode::UncheckedHrpstringError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::UncheckedHrpstringError::from(e: bech32::primitives::decode::CharError) -> Self pub fn bech32::primitives::decode::UncheckedHrpstringError::from(e: bech32::primitives::hrp::Error) -> Self pub fn bech32::primitives::decode::UncheckedHrpstringError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::encode::ByteIter<'a, I, Ck>::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::ByteIter<'a, I, Ck>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::encode::ByteIter<'hrp, I, Ck>::new(char_iter: bech32::primitives::encode::CharIter<'hrp, I, Ck>) -> Self pub fn bech32::primitives::encode::CharIter<'a, I, Ck>::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::CharIter<'a, I, Ck>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::encode::CharIter<'hrp, I, Ck>::new(hrp: &'hrp bech32::primitives::hrp::Hrp, data: bech32::primitives::encode::WitnessVersionIter) -> Self pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::bytes(self) -> bech32::primitives::encode::ByteIter<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::chars(self) -> bech32::primitives::encode::CharIter<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::clone(&self) -> bech32::primitives::encode::Encoder<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::eq(&self, other: &bech32::primitives::encode::Encoder<'hrp, I, Ck>) -> bool pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::fes(self) -> bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::new(data: I, hrp: &'hrp bech32::primitives::hrp::Hrp) -> Self pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::with_witness_version(self, witness_version: bech32::primitives::gf32::Fe32) -> Self pub fn bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::new(hrp: &'hrp bech32::primitives::hrp::Hrp, data: bech32::primitives::encode::WitnessVersionIter) -> Self pub fn bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::encode::WitnessVersionIter::new(witness_version: core::option::Option, iter: I) -> Self pub fn bech32::primitives::encode::WitnessVersionIter::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::WitnessVersionIter::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::gf32::Fe32::add(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::add(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::add_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::as_ref(&self) -> &u8 pub fn bech32::primitives::gf32::Fe32::clone(&self) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::div(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::div(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::div_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::eq(&self, other: &bech32::primitives::gf32::Fe32) -> bool pub fn bech32::primitives::gf32::Fe32::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::gf32::Fe32::from_char(c: char) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::from_char_unchecked(c: u8) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::gf32::Fe32::iter_alpha() -> impl core::iter::traits::iterator::Iterator pub fn bech32::primitives::gf32::Fe32::mul(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::mul(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::mul_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::sub(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::sub(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::sub_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::to_char(self) -> char pub fn bech32::primitives::gf32::Fe32::to_u8(self) -> u8 pub fn bech32::primitives::gf32::Fe32::try_from(value: i128) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i16) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i32) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i64) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i8) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u128) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u16) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u32) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u64) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u8) -> core::result::Result pub fn bech32::primitives::gf32::FromCharError::clone(&self) -> bech32::primitives::gf32::FromCharError pub fn bech32::primitives::gf32::FromCharError::eq(&self, other: &bech32::primitives::gf32::FromCharError) -> bool pub fn bech32::primitives::gf32::FromCharError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::gf32::FromCharError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::gf32::TryFromError::clone(&self) -> bech32::primitives::gf32::TryFromError pub fn bech32::primitives::gf32::TryFromError::eq(&self, other: &bech32::primitives::gf32::TryFromError) -> bool pub fn bech32::primitives::gf32::TryFromError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::gf32::TryFromError::from(e: core::num::error::TryFromIntError) -> Self pub fn bech32::primitives::gf32::TryFromError::from(i: core::convert::Infallible) -> Self pub fn bech32::primitives::gf32::TryFromError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::hrp::ByteIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::ByteIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::ByteIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::ByteIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::hrp::CharIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::CharIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::CharIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::CharIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::hrp::Error::clone(&self) -> bech32::primitives::hrp::Error pub fn bech32::primitives::hrp::Error::eq(&self, other: &bech32::primitives::hrp::Error) -> bool pub fn bech32::primitives::hrp::Error::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::hrp::Error::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::hrp::Hrp::as_bytes(&self) -> &[u8] pub fn bech32::primitives::hrp::Hrp::as_str(&self) -> &str pub fn bech32::primitives::hrp::Hrp::byte_iter(&self) -> bech32::primitives::hrp::ByteIter<'_> pub fn bech32::primitives::hrp::Hrp::char_iter(&self) -> bech32::primitives::hrp::CharIter<'_> pub fn bech32::primitives::hrp::Hrp::clone(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::hrp::Hrp::cmp(&self, other: &Self) -> core::cmp::Ordering pub fn bech32::primitives::hrp::Hrp::eq(&self, other: &Self) -> bool pub fn bech32::primitives::hrp::Hrp::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::hrp::Hrp::hash(&self, h: &mut H) pub fn bech32::primitives::hrp::Hrp::is_valid_on_mainnet(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_on_regtest(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_on_signet(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_on_testnet(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_segwit(&self) -> bool pub fn bech32::primitives::hrp::Hrp::len(&self) -> usize pub fn bech32::primitives::hrp::Hrp::lowercase_byte_iter(&self) -> bech32::primitives::hrp::LowercaseByteIter<'_> pub fn bech32::primitives::hrp::Hrp::lowercase_char_iter(&self) -> bech32::primitives::hrp::LowercaseCharIter<'_> pub fn bech32::primitives::hrp::Hrp::parse(hrp: &str) -> core::result::Result pub fn bech32::primitives::hrp::Hrp::partial_cmp(&self, other: &Self) -> core::option::Option pub fn bech32::primitives::hrp::Hrp::to_lowercase(&self) -> alloc::string::String pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::iter::ByteIterExt::bytes_to_fes(self) -> bech32::primitives::iter::BytesToFes pub fn bech32::primitives::iter::BytesToFes::clone(&self) -> bech32::primitives::iter::BytesToFes pub fn bech32::primitives::iter::BytesToFes::eq(&self, other: &bech32::primitives::iter::BytesToFes) -> bool pub fn bech32::primitives::iter::BytesToFes::len(&self) -> usize pub fn bech32::primitives::iter::BytesToFes::next(&mut self) -> core::option::Option pub fn bech32::primitives::iter::BytesToFes::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::iter::Checksummed::clone(&self) -> bech32::primitives::iter::Checksummed pub fn bech32::primitives::iter::Checksummed::eq(&self, other: &bech32::primitives::iter::Checksummed) -> bool pub fn bech32::primitives::iter::Checksummed::new(data: I) -> bech32::primitives::iter::Checksummed pub fn bech32::primitives::iter::Checksummed::new_hrp(hrp: bech32::primitives::hrp::Hrp, data: I) -> bech32::primitives::iter::Checksummed pub fn bech32::primitives::iter::Checksummed::next(&mut self) -> core::option::Option pub fn bech32::primitives::iter::Checksummed::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::iter::Fe32IterExt::fes_to_bytes(self) -> bech32::primitives::iter::FesToBytes pub fn bech32::primitives::iter::Fe32IterExt::with_checksum(self, hrp: &bech32::primitives::hrp::Hrp) -> bech32::primitives::encode::Encoder<'_, Self, Ck> pub fn bech32::primitives::iter::FesToBytes::clone(&self) -> bech32::primitives::iter::FesToBytes pub fn bech32::primitives::iter::FesToBytes::eq(&self, other: &bech32::primitives::iter::FesToBytes) -> bool pub fn bech32::primitives::iter::FesToBytes::len(&self) -> usize pub fn bech32::primitives::iter::FesToBytes::next(&mut self) -> core::option::Option pub fn bech32::primitives::iter::FesToBytes::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::segwit::InvalidWitnessVersionError::clone(&self) -> bech32::primitives::segwit::InvalidWitnessVersionError pub fn bech32::primitives::segwit::InvalidWitnessVersionError::eq(&self, other: &bech32::primitives::segwit::InvalidWitnessVersionError) -> bool pub fn bech32::primitives::segwit::InvalidWitnessVersionError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::segwit::InvalidWitnessVersionError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::segwit::WitnessLengthError::clone(&self) -> bech32::primitives::segwit::WitnessLengthError pub fn bech32::primitives::segwit::WitnessLengthError::eq(&self, other: &bech32::primitives::segwit::WitnessLengthError) -> bool pub fn bech32::primitives::segwit::WitnessLengthError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::segwit::WitnessLengthError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::primitives::segwit::is_valid_witness_program_length(length: usize, witness_version: bech32::primitives::gf32::Fe32) -> bool pub fn bech32::primitives::segwit::is_valid_witness_version(witness_version: bech32::primitives::gf32::Fe32) -> bool pub fn bech32::primitives::segwit::validate_witness_program_length(length: usize, version: bech32::primitives::gf32::Fe32) -> core::result::Result<(), bech32::primitives::segwit::WitnessLengthError> pub fn bech32::primitives::segwit::validate_witness_version(witness_version: bech32::primitives::gf32::Fe32) -> core::result::Result<(), bech32::primitives::segwit::InvalidWitnessVersionError> pub fn bech32::segwit::DecodeError::clone(&self) -> bech32::segwit::DecodeError pub fn bech32::segwit::DecodeError::eq(&self, other: &bech32::segwit::DecodeError) -> bool pub fn bech32::segwit::DecodeError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::segwit::DecodeError::from(e: bech32::primitives::decode::SegwitHrpstringError) -> Self pub fn bech32::segwit::DecodeError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::segwit::EncodeError::clone(&self) -> bech32::segwit::EncodeError pub fn bech32::segwit::EncodeError::eq(&self, other: &bech32::segwit::EncodeError) -> bool pub fn bech32::segwit::EncodeError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::segwit::EncodeError::from(e: bech32::primitives::decode::SegwitCodeLengthError) -> Self pub fn bech32::segwit::EncodeError::from(e: bech32::primitives::segwit::InvalidWitnessVersionError) -> Self pub fn bech32::segwit::EncodeError::from(e: bech32::primitives::segwit::WitnessLengthError) -> Self pub fn bech32::segwit::EncodeError::from(e: core::fmt::Error) -> Self pub fn bech32::segwit::EncodeError::source(&self) -> core::option::Option<&(dyn core::error::Error + 'static)> pub fn bech32::segwit::decode(s: &str) -> core::result::Result<(bech32::primitives::hrp::Hrp, bech32::primitives::gf32::Fe32, alloc::vec::Vec), bech32::segwit::DecodeError> pub fn bech32::segwit::encode(hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::result::Result pub fn bech32::segwit::encode_lower_to_fmt_unchecked(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::fmt::Result pub fn bech32::segwit::encode_lower_to_writer_unchecked(w: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> std::io::error::Result<()> pub fn bech32::segwit::encode_to_fmt_unchecked(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::fmt::Result pub fn bech32::segwit::encode_to_writer_unchecked(w: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> std::io::error::Result<()> pub fn bech32::segwit::encode_upper_to_fmt_unchecked(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::fmt::Result pub fn bech32::segwit::encode_upper_to_writer_unchecked(w: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> std::io::error::Result<()> pub fn bech32::segwit::encode_v0(hrp: bech32::primitives::hrp::Hrp, witness_program: &[u8]) -> core::result::Result pub fn bech32::segwit::encode_v1(hrp: bech32::primitives::hrp::Hrp, witness_program: &[u8]) -> core::result::Result pub fn bech32::segwit::encoded_length(hrp: bech32::primitives::hrp::Hrp, _witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::result::Result pub fn u128::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn u128::unpack(&self, n: usize) -> u8 pub fn u32::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn u32::unpack(&self, n: usize) -> u8 pub fn u64::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn u64::unpack(&self, n: usize) -> u8 pub fn u8::from(v: bech32::primitives::gf32::Fe32) -> u8 pub mod bech32 pub mod bech32::hrp pub mod bech32::primitives pub mod bech32::primitives::checksum pub mod bech32::primitives::decode pub mod bech32::primitives::encode pub mod bech32::primitives::gf32 pub mod bech32::primitives::hrp pub mod bech32::primitives::iter pub mod bech32::primitives::segwit pub mod bech32::segwit pub struct bech32::Hrp pub struct bech32::hrp::Hrp pub struct bech32::primitives::checksum::Engine pub struct bech32::primitives::checksum::HrpFe32Iter<'hrp> pub struct bech32::primitives::checksum::PackedNull pub struct bech32::primitives::decode::AsciiToFe32Iter<'s> pub struct bech32::primitives::decode::ByteIter<'s> pub struct bech32::primitives::decode::CheckedHrpstring<'s> pub struct bech32::primitives::decode::Fe32Iter<'s> pub struct bech32::primitives::decode::SegwitHrpstring<'s> pub struct bech32::primitives::decode::UncheckedHrpstring<'s> pub struct bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator pub struct bech32::primitives::hrp::ByteIter<'b> pub struct bech32::primitives::hrp::CharIter<'b> pub struct bech32::primitives::hrp::Hrp pub struct bech32::primitives::hrp::LowercaseByteIter<'b> pub struct bech32::primitives::hrp::LowercaseCharIter<'b> pub struct bech32::primitives::iter::BytesToFes> pub struct bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::iter::FesToBytes> pub trait bech32::ByteIterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::Checksum pub trait bech32::Fe32IterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::primitives::checksum::Checksum pub trait bech32::primitives::checksum::PackedFe32: core::marker::Copy + core::cmp::PartialEq + core::cmp::Eq + core::ops::bit::BitXor pub trait bech32::primitives::iter::ByteIterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::primitives::iter::Fe32IterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub type &bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 pub type bech32::Checksum::MidstateRepr: bech32::primitives::checksum::PackedFe32 pub type bech32::primitives::Bech32::MidstateRepr = u32 pub type bech32::primitives::Bech32m::MidstateRepr = u32 pub type bech32::primitives::NoChecksum::MidstateRepr = bech32::primitives::checksum::PackedNull pub type bech32::primitives::checksum::Checksum::MidstateRepr: bech32::primitives::checksum::PackedFe32 pub type bech32::primitives::checksum::HrpFe32Iter<'hrp>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::checksum::PackedNull::Output = bech32::primitives::checksum::PackedNull pub type bech32::primitives::decode::AsciiToFe32Iter<'s>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::decode::ByteIter<'s>::Item = u8 pub type bech32::primitives::decode::Fe32Iter<'s>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::encode::ByteIter<'a, I, Ck>::Item = u8 pub type bech32::primitives::encode::CharIter<'a, I, Ck>::Item = char pub type bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::encode::WitnessVersionIter::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::gf32::Fe32::Error = bech32::primitives::gf32::TryFromError pub type bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 pub type bech32::primitives::hrp::ByteIter<'b>::Item = u8 pub type bech32::primitives::hrp::CharIter<'b>::Item = char pub type bech32::primitives::hrp::LowercaseByteIter<'b>::Item = u8 pub type bech32::primitives::hrp::LowercaseCharIter<'b>::Item = char pub type bech32::primitives::iter::BytesToFes::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::iter::Checksummed::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::iter::FesToBytes::Item = u8 bech32-0.11.0/api/alloc-only.txt000064400000000000000000002702151046102023000143430ustar 00000000000000#[non_exhaustive] pub enum bech32::DecodeError #[non_exhaustive] pub enum bech32::EncodeError #[non_exhaustive] pub enum bech32::primitives::decode::CharError #[non_exhaustive] pub enum bech32::primitives::decode::CheckedHrpstringError #[non_exhaustive] pub enum bech32::primitives::decode::ChecksumError #[non_exhaustive] pub enum bech32::primitives::decode::PaddingError #[non_exhaustive] pub enum bech32::primitives::decode::SegwitHrpstringError #[non_exhaustive] pub enum bech32::primitives::decode::UncheckedHrpstringError #[non_exhaustive] pub enum bech32::primitives::gf32::FromCharError #[non_exhaustive] pub enum bech32::primitives::gf32::TryFromError #[non_exhaustive] pub enum bech32::primitives::hrp::Error #[non_exhaustive] pub enum bech32::primitives::segwit::WitnessLengthError #[non_exhaustive] pub enum bech32::segwit::EncodeError #[non_exhaustive] pub struct bech32::primitives::decode::CodeLengthError #[non_exhaustive] pub struct bech32::primitives::decode::SegwitCodeLengthError(pub usize) #[non_exhaustive] pub struct bech32::primitives::segwit::InvalidWitnessVersionError(pub bech32::primitives::gf32::Fe32) #[non_exhaustive] pub struct bech32::segwit::DecodeError(pub bech32::primitives::decode::SegwitHrpstringError) #[repr(transparent)] pub struct bech32::Fe32(_) #[repr(transparent)] pub struct bech32::primitives::gf32::Fe32(_) impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32 impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32m impl bech32::primitives::checksum::Checksum for bech32::primitives::NoChecksum impl bech32::primitives::checksum::PackedFe32 for bech32::primitives::checksum::PackedNull impl bech32::primitives::checksum::PackedFe32 for u128 impl bech32::primitives::checksum::PackedFe32 for u32 impl bech32::primitives::checksum::PackedFe32 for u64 impl bech32::primitives::gf32::Fe32 impl bech32::primitives::hrp::Hrp impl core::clone::Clone for bech32::DecodeError impl core::clone::Clone for bech32::EncodeError impl core::clone::Clone for bech32::primitives::Bech32 impl core::clone::Clone for bech32::primitives::Bech32m impl core::clone::Clone for bech32::primitives::NoChecksum impl core::clone::Clone for bech32::primitives::checksum::PackedNull impl core::clone::Clone for bech32::primitives::decode::CharError impl core::clone::Clone for bech32::primitives::decode::CheckedHrpstringError impl core::clone::Clone for bech32::primitives::decode::ChecksumError impl core::clone::Clone for bech32::primitives::decode::CodeLengthError impl core::clone::Clone for bech32::primitives::decode::PaddingError impl core::clone::Clone for bech32::primitives::decode::SegwitCodeLengthError impl core::clone::Clone for bech32::primitives::decode::SegwitHrpstringError impl core::clone::Clone for bech32::primitives::decode::UncheckedHrpstringError impl core::clone::Clone for bech32::primitives::gf32::Fe32 impl core::clone::Clone for bech32::primitives::gf32::FromCharError impl core::clone::Clone for bech32::primitives::gf32::TryFromError impl core::clone::Clone for bech32::primitives::hrp::Error impl core::clone::Clone for bech32::primitives::hrp::Hrp impl core::clone::Clone for bech32::primitives::segwit::InvalidWitnessVersionError impl core::clone::Clone for bech32::primitives::segwit::WitnessLengthError impl core::clone::Clone for bech32::segwit::DecodeError impl core::clone::Clone for bech32::segwit::EncodeError impl core::cmp::Eq for bech32::DecodeError impl core::cmp::Eq for bech32::EncodeError impl core::cmp::Eq for bech32::primitives::Bech32 impl core::cmp::Eq for bech32::primitives::Bech32m impl core::cmp::Eq for bech32::primitives::NoChecksum impl core::cmp::Eq for bech32::primitives::checksum::PackedNull impl core::cmp::Eq for bech32::primitives::decode::CharError impl core::cmp::Eq for bech32::primitives::decode::CheckedHrpstringError impl core::cmp::Eq for bech32::primitives::decode::ChecksumError impl core::cmp::Eq for bech32::primitives::decode::CodeLengthError impl core::cmp::Eq for bech32::primitives::decode::PaddingError impl core::cmp::Eq for bech32::primitives::decode::SegwitCodeLengthError impl core::cmp::Eq for bech32::primitives::decode::SegwitHrpstringError impl core::cmp::Eq for bech32::primitives::decode::UncheckedHrpstringError impl core::cmp::Eq for bech32::primitives::gf32::Fe32 impl core::cmp::Eq for bech32::primitives::gf32::FromCharError impl core::cmp::Eq for bech32::primitives::gf32::TryFromError impl core::cmp::Eq for bech32::primitives::hrp::Error impl core::cmp::Eq for bech32::primitives::hrp::Hrp impl core::cmp::Eq for bech32::primitives::segwit::InvalidWitnessVersionError impl core::cmp::Eq for bech32::primitives::segwit::WitnessLengthError impl core::cmp::Eq for bech32::segwit::DecodeError impl core::cmp::Eq for bech32::segwit::EncodeError impl core::cmp::Ord for bech32::primitives::Bech32 impl core::cmp::Ord for bech32::primitives::Bech32m impl core::cmp::Ord for bech32::primitives::NoChecksum impl core::cmp::Ord for bech32::primitives::hrp::Hrp impl core::cmp::PartialEq for bech32::DecodeError impl core::cmp::PartialEq for bech32::EncodeError impl core::cmp::PartialEq for bech32::primitives::Bech32 impl core::cmp::PartialEq for bech32::primitives::Bech32m impl core::cmp::PartialEq for bech32::primitives::NoChecksum impl core::cmp::PartialEq for bech32::primitives::checksum::PackedNull impl core::cmp::PartialEq for bech32::primitives::decode::CharError impl core::cmp::PartialEq for bech32::primitives::decode::CheckedHrpstringError impl core::cmp::PartialEq for bech32::primitives::decode::ChecksumError impl core::cmp::PartialEq for bech32::primitives::decode::CodeLengthError impl core::cmp::PartialEq for bech32::primitives::decode::PaddingError impl core::cmp::PartialEq for bech32::primitives::decode::SegwitCodeLengthError impl core::cmp::PartialEq for bech32::primitives::decode::SegwitHrpstringError impl core::cmp::PartialEq for bech32::primitives::decode::UncheckedHrpstringError impl core::cmp::PartialEq for bech32::primitives::gf32::Fe32 impl core::cmp::PartialEq for bech32::primitives::gf32::FromCharError impl core::cmp::PartialEq for bech32::primitives::gf32::TryFromError impl core::cmp::PartialEq for bech32::primitives::hrp::Error impl core::cmp::PartialEq for bech32::primitives::hrp::Hrp impl core::cmp::PartialEq for bech32::primitives::segwit::InvalidWitnessVersionError impl core::cmp::PartialEq for bech32::primitives::segwit::WitnessLengthError impl core::cmp::PartialEq for bech32::segwit::DecodeError impl core::cmp::PartialEq for bech32::segwit::EncodeError impl core::cmp::PartialOrd for bech32::primitives::Bech32 impl core::cmp::PartialOrd for bech32::primitives::Bech32m impl core::cmp::PartialOrd for bech32::primitives::NoChecksum impl core::cmp::PartialOrd for bech32::primitives::hrp::Hrp impl core::convert::AsRef for bech32::primitives::gf32::Fe32 impl core::convert::From for bech32::primitives::decode::UncheckedHrpstringError impl core::convert::From for bech32::primitives::decode::CheckedHrpstringError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for bech32::EncodeError impl core::convert::From for bech32::primitives::decode::SegwitCodeLengthError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for bech32::segwit::EncodeError impl core::convert::From for bech32::segwit::DecodeError impl core::convert::From for bech32::DecodeError impl core::convert::From for bech32::primitives::decode::CheckedHrpstringError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for u8 impl core::convert::From for bech32::primitives::decode::UncheckedHrpstringError impl core::convert::From for bech32::segwit::EncodeError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for bech32::segwit::EncodeError impl core::convert::From for bech32::primitives::gf32::TryFromError impl core::convert::From for bech32::EncodeError impl core::convert::From for bech32::segwit::EncodeError impl core::convert::From for bech32::primitives::gf32::TryFromError impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::fmt::Debug for bech32::DecodeError impl core::fmt::Debug for bech32::EncodeError impl core::fmt::Debug for bech32::primitives::checksum::PackedNull impl core::fmt::Debug for bech32::primitives::decode::CharError impl core::fmt::Debug for bech32::primitives::decode::CheckedHrpstringError impl core::fmt::Debug for bech32::primitives::decode::ChecksumError impl core::fmt::Debug for bech32::primitives::decode::CodeLengthError impl core::fmt::Debug for bech32::primitives::decode::PaddingError impl core::fmt::Debug for bech32::primitives::decode::SegwitCodeLengthError impl core::fmt::Debug for bech32::primitives::decode::SegwitHrpstringError impl core::fmt::Debug for bech32::primitives::decode::UncheckedHrpstringError impl core::fmt::Debug for bech32::primitives::gf32::Fe32 impl core::fmt::Debug for bech32::primitives::gf32::FromCharError impl core::fmt::Debug for bech32::primitives::gf32::TryFromError impl core::fmt::Debug for bech32::primitives::hrp::Error impl core::fmt::Debug for bech32::primitives::hrp::Hrp impl core::fmt::Debug for bech32::primitives::segwit::InvalidWitnessVersionError impl core::fmt::Debug for bech32::primitives::segwit::WitnessLengthError impl core::fmt::Debug for bech32::segwit::DecodeError impl core::fmt::Debug for bech32::segwit::EncodeError impl core::fmt::Display for bech32::DecodeError impl core::fmt::Display for bech32::EncodeError impl core::fmt::Display for bech32::primitives::decode::CharError impl core::fmt::Display for bech32::primitives::decode::CheckedHrpstringError impl core::fmt::Display for bech32::primitives::decode::ChecksumError impl core::fmt::Display for bech32::primitives::decode::CodeLengthError impl core::fmt::Display for bech32::primitives::decode::PaddingError impl core::fmt::Display for bech32::primitives::decode::SegwitCodeLengthError impl core::fmt::Display for bech32::primitives::decode::SegwitHrpstringError impl core::fmt::Display for bech32::primitives::decode::UncheckedHrpstringError impl core::fmt::Display for bech32::primitives::gf32::Fe32 impl core::fmt::Display for bech32::primitives::gf32::FromCharError impl core::fmt::Display for bech32::primitives::gf32::TryFromError impl core::fmt::Display for bech32::primitives::hrp::Error impl core::fmt::Display for bech32::primitives::hrp::Hrp impl core::fmt::Display for bech32::primitives::segwit::InvalidWitnessVersionError impl core::fmt::Display for bech32::primitives::segwit::WitnessLengthError impl core::fmt::Display for bech32::segwit::DecodeError impl core::fmt::Display for bech32::segwit::EncodeError impl core::hash::Hash for bech32::primitives::Bech32 impl core::hash::Hash for bech32::primitives::Bech32m impl core::hash::Hash for bech32::primitives::NoChecksum impl core::hash::Hash for bech32::primitives::gf32::Fe32 impl core::hash::Hash for bech32::primitives::hrp::Hrp impl core::marker::Copy for bech32::primitives::Bech32 impl core::marker::Copy for bech32::primitives::Bech32m impl core::marker::Copy for bech32::primitives::NoChecksum impl core::marker::Copy for bech32::primitives::checksum::PackedNull impl core::marker::Copy for bech32::primitives::gf32::Fe32 impl core::marker::Copy for bech32::primitives::gf32::FromCharError impl core::marker::Copy for bech32::primitives::gf32::TryFromError impl core::marker::Copy for bech32::primitives::hrp::Hrp impl core::marker::Send for bech32::DecodeError impl core::marker::Send for bech32::EncodeError impl core::marker::Send for bech32::primitives::Bech32 impl core::marker::Send for bech32::primitives::Bech32m impl core::marker::Send for bech32::primitives::NoChecksum impl core::marker::Send for bech32::primitives::checksum::PackedNull impl core::marker::Send for bech32::primitives::decode::CharError impl core::marker::Send for bech32::primitives::decode::CheckedHrpstringError impl core::marker::Send for bech32::primitives::decode::ChecksumError impl core::marker::Send for bech32::primitives::decode::CodeLengthError impl core::marker::Send for bech32::primitives::decode::PaddingError impl core::marker::Send for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::Send for bech32::primitives::decode::SegwitHrpstringError impl core::marker::Send for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::Send for bech32::primitives::gf32::Fe32 impl core::marker::Send for bech32::primitives::gf32::FromCharError impl core::marker::Send for bech32::primitives::gf32::TryFromError impl core::marker::Send for bech32::primitives::hrp::Error impl core::marker::Send for bech32::primitives::hrp::Hrp impl core::marker::Send for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::Send for bech32::primitives::segwit::WitnessLengthError impl core::marker::Send for bech32::segwit::DecodeError impl core::marker::Send for bech32::segwit::EncodeError impl core::marker::StructuralPartialEq for bech32::DecodeError impl core::marker::StructuralPartialEq for bech32::EncodeError impl core::marker::StructuralPartialEq for bech32::primitives::Bech32 impl core::marker::StructuralPartialEq for bech32::primitives::Bech32m impl core::marker::StructuralPartialEq for bech32::primitives::NoChecksum impl core::marker::StructuralPartialEq for bech32::primitives::checksum::PackedNull impl core::marker::StructuralPartialEq for bech32::primitives::decode::CharError impl core::marker::StructuralPartialEq for bech32::primitives::decode::CheckedHrpstringError impl core::marker::StructuralPartialEq for bech32::primitives::decode::ChecksumError impl core::marker::StructuralPartialEq for bech32::primitives::decode::CodeLengthError impl core::marker::StructuralPartialEq for bech32::primitives::decode::PaddingError impl core::marker::StructuralPartialEq for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::StructuralPartialEq for bech32::primitives::decode::SegwitHrpstringError impl core::marker::StructuralPartialEq for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::StructuralPartialEq for bech32::primitives::gf32::Fe32 impl core::marker::StructuralPartialEq for bech32::primitives::gf32::FromCharError impl core::marker::StructuralPartialEq for bech32::primitives::gf32::TryFromError impl core::marker::StructuralPartialEq for bech32::primitives::hrp::Error impl core::marker::StructuralPartialEq for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::StructuralPartialEq for bech32::primitives::segwit::WitnessLengthError impl core::marker::StructuralPartialEq for bech32::segwit::DecodeError impl core::marker::StructuralPartialEq for bech32::segwit::EncodeError impl core::marker::Sync for bech32::DecodeError impl core::marker::Sync for bech32::EncodeError impl core::marker::Sync for bech32::primitives::Bech32 impl core::marker::Sync for bech32::primitives::Bech32m impl core::marker::Sync for bech32::primitives::NoChecksum impl core::marker::Sync for bech32::primitives::checksum::PackedNull impl core::marker::Sync for bech32::primitives::decode::CharError impl core::marker::Sync for bech32::primitives::decode::CheckedHrpstringError impl core::marker::Sync for bech32::primitives::decode::ChecksumError impl core::marker::Sync for bech32::primitives::decode::CodeLengthError impl core::marker::Sync for bech32::primitives::decode::PaddingError impl core::marker::Sync for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::Sync for bech32::primitives::decode::SegwitHrpstringError impl core::marker::Sync for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::Sync for bech32::primitives::gf32::Fe32 impl core::marker::Sync for bech32::primitives::gf32::FromCharError impl core::marker::Sync for bech32::primitives::gf32::TryFromError impl core::marker::Sync for bech32::primitives::hrp::Error impl core::marker::Sync for bech32::primitives::hrp::Hrp impl core::marker::Sync for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::Sync for bech32::primitives::segwit::WitnessLengthError impl core::marker::Sync for bech32::segwit::DecodeError impl core::marker::Sync for bech32::segwit::EncodeError impl core::marker::Unpin for bech32::DecodeError impl core::marker::Unpin for bech32::EncodeError impl core::marker::Unpin for bech32::primitives::Bech32 impl core::marker::Unpin for bech32::primitives::Bech32m impl core::marker::Unpin for bech32::primitives::NoChecksum impl core::marker::Unpin for bech32::primitives::checksum::PackedNull impl core::marker::Unpin for bech32::primitives::decode::CharError impl core::marker::Unpin for bech32::primitives::decode::CheckedHrpstringError impl core::marker::Unpin for bech32::primitives::decode::ChecksumError impl core::marker::Unpin for bech32::primitives::decode::CodeLengthError impl core::marker::Unpin for bech32::primitives::decode::PaddingError impl core::marker::Unpin for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::Unpin for bech32::primitives::decode::SegwitHrpstringError impl core::marker::Unpin for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::Unpin for bech32::primitives::gf32::Fe32 impl core::marker::Unpin for bech32::primitives::gf32::FromCharError impl core::marker::Unpin for bech32::primitives::gf32::TryFromError impl core::marker::Unpin for bech32::primitives::hrp::Error impl core::marker::Unpin for bech32::primitives::hrp::Hrp impl core::marker::Unpin for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::Unpin for bech32::primitives::segwit::WitnessLengthError impl core::marker::Unpin for bech32::segwit::DecodeError impl core::marker::Unpin for bech32::segwit::EncodeError impl core::ops::arith::Add for bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Add for &bech32::primitives::gf32::Fe32 impl core::ops::arith::AddAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div for &bech32::primitives::gf32::Fe32 impl core::ops::arith::DivAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul for &bech32::primitives::gf32::Fe32 impl core::ops::arith::MulAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub for &bech32::primitives::gf32::Fe32 impl core::ops::arith::SubAssign for bech32::primitives::gf32::Fe32 impl core::ops::bit::BitXor for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::RefUnwindSafe for bech32::DecodeError impl core::panic::unwind_safe::RefUnwindSafe for bech32::EncodeError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::Bech32 impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::Bech32m impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::NoChecksum impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CharError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CheckedHrpstringError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::ChecksumError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CodeLengthError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::PaddingError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::SegwitCodeLengthError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::SegwitHrpstringError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::UncheckedHrpstringError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32::Fe32 impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32::FromCharError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32::TryFromError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::Error impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::Hrp impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::segwit::InvalidWitnessVersionError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::segwit::WitnessLengthError impl core::panic::unwind_safe::RefUnwindSafe for bech32::segwit::DecodeError impl core::panic::unwind_safe::RefUnwindSafe for bech32::segwit::EncodeError impl core::panic::unwind_safe::UnwindSafe for bech32::DecodeError impl core::panic::unwind_safe::UnwindSafe for bech32::EncodeError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::Bech32 impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::Bech32m impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::NoChecksum impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CharError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CheckedHrpstringError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::ChecksumError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CodeLengthError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::PaddingError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::SegwitCodeLengthError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::SegwitHrpstringError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::UncheckedHrpstringError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32::Fe32 impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32::FromCharError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32::TryFromError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::Error impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::Hrp impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::segwit::InvalidWitnessVersionError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::segwit::WitnessLengthError impl core::panic::unwind_safe::UnwindSafe for bech32::segwit::DecodeError impl core::panic::unwind_safe::UnwindSafe for bech32::segwit::EncodeError impl<'a, I, Ck> core::iter::traits::iterator::Iterator for bech32::primitives::encode::ByteIter<'a, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'a, I, Ck> core::iter::traits::iterator::Iterator for bech32::primitives::encode::CharIter<'a, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::CharIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::CharIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::CharIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::CharIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::CharIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'hrp, I, Ck> bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> core::clone::Clone for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator + core::clone::Clone, Ck: bech32::primitives::checksum::Checksum + core::clone::Clone impl<'hrp, I, Ck> core::cmp::Eq for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator + core::cmp::Eq, Ck: bech32::primitives::checksum::Checksum + core::cmp::Eq impl<'hrp, I, Ck> core::cmp::PartialEq for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator + core::cmp::PartialEq, Ck: bech32::primitives::checksum::Checksum + core::cmp::PartialEq impl<'hrp, I, Ck> core::iter::traits::iterator::Iterator for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::marker::Send, I: core::marker::Send impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl<'hrp, I, Ck> core::marker::StructuralPartialEq for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::marker::Sync, I: core::marker::Sync impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::marker::Unpin, I: core::marker::Unpin impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::panic::unwind_safe::RefUnwindSafe, I: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::panic::unwind_safe::UnwindSafe, I: core::panic::unwind_safe::UnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl<'hrp> bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::iter::traits::iterator::Iterator for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::marker::Send for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::marker::Sync for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::marker::Unpin for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::panic::unwind_safe::UnwindSafe for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'s> bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::fmt::Debug for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::fmt::Debug for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::fmt::Debug for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::decode::ByteIter<'s> impl<'s> core::iter::traits::iterator::Iterator for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::iter::traits::iterator::Iterator for bech32::primitives::decode::ByteIter<'s> impl<'s> core::iter::traits::iterator::Iterator for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::ByteIter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::marker::Send for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::marker::Send for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::ByteIter<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::ByteIter<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::ByteIter<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::ByteIter<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::UncheckedHrpstring<'s> impl bech32::primitives::checksum::Engine impl core::default::Default for bech32::primitives::checksum::Engine impl core::marker::StructuralPartialEq for bech32::primitives::checksum::Engine impl core::clone::Clone for bech32::primitives::checksum::Engine where ::MidstateRepr: core::clone::Clone impl core::cmp::Eq for bech32::primitives::checksum::Engine where ::MidstateRepr: core::cmp::Eq impl core::cmp::PartialEq for bech32::primitives::checksum::Engine where ::MidstateRepr: core::cmp::PartialEq impl core::fmt::Debug for bech32::primitives::checksum::Engine where ::MidstateRepr: core::fmt::Debug impl core::marker::Copy for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Copy impl core::marker::Send for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Send impl core::marker::Sync for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Sync impl core::marker::Unpin for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Unpin impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::checksum::Engine where ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::checksum::Engine where ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl core::clone::Clone for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator + core::clone::Clone, Ck: bech32::primitives::checksum::Checksum + core::clone::Clone impl core::cmp::Eq for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator + core::cmp::Eq, Ck: bech32::primitives::checksum::Checksum + core::cmp::Eq impl core::cmp::PartialEq for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator + core::cmp::PartialEq, Ck: bech32::primitives::checksum::Checksum + core::cmp::PartialEq impl core::iter::traits::iterator::Iterator for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl core::marker::Send for bech32::primitives::iter::Checksummed where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl core::marker::StructuralPartialEq for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl core::marker::Sync for bech32::primitives::iter::Checksummed where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl core::marker::Unpin for bech32::primitives::iter::Checksummed where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::Checksummed where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::Checksummed where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl> core::clone::Clone for bech32::primitives::iter::FesToBytes impl> core::clone::Clone for bech32::primitives::iter::BytesToFes impl> core::cmp::Eq for bech32::primitives::iter::FesToBytes impl> core::cmp::Eq for bech32::primitives::iter::BytesToFes impl> core::cmp::PartialEq for bech32::primitives::iter::FesToBytes impl> core::cmp::PartialEq for bech32::primitives::iter::BytesToFes impl> core::marker::StructuralPartialEq for bech32::primitives::iter::FesToBytes impl> core::marker::StructuralPartialEq for bech32::primitives::iter::BytesToFes impl bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator impl bech32::primitives::iter::ByteIterExt for I where I: core::iter::traits::iterator::Iterator impl bech32::primitives::iter::Fe32IterExt for I where I: core::iter::traits::iterator::Iterator impl core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::iter::BytesToFes where I: core::iter::traits::iterator::Iterator + core::iter::traits::exact_size::ExactSizeIterator impl core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::iter::FesToBytes where I: core::iter::traits::iterator::Iterator + core::iter::traits::exact_size::ExactSizeIterator impl core::iter::traits::iterator::Iterator for bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator impl core::iter::traits::iterator::Iterator for bech32::primitives::iter::BytesToFes where I: core::iter::traits::iterator::Iterator impl core::iter::traits::iterator::Iterator for bech32::primitives::iter::FesToBytes where I: core::iter::traits::iterator::Iterator impl core::marker::Send for bech32::primitives::encode::WitnessVersionIter where I: core::marker::Send impl core::marker::Send for bech32::primitives::iter::BytesToFes where I: core::marker::Send impl core::marker::Send for bech32::primitives::iter::FesToBytes where I: core::marker::Send impl core::marker::Sync for bech32::primitives::encode::WitnessVersionIter where I: core::marker::Sync impl core::marker::Sync for bech32::primitives::iter::BytesToFes where I: core::marker::Sync impl core::marker::Sync for bech32::primitives::iter::FesToBytes where I: core::marker::Sync impl core::marker::Unpin for bech32::primitives::encode::WitnessVersionIter where I: core::marker::Unpin impl core::marker::Unpin for bech32::primitives::iter::BytesToFes where I: core::marker::Unpin impl core::marker::Unpin for bech32::primitives::iter::FesToBytes where I: core::marker::Unpin impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::WitnessVersionIter where I: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::BytesToFes where I: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::FesToBytes where I: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::WitnessVersionIter where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::BytesToFes where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::FesToBytes where I: core::panic::unwind_safe::UnwindSafe pub bech32::DecodeError::Checksum(bech32::primitives::decode::ChecksumError) pub bech32::DecodeError::Parse(bech32::primitives::decode::UncheckedHrpstringError) pub bech32::EncodeError::Fmt(core::fmt::Error) pub bech32::EncodeError::TooLong(bech32::primitives::decode::CodeLengthError) pub bech32::primitives::decode::CharError::InvalidChar(char) pub bech32::primitives::decode::CharError::MissingSeparator pub bech32::primitives::decode::CharError::MixedCase pub bech32::primitives::decode::CharError::NothingAfterSeparator pub bech32::primitives::decode::CheckedHrpstringError::Checksum(bech32::primitives::decode::ChecksumError) pub bech32::primitives::decode::CheckedHrpstringError::Parse(bech32::primitives::decode::UncheckedHrpstringError) pub bech32::primitives::decode::ChecksumError::CodeLength(bech32::primitives::decode::CodeLengthError) pub bech32::primitives::decode::ChecksumError::InvalidLength pub bech32::primitives::decode::ChecksumError::InvalidResidue pub bech32::primitives::decode::CodeLengthError::code_length: usize pub bech32::primitives::decode::CodeLengthError::encoded_length: usize pub bech32::primitives::decode::PaddingError::NonZero pub bech32::primitives::decode::PaddingError::TooMuch pub bech32::primitives::decode::SegwitHrpstringError::Checksum(bech32::primitives::decode::ChecksumError) pub bech32::primitives::decode::SegwitHrpstringError::InvalidWitnessVersion(bech32::primitives::gf32::Fe32) pub bech32::primitives::decode::SegwitHrpstringError::NoData pub bech32::primitives::decode::SegwitHrpstringError::Padding(bech32::primitives::decode::PaddingError) pub bech32::primitives::decode::SegwitHrpstringError::TooLong(usize) pub bech32::primitives::decode::SegwitHrpstringError::Unchecked(bech32::primitives::decode::UncheckedHrpstringError) pub bech32::primitives::decode::SegwitHrpstringError::WitnessLength(bech32::primitives::segwit::WitnessLengthError) pub bech32::primitives::decode::UncheckedHrpstringError::Char(bech32::primitives::decode::CharError) pub bech32::primitives::decode::UncheckedHrpstringError::Hrp(bech32::primitives::hrp::Error) pub bech32::primitives::gf32::FromCharError::Invalid(char) pub bech32::primitives::gf32::FromCharError::NotAscii(char) pub bech32::primitives::gf32::TryFromError::InvalidByte(u8) pub bech32::primitives::gf32::TryFromError::NotAByte(core::num::error::TryFromIntError) pub bech32::primitives::hrp::Error::Empty pub bech32::primitives::hrp::Error::InvalidAsciiByte(u8) pub bech32::primitives::hrp::Error::MixedCase pub bech32::primitives::hrp::Error::NonAsciiChar(char) pub bech32::primitives::hrp::Error::TooLong(usize) pub bech32::primitives::segwit::WitnessLengthError::InvalidSegwitV0 pub bech32::primitives::segwit::WitnessLengthError::TooLong pub bech32::primitives::segwit::WitnessLengthError::TooShort pub bech32::segwit::EncodeError::Fmt(core::fmt::Error) pub bech32::segwit::EncodeError::TooLong(bech32::primitives::decode::SegwitCodeLengthError) pub bech32::segwit::EncodeError::WitnessLength(bech32::primitives::segwit::WitnessLengthError) pub bech32::segwit::EncodeError::WitnessVersion(bech32::primitives::segwit::InvalidWitnessVersionError) pub const bech32::Checksum::CHECKSUM_LENGTH: usize pub const bech32::Checksum::CODE_LENGTH: usize pub const bech32::Checksum::GENERATOR_SH: [Self::MidstateRepr; 5] pub const bech32::Checksum::TARGET_RESIDUE: Self::MidstateRepr pub const bech32::hrp::BC: _ pub const bech32::hrp::BCRT: _ pub const bech32::hrp::TB: _ pub const bech32::primitives::Bech32::CHECKSUM_LENGTH: usize pub const bech32::primitives::Bech32::CODE_LENGTH: usize pub const bech32::primitives::Bech32::GENERATOR_SH: [u32; 5] pub const bech32::primitives::Bech32::TARGET_RESIDUE: u32 pub const bech32::primitives::Bech32m::CHECKSUM_LENGTH: usize pub const bech32::primitives::Bech32m::CODE_LENGTH: usize pub const bech32::primitives::Bech32m::GENERATOR_SH: [u32; 5] pub const bech32::primitives::Bech32m::TARGET_RESIDUE: u32 pub const bech32::primitives::NoChecksum::CHECKSUM_LENGTH: usize pub const bech32::primitives::NoChecksum::CODE_LENGTH: usize pub const bech32::primitives::NoChecksum::GENERATOR_SH: [bech32::primitives::checksum::PackedNull; 5] pub const bech32::primitives::NoChecksum::TARGET_RESIDUE: bech32::primitives::checksum::PackedNull pub const bech32::primitives::checksum::Checksum::CHECKSUM_LENGTH: usize pub const bech32::primitives::checksum::Checksum::CODE_LENGTH: usize pub const bech32::primitives::checksum::Checksum::GENERATOR_SH: [Self::MidstateRepr; 5] pub const bech32::primitives::checksum::Checksum::TARGET_RESIDUE: Self::MidstateRepr pub const bech32::primitives::checksum::PackedFe32::ONE: Self pub const bech32::primitives::checksum::PackedFe32::WIDTH: usize pub const bech32::primitives::checksum::PackedNull::ONE: Self pub const bech32::primitives::gf32::Fe32::A: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::C: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::D: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::E: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::F: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::G: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::H: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::J: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::K: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::L: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::M: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::N: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::P: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::Q: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::R: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::S: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::T: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::U: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::V: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::W: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::X: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::Y: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::Z: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_0: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_2: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_3: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_4: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_5: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_6: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_7: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_8: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_9: bech32::primitives::gf32::Fe32 pub const bech32::primitives::hrp::BC: _ pub const bech32::primitives::hrp::BCRT: _ pub const bech32::primitives::hrp::TB: _ pub const bech32::primitives::segwit::MAX_STRING_LENGTH: usize = 90usize pub const bech32::primitives::segwit::VERSION_0: Fe32::Q pub const bech32::primitives::segwit::VERSION_1: Fe32::P pub const bech32::segwit::VERSION_0: Fe32::Q pub const bech32::segwit::VERSION_1: Fe32::P pub const fn bech32::primitives::hrp::Hrp::parse_unchecked(hrp: &str) -> Self pub const u128::ONE: Self pub const u32::ONE: Self pub const u64::ONE: Self pub enum bech32::Bech32 pub enum bech32::Bech32m pub enum bech32::NoChecksum pub enum bech32::primitives::Bech32 pub enum bech32::primitives::Bech32m pub enum bech32::primitives::NoChecksum pub fn &bech32::primitives::gf32::Fe32::add(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::add(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::div(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::div(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::mul(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::mul(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::ByteIterExt::bytes_to_fes(self) -> bech32::primitives::iter::BytesToFes pub fn bech32::Checksum::sanity_check() pub fn bech32::DecodeError::clone(&self) -> bech32::DecodeError pub fn bech32::DecodeError::eq(&self, other: &bech32::DecodeError) -> bool pub fn bech32::DecodeError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::DecodeError::from(e: bech32::primitives::decode::UncheckedHrpstringError) -> Self pub fn bech32::EncodeError::clone(&self) -> bech32::EncodeError pub fn bech32::EncodeError::eq(&self, other: &bech32::EncodeError) -> bool pub fn bech32::EncodeError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::EncodeError::from(e: bech32::primitives::decode::CodeLengthError) -> Self pub fn bech32::EncodeError::from(e: core::fmt::Error) -> Self pub fn bech32::Fe32IterExt::fes_to_bytes(self) -> bech32::primitives::iter::FesToBytes pub fn bech32::Fe32IterExt::with_checksum(self, hrp: &bech32::primitives::hrp::Hrp) -> bech32::primitives::encode::Encoder<'_, Self, Ck> pub fn bech32::decode(s: &str) -> core::result::Result<(bech32::primitives::hrp::Hrp, alloc::vec::Vec), bech32::DecodeError> pub fn bech32::encode(hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result pub fn bech32::encode_lower(hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result pub fn bech32::encode_lower_to_fmt(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeError> pub fn bech32::encode_to_fmt(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeError> pub fn bech32::encode_upper(hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result pub fn bech32::encode_upper_to_fmt(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeError> pub fn bech32::encoded_length(hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result pub fn bech32::primitives::Bech32::clone(&self) -> bech32::primitives::Bech32 pub fn bech32::primitives::Bech32::cmp(&self, other: &bech32::primitives::Bech32) -> core::cmp::Ordering pub fn bech32::primitives::Bech32::eq(&self, other: &bech32::primitives::Bech32) -> bool pub fn bech32::primitives::Bech32::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::Bech32::partial_cmp(&self, other: &bech32::primitives::Bech32) -> core::option::Option pub fn bech32::primitives::Bech32m::clone(&self) -> bech32::primitives::Bech32m pub fn bech32::primitives::Bech32m::cmp(&self, other: &bech32::primitives::Bech32m) -> core::cmp::Ordering pub fn bech32::primitives::Bech32m::eq(&self, other: &bech32::primitives::Bech32m) -> bool pub fn bech32::primitives::Bech32m::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::Bech32m::partial_cmp(&self, other: &bech32::primitives::Bech32m) -> core::option::Option pub fn bech32::primitives::NoChecksum::clone(&self) -> bech32::primitives::NoChecksum pub fn bech32::primitives::NoChecksum::cmp(&self, other: &bech32::primitives::NoChecksum) -> core::cmp::Ordering pub fn bech32::primitives::NoChecksum::eq(&self, other: &bech32::primitives::NoChecksum) -> bool pub fn bech32::primitives::NoChecksum::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::NoChecksum::partial_cmp(&self, other: &bech32::primitives::NoChecksum) -> core::option::Option pub fn bech32::primitives::checksum::Checksum::sanity_check() pub fn bech32::primitives::checksum::Engine::clone(&self) -> bech32::primitives::checksum::Engine pub fn bech32::primitives::checksum::Engine::default() -> Self pub fn bech32::primitives::checksum::Engine::eq(&self, other: &bech32::primitives::checksum::Engine) -> bool pub fn bech32::primitives::checksum::Engine::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::checksum::Engine::input_fe(&mut self, e: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::checksum::Engine::input_hrp(&mut self, hrp: bech32::primitives::hrp::Hrp) pub fn bech32::primitives::checksum::Engine::input_target_residue(&mut self) pub fn bech32::primitives::checksum::Engine::new() -> Self pub fn bech32::primitives::checksum::Engine::residue(&self) -> &::MidstateRepr pub fn bech32::primitives::checksum::HrpFe32Iter<'hrp>::new(hrp: &'hrp bech32::primitives::hrp::Hrp) -> Self pub fn bech32::primitives::checksum::HrpFe32Iter<'hrp>::next(&mut self) -> core::option::Option pub fn bech32::primitives::checksum::HrpFe32Iter<'hrp>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::checksum::PackedFe32::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn bech32::primitives::checksum::PackedFe32::unpack(&self, n: usize) -> u8 pub fn bech32::primitives::checksum::PackedNull::bitxor(self, bech32::primitives::checksum::PackedNull) -> bech32::primitives::checksum::PackedNull pub fn bech32::primitives::checksum::PackedNull::clone(&self) -> bech32::primitives::checksum::PackedNull pub fn bech32::primitives::checksum::PackedNull::eq(&self, other: &bech32::primitives::checksum::PackedNull) -> bool pub fn bech32::primitives::checksum::PackedNull::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::checksum::PackedNull::mul_by_x_then_add(&mut self, usize, u8) -> u8 pub fn bech32::primitives::checksum::PackedNull::unpack(&self, usize) -> u8 pub fn bech32::primitives::decode::AsciiToFe32Iter<'s>::len(&self) -> usize pub fn bech32::primitives::decode::AsciiToFe32Iter<'s>::next(&mut self) -> core::option::Option pub fn bech32::primitives::decode::AsciiToFe32Iter<'s>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::decode::ByteIter<'s>::len(&self) -> usize pub fn bech32::primitives::decode::ByteIter<'s>::next(&mut self) -> core::option::Option pub fn bech32::primitives::decode::ByteIter<'s>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::decode::CharError::clone(&self) -> bech32::primitives::decode::CharError pub fn bech32::primitives::decode::CharError::eq(&self, other: &bech32::primitives::decode::CharError) -> bool pub fn bech32::primitives::decode::CharError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CheckedHrpstring<'s>::byte_iter(&self) -> bech32::primitives::decode::ByteIter<'_> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::data_part_ascii_no_checksum(&self) -> &'s [u8] pub fn bech32::primitives::decode::CheckedHrpstring<'s>::fe32_iter>(&self) -> bech32::primitives::decode::AsciiToFe32Iter<'_> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CheckedHrpstring<'s>::hrp(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::decode::CheckedHrpstring<'s>::new(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::CheckedHrpstring<'s>::remove_witness_version(&mut self) -> core::option::Option pub fn bech32::primitives::decode::CheckedHrpstring<'s>::validate_segwit(self) -> core::result::Result, bech32::primitives::decode::SegwitHrpstringError> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::validate_segwit_padding(&self) -> core::result::Result<(), bech32::primitives::decode::PaddingError> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::validate_witness_program_length(&self, witness_version: bech32::primitives::gf32::Fe32) -> core::result::Result<(), bech32::primitives::segwit::WitnessLengthError> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::witness_version(&self) -> core::option::Option pub fn bech32::primitives::decode::CheckedHrpstringError::clone(&self) -> bech32::primitives::decode::CheckedHrpstringError pub fn bech32::primitives::decode::CheckedHrpstringError::eq(&self, other: &bech32::primitives::decode::CheckedHrpstringError) -> bool pub fn bech32::primitives::decode::CheckedHrpstringError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CheckedHrpstringError::from(e: bech32::primitives::decode::ChecksumError) -> Self pub fn bech32::primitives::decode::CheckedHrpstringError::from(e: bech32::primitives::decode::UncheckedHrpstringError) -> Self pub fn bech32::primitives::decode::ChecksumError::clone(&self) -> bech32::primitives::decode::ChecksumError pub fn bech32::primitives::decode::ChecksumError::eq(&self, other: &bech32::primitives::decode::ChecksumError) -> bool pub fn bech32::primitives::decode::ChecksumError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CodeLengthError::clone(&self) -> bech32::primitives::decode::CodeLengthError pub fn bech32::primitives::decode::CodeLengthError::eq(&self, other: &bech32::primitives::decode::CodeLengthError) -> bool pub fn bech32::primitives::decode::CodeLengthError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::Fe32Iter<'s>::next(&mut self) -> core::option::Option pub fn bech32::primitives::decode::Fe32Iter<'s>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::decode::PaddingError::clone(&self) -> bech32::primitives::decode::PaddingError pub fn bech32::primitives::decode::PaddingError::eq(&self, other: &bech32::primitives::decode::PaddingError) -> bool pub fn bech32::primitives::decode::PaddingError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::SegwitCodeLengthError::clone(&self) -> bech32::primitives::decode::SegwitCodeLengthError pub fn bech32::primitives::decode::SegwitCodeLengthError::eq(&self, other: &bech32::primitives::decode::SegwitCodeLengthError) -> bool pub fn bech32::primitives::decode::SegwitCodeLengthError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::SegwitCodeLengthError::from(e: bech32::primitives::decode::CodeLengthError) -> Self pub fn bech32::primitives::decode::SegwitHrpstring<'s>::byte_iter(&self) -> bech32::primitives::decode::ByteIter<'_> pub fn bech32::primitives::decode::SegwitHrpstring<'s>::data_part_ascii_no_witver_no_checksum(&self) -> &'s [u8] pub fn bech32::primitives::decode::SegwitHrpstring<'s>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::SegwitHrpstring<'s>::has_valid_hrp(&self) -> bool pub fn bech32::primitives::decode::SegwitHrpstring<'s>::hrp(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::decode::SegwitHrpstring<'s>::new(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::SegwitHrpstring<'s>::new_bech32(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::SegwitHrpstring<'s>::witness_version(&self) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::decode::SegwitHrpstringError::clone(&self) -> bech32::primitives::decode::SegwitHrpstringError pub fn bech32::primitives::decode::SegwitHrpstringError::eq(&self, other: &bech32::primitives::decode::SegwitHrpstringError) -> bool pub fn bech32::primitives::decode::SegwitHrpstringError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::decode::ChecksumError) -> Self pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::decode::PaddingError) -> Self pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::decode::UncheckedHrpstringError) -> Self pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::segwit::WitnessLengthError) -> Self pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::data_part_ascii(&self) -> &'s [u8] pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::has_valid_checksum(&self) -> bool pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::hrp(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::new(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::remove_checksum(self) -> bech32::primitives::decode::CheckedHrpstring<'s> pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::remove_witness_version(&mut self) -> core::option::Option pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::validate_and_remove_checksum(self) -> core::result::Result, bech32::primitives::decode::ChecksumError> pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::validate_checksum(&self) -> core::result::Result<(), bech32::primitives::decode::ChecksumError> pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::witness_version(&self) -> core::option::Option pub fn bech32::primitives::decode::UncheckedHrpstringError::clone(&self) -> bech32::primitives::decode::UncheckedHrpstringError pub fn bech32::primitives::decode::UncheckedHrpstringError::eq(&self, other: &bech32::primitives::decode::UncheckedHrpstringError) -> bool pub fn bech32::primitives::decode::UncheckedHrpstringError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::UncheckedHrpstringError::from(e: bech32::primitives::decode::CharError) -> Self pub fn bech32::primitives::decode::UncheckedHrpstringError::from(e: bech32::primitives::hrp::Error) -> Self pub fn bech32::primitives::encode::ByteIter<'a, I, Ck>::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::ByteIter<'a, I, Ck>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::encode::ByteIter<'hrp, I, Ck>::new(char_iter: bech32::primitives::encode::CharIter<'hrp, I, Ck>) -> Self pub fn bech32::primitives::encode::CharIter<'a, I, Ck>::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::CharIter<'a, I, Ck>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::encode::CharIter<'hrp, I, Ck>::new(hrp: &'hrp bech32::primitives::hrp::Hrp, data: bech32::primitives::encode::WitnessVersionIter) -> Self pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::bytes(self) -> bech32::primitives::encode::ByteIter<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::chars(self) -> bech32::primitives::encode::CharIter<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::clone(&self) -> bech32::primitives::encode::Encoder<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::eq(&self, other: &bech32::primitives::encode::Encoder<'hrp, I, Ck>) -> bool pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::fes(self) -> bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::new(data: I, hrp: &'hrp bech32::primitives::hrp::Hrp) -> Self pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::with_witness_version(self, witness_version: bech32::primitives::gf32::Fe32) -> Self pub fn bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::new(hrp: &'hrp bech32::primitives::hrp::Hrp, data: bech32::primitives::encode::WitnessVersionIter) -> Self pub fn bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::encode::WitnessVersionIter::new(witness_version: core::option::Option, iter: I) -> Self pub fn bech32::primitives::encode::WitnessVersionIter::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::WitnessVersionIter::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::gf32::Fe32::add(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::add(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::add_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::as_ref(&self) -> &u8 pub fn bech32::primitives::gf32::Fe32::clone(&self) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::div(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::div(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::div_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::eq(&self, other: &bech32::primitives::gf32::Fe32) -> bool pub fn bech32::primitives::gf32::Fe32::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::gf32::Fe32::from_char(c: char) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::from_char_unchecked(c: u8) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::gf32::Fe32::iter_alpha() -> impl core::iter::traits::iterator::Iterator pub fn bech32::primitives::gf32::Fe32::mul(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::mul(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::mul_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::sub(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::sub(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::sub_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::to_char(self) -> char pub fn bech32::primitives::gf32::Fe32::to_u8(self) -> u8 pub fn bech32::primitives::gf32::Fe32::try_from(value: i128) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i16) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i32) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i64) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i8) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u128) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u16) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u32) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u64) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u8) -> core::result::Result pub fn bech32::primitives::gf32::FromCharError::clone(&self) -> bech32::primitives::gf32::FromCharError pub fn bech32::primitives::gf32::FromCharError::eq(&self, other: &bech32::primitives::gf32::FromCharError) -> bool pub fn bech32::primitives::gf32::FromCharError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::gf32::TryFromError::clone(&self) -> bech32::primitives::gf32::TryFromError pub fn bech32::primitives::gf32::TryFromError::eq(&self, other: &bech32::primitives::gf32::TryFromError) -> bool pub fn bech32::primitives::gf32::TryFromError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::gf32::TryFromError::from(e: core::num::error::TryFromIntError) -> Self pub fn bech32::primitives::gf32::TryFromError::from(i: core::convert::Infallible) -> Self pub fn bech32::primitives::hrp::ByteIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::ByteIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::ByteIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::ByteIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::hrp::CharIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::CharIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::CharIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::CharIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::hrp::Error::clone(&self) -> bech32::primitives::hrp::Error pub fn bech32::primitives::hrp::Error::eq(&self, other: &bech32::primitives::hrp::Error) -> bool pub fn bech32::primitives::hrp::Error::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::hrp::Hrp::as_bytes(&self) -> &[u8] pub fn bech32::primitives::hrp::Hrp::as_str(&self) -> &str pub fn bech32::primitives::hrp::Hrp::byte_iter(&self) -> bech32::primitives::hrp::ByteIter<'_> pub fn bech32::primitives::hrp::Hrp::char_iter(&self) -> bech32::primitives::hrp::CharIter<'_> pub fn bech32::primitives::hrp::Hrp::clone(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::hrp::Hrp::cmp(&self, other: &Self) -> core::cmp::Ordering pub fn bech32::primitives::hrp::Hrp::eq(&self, other: &Self) -> bool pub fn bech32::primitives::hrp::Hrp::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::hrp::Hrp::hash(&self, h: &mut H) pub fn bech32::primitives::hrp::Hrp::is_valid_on_mainnet(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_on_regtest(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_on_signet(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_on_testnet(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_segwit(&self) -> bool pub fn bech32::primitives::hrp::Hrp::len(&self) -> usize pub fn bech32::primitives::hrp::Hrp::lowercase_byte_iter(&self) -> bech32::primitives::hrp::LowercaseByteIter<'_> pub fn bech32::primitives::hrp::Hrp::lowercase_char_iter(&self) -> bech32::primitives::hrp::LowercaseCharIter<'_> pub fn bech32::primitives::hrp::Hrp::parse(hrp: &str) -> core::result::Result pub fn bech32::primitives::hrp::Hrp::partial_cmp(&self, other: &Self) -> core::option::Option pub fn bech32::primitives::hrp::Hrp::to_lowercase(&self) -> alloc::string::String pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::iter::ByteIterExt::bytes_to_fes(self) -> bech32::primitives::iter::BytesToFes pub fn bech32::primitives::iter::BytesToFes::clone(&self) -> bech32::primitives::iter::BytesToFes pub fn bech32::primitives::iter::BytesToFes::eq(&self, other: &bech32::primitives::iter::BytesToFes) -> bool pub fn bech32::primitives::iter::BytesToFes::len(&self) -> usize pub fn bech32::primitives::iter::BytesToFes::next(&mut self) -> core::option::Option pub fn bech32::primitives::iter::BytesToFes::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::iter::Checksummed::clone(&self) -> bech32::primitives::iter::Checksummed pub fn bech32::primitives::iter::Checksummed::eq(&self, other: &bech32::primitives::iter::Checksummed) -> bool pub fn bech32::primitives::iter::Checksummed::new(data: I) -> bech32::primitives::iter::Checksummed pub fn bech32::primitives::iter::Checksummed::new_hrp(hrp: bech32::primitives::hrp::Hrp, data: I) -> bech32::primitives::iter::Checksummed pub fn bech32::primitives::iter::Checksummed::next(&mut self) -> core::option::Option pub fn bech32::primitives::iter::Checksummed::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::iter::Fe32IterExt::fes_to_bytes(self) -> bech32::primitives::iter::FesToBytes pub fn bech32::primitives::iter::Fe32IterExt::with_checksum(self, hrp: &bech32::primitives::hrp::Hrp) -> bech32::primitives::encode::Encoder<'_, Self, Ck> pub fn bech32::primitives::iter::FesToBytes::clone(&self) -> bech32::primitives::iter::FesToBytes pub fn bech32::primitives::iter::FesToBytes::eq(&self, other: &bech32::primitives::iter::FesToBytes) -> bool pub fn bech32::primitives::iter::FesToBytes::len(&self) -> usize pub fn bech32::primitives::iter::FesToBytes::next(&mut self) -> core::option::Option pub fn bech32::primitives::iter::FesToBytes::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::segwit::InvalidWitnessVersionError::clone(&self) -> bech32::primitives::segwit::InvalidWitnessVersionError pub fn bech32::primitives::segwit::InvalidWitnessVersionError::eq(&self, other: &bech32::primitives::segwit::InvalidWitnessVersionError) -> bool pub fn bech32::primitives::segwit::InvalidWitnessVersionError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::segwit::WitnessLengthError::clone(&self) -> bech32::primitives::segwit::WitnessLengthError pub fn bech32::primitives::segwit::WitnessLengthError::eq(&self, other: &bech32::primitives::segwit::WitnessLengthError) -> bool pub fn bech32::primitives::segwit::WitnessLengthError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::segwit::is_valid_witness_program_length(length: usize, witness_version: bech32::primitives::gf32::Fe32) -> bool pub fn bech32::primitives::segwit::is_valid_witness_version(witness_version: bech32::primitives::gf32::Fe32) -> bool pub fn bech32::primitives::segwit::validate_witness_program_length(length: usize, version: bech32::primitives::gf32::Fe32) -> core::result::Result<(), bech32::primitives::segwit::WitnessLengthError> pub fn bech32::primitives::segwit::validate_witness_version(witness_version: bech32::primitives::gf32::Fe32) -> core::result::Result<(), bech32::primitives::segwit::InvalidWitnessVersionError> pub fn bech32::segwit::DecodeError::clone(&self) -> bech32::segwit::DecodeError pub fn bech32::segwit::DecodeError::eq(&self, other: &bech32::segwit::DecodeError) -> bool pub fn bech32::segwit::DecodeError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::segwit::DecodeError::from(e: bech32::primitives::decode::SegwitHrpstringError) -> Self pub fn bech32::segwit::EncodeError::clone(&self) -> bech32::segwit::EncodeError pub fn bech32::segwit::EncodeError::eq(&self, other: &bech32::segwit::EncodeError) -> bool pub fn bech32::segwit::EncodeError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::segwit::EncodeError::from(e: bech32::primitives::decode::SegwitCodeLengthError) -> Self pub fn bech32::segwit::EncodeError::from(e: bech32::primitives::segwit::InvalidWitnessVersionError) -> Self pub fn bech32::segwit::EncodeError::from(e: bech32::primitives::segwit::WitnessLengthError) -> Self pub fn bech32::segwit::EncodeError::from(e: core::fmt::Error) -> Self pub fn bech32::segwit::decode(s: &str) -> core::result::Result<(bech32::primitives::hrp::Hrp, bech32::primitives::gf32::Fe32, alloc::vec::Vec), bech32::segwit::DecodeError> pub fn bech32::segwit::encode(hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::result::Result pub fn bech32::segwit::encode_lower_to_fmt_unchecked(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::fmt::Result pub fn bech32::segwit::encode_to_fmt_unchecked(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::fmt::Result pub fn bech32::segwit::encode_upper_to_fmt_unchecked(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::fmt::Result pub fn bech32::segwit::encode_v0(hrp: bech32::primitives::hrp::Hrp, witness_program: &[u8]) -> core::result::Result pub fn bech32::segwit::encode_v1(hrp: bech32::primitives::hrp::Hrp, witness_program: &[u8]) -> core::result::Result pub fn bech32::segwit::encoded_length(hrp: bech32::primitives::hrp::Hrp, _witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::result::Result pub fn u128::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn u128::unpack(&self, n: usize) -> u8 pub fn u32::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn u32::unpack(&self, n: usize) -> u8 pub fn u64::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn u64::unpack(&self, n: usize) -> u8 pub fn u8::from(v: bech32::primitives::gf32::Fe32) -> u8 pub mod bech32 pub mod bech32::hrp pub mod bech32::primitives pub mod bech32::primitives::checksum pub mod bech32::primitives::decode pub mod bech32::primitives::encode pub mod bech32::primitives::gf32 pub mod bech32::primitives::hrp pub mod bech32::primitives::iter pub mod bech32::primitives::segwit pub mod bech32::segwit pub struct bech32::Hrp pub struct bech32::hrp::Hrp pub struct bech32::primitives::checksum::Engine pub struct bech32::primitives::checksum::HrpFe32Iter<'hrp> pub struct bech32::primitives::checksum::PackedNull pub struct bech32::primitives::decode::AsciiToFe32Iter<'s> pub struct bech32::primitives::decode::ByteIter<'s> pub struct bech32::primitives::decode::CheckedHrpstring<'s> pub struct bech32::primitives::decode::Fe32Iter<'s> pub struct bech32::primitives::decode::SegwitHrpstring<'s> pub struct bech32::primitives::decode::UncheckedHrpstring<'s> pub struct bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator pub struct bech32::primitives::hrp::ByteIter<'b> pub struct bech32::primitives::hrp::CharIter<'b> pub struct bech32::primitives::hrp::Hrp pub struct bech32::primitives::hrp::LowercaseByteIter<'b> pub struct bech32::primitives::hrp::LowercaseCharIter<'b> pub struct bech32::primitives::iter::BytesToFes> pub struct bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::iter::FesToBytes> pub trait bech32::ByteIterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::Checksum pub trait bech32::Fe32IterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::primitives::checksum::Checksum pub trait bech32::primitives::checksum::PackedFe32: core::marker::Copy + core::cmp::PartialEq + core::cmp::Eq + core::ops::bit::BitXor pub trait bech32::primitives::iter::ByteIterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::primitives::iter::Fe32IterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub type &bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 pub type bech32::Checksum::MidstateRepr: bech32::primitives::checksum::PackedFe32 pub type bech32::primitives::Bech32::MidstateRepr = u32 pub type bech32::primitives::Bech32m::MidstateRepr = u32 pub type bech32::primitives::NoChecksum::MidstateRepr = bech32::primitives::checksum::PackedNull pub type bech32::primitives::checksum::Checksum::MidstateRepr: bech32::primitives::checksum::PackedFe32 pub type bech32::primitives::checksum::HrpFe32Iter<'hrp>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::checksum::PackedNull::Output = bech32::primitives::checksum::PackedNull pub type bech32::primitives::decode::AsciiToFe32Iter<'s>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::decode::ByteIter<'s>::Item = u8 pub type bech32::primitives::decode::Fe32Iter<'s>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::encode::ByteIter<'a, I, Ck>::Item = u8 pub type bech32::primitives::encode::CharIter<'a, I, Ck>::Item = char pub type bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::encode::WitnessVersionIter::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::gf32::Fe32::Error = bech32::primitives::gf32::TryFromError pub type bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 pub type bech32::primitives::hrp::ByteIter<'b>::Item = u8 pub type bech32::primitives::hrp::CharIter<'b>::Item = char pub type bech32::primitives::hrp::LowercaseByteIter<'b>::Item = u8 pub type bech32::primitives::hrp::LowercaseCharIter<'b>::Item = char pub type bech32::primitives::iter::BytesToFes::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::iter::Checksummed::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::iter::FesToBytes::Item = u8 bech32-0.11.0/api/no-features.txt000064400000000000000000002542761046102023000145330ustar 00000000000000#[non_exhaustive] pub enum bech32::EncodeError #[non_exhaustive] pub enum bech32::primitives::decode::CharError #[non_exhaustive] pub enum bech32::primitives::decode::CheckedHrpstringError #[non_exhaustive] pub enum bech32::primitives::decode::ChecksumError #[non_exhaustive] pub enum bech32::primitives::decode::PaddingError #[non_exhaustive] pub enum bech32::primitives::decode::SegwitHrpstringError #[non_exhaustive] pub enum bech32::primitives::decode::UncheckedHrpstringError #[non_exhaustive] pub enum bech32::primitives::gf32::FromCharError #[non_exhaustive] pub enum bech32::primitives::gf32::TryFromError #[non_exhaustive] pub enum bech32::primitives::hrp::Error #[non_exhaustive] pub enum bech32::primitives::segwit::WitnessLengthError #[non_exhaustive] pub struct bech32::primitives::decode::CodeLengthError #[non_exhaustive] pub struct bech32::primitives::decode::SegwitCodeLengthError(pub usize) #[non_exhaustive] pub struct bech32::primitives::segwit::InvalidWitnessVersionError(pub bech32::primitives::gf32::Fe32) #[repr(transparent)] pub struct bech32::Fe32(_) #[repr(transparent)] pub struct bech32::primitives::gf32::Fe32(_) impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32 impl bech32::primitives::checksum::Checksum for bech32::primitives::Bech32m impl bech32::primitives::checksum::Checksum for bech32::primitives::NoChecksum impl bech32::primitives::checksum::PackedFe32 for bech32::primitives::checksum::PackedNull impl bech32::primitives::checksum::PackedFe32 for u128 impl bech32::primitives::checksum::PackedFe32 for u32 impl bech32::primitives::checksum::PackedFe32 for u64 impl bech32::primitives::gf32::Fe32 impl bech32::primitives::hrp::Hrp impl core::clone::Clone for bech32::EncodeError impl core::clone::Clone for bech32::primitives::Bech32 impl core::clone::Clone for bech32::primitives::Bech32m impl core::clone::Clone for bech32::primitives::NoChecksum impl core::clone::Clone for bech32::primitives::checksum::PackedNull impl core::clone::Clone for bech32::primitives::decode::CharError impl core::clone::Clone for bech32::primitives::decode::CheckedHrpstringError impl core::clone::Clone for bech32::primitives::decode::ChecksumError impl core::clone::Clone for bech32::primitives::decode::CodeLengthError impl core::clone::Clone for bech32::primitives::decode::PaddingError impl core::clone::Clone for bech32::primitives::decode::SegwitCodeLengthError impl core::clone::Clone for bech32::primitives::decode::SegwitHrpstringError impl core::clone::Clone for bech32::primitives::decode::UncheckedHrpstringError impl core::clone::Clone for bech32::primitives::gf32::Fe32 impl core::clone::Clone for bech32::primitives::gf32::FromCharError impl core::clone::Clone for bech32::primitives::gf32::TryFromError impl core::clone::Clone for bech32::primitives::hrp::Error impl core::clone::Clone for bech32::primitives::hrp::Hrp impl core::clone::Clone for bech32::primitives::segwit::InvalidWitnessVersionError impl core::clone::Clone for bech32::primitives::segwit::WitnessLengthError impl core::cmp::Eq for bech32::EncodeError impl core::cmp::Eq for bech32::primitives::Bech32 impl core::cmp::Eq for bech32::primitives::Bech32m impl core::cmp::Eq for bech32::primitives::NoChecksum impl core::cmp::Eq for bech32::primitives::checksum::PackedNull impl core::cmp::Eq for bech32::primitives::decode::CharError impl core::cmp::Eq for bech32::primitives::decode::CheckedHrpstringError impl core::cmp::Eq for bech32::primitives::decode::ChecksumError impl core::cmp::Eq for bech32::primitives::decode::CodeLengthError impl core::cmp::Eq for bech32::primitives::decode::PaddingError impl core::cmp::Eq for bech32::primitives::decode::SegwitCodeLengthError impl core::cmp::Eq for bech32::primitives::decode::SegwitHrpstringError impl core::cmp::Eq for bech32::primitives::decode::UncheckedHrpstringError impl core::cmp::Eq for bech32::primitives::gf32::Fe32 impl core::cmp::Eq for bech32::primitives::gf32::FromCharError impl core::cmp::Eq for bech32::primitives::gf32::TryFromError impl core::cmp::Eq for bech32::primitives::hrp::Error impl core::cmp::Eq for bech32::primitives::hrp::Hrp impl core::cmp::Eq for bech32::primitives::segwit::InvalidWitnessVersionError impl core::cmp::Eq for bech32::primitives::segwit::WitnessLengthError impl core::cmp::Ord for bech32::primitives::Bech32 impl core::cmp::Ord for bech32::primitives::Bech32m impl core::cmp::Ord for bech32::primitives::NoChecksum impl core::cmp::Ord for bech32::primitives::hrp::Hrp impl core::cmp::PartialEq for bech32::EncodeError impl core::cmp::PartialEq for bech32::primitives::Bech32 impl core::cmp::PartialEq for bech32::primitives::Bech32m impl core::cmp::PartialEq for bech32::primitives::NoChecksum impl core::cmp::PartialEq for bech32::primitives::checksum::PackedNull impl core::cmp::PartialEq for bech32::primitives::decode::CharError impl core::cmp::PartialEq for bech32::primitives::decode::CheckedHrpstringError impl core::cmp::PartialEq for bech32::primitives::decode::ChecksumError impl core::cmp::PartialEq for bech32::primitives::decode::CodeLengthError impl core::cmp::PartialEq for bech32::primitives::decode::PaddingError impl core::cmp::PartialEq for bech32::primitives::decode::SegwitCodeLengthError impl core::cmp::PartialEq for bech32::primitives::decode::SegwitHrpstringError impl core::cmp::PartialEq for bech32::primitives::decode::UncheckedHrpstringError impl core::cmp::PartialEq for bech32::primitives::gf32::Fe32 impl core::cmp::PartialEq for bech32::primitives::gf32::FromCharError impl core::cmp::PartialEq for bech32::primitives::gf32::TryFromError impl core::cmp::PartialEq for bech32::primitives::hrp::Error impl core::cmp::PartialEq for bech32::primitives::hrp::Hrp impl core::cmp::PartialEq for bech32::primitives::segwit::InvalidWitnessVersionError impl core::cmp::PartialEq for bech32::primitives::segwit::WitnessLengthError impl core::cmp::PartialOrd for bech32::primitives::Bech32 impl core::cmp::PartialOrd for bech32::primitives::Bech32m impl core::cmp::PartialOrd for bech32::primitives::NoChecksum impl core::cmp::PartialOrd for bech32::primitives::hrp::Hrp impl core::convert::AsRef for bech32::primitives::gf32::Fe32 impl core::convert::From for bech32::primitives::decode::UncheckedHrpstringError impl core::convert::From for bech32::primitives::decode::CheckedHrpstringError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for bech32::EncodeError impl core::convert::From for bech32::primitives::decode::SegwitCodeLengthError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for bech32::primitives::decode::CheckedHrpstringError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for u8 impl core::convert::From for bech32::primitives::decode::UncheckedHrpstringError impl core::convert::From for bech32::primitives::decode::SegwitHrpstringError impl core::convert::From for bech32::primitives::gf32::TryFromError impl core::convert::From for bech32::EncodeError impl core::convert::From for bech32::primitives::gf32::TryFromError impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::convert::TryFrom for bech32::primitives::gf32::Fe32 impl core::fmt::Debug for bech32::EncodeError impl core::fmt::Debug for bech32::primitives::checksum::PackedNull impl core::fmt::Debug for bech32::primitives::decode::CharError impl core::fmt::Debug for bech32::primitives::decode::CheckedHrpstringError impl core::fmt::Debug for bech32::primitives::decode::ChecksumError impl core::fmt::Debug for bech32::primitives::decode::CodeLengthError impl core::fmt::Debug for bech32::primitives::decode::PaddingError impl core::fmt::Debug for bech32::primitives::decode::SegwitCodeLengthError impl core::fmt::Debug for bech32::primitives::decode::SegwitHrpstringError impl core::fmt::Debug for bech32::primitives::decode::UncheckedHrpstringError impl core::fmt::Debug for bech32::primitives::gf32::Fe32 impl core::fmt::Debug for bech32::primitives::gf32::FromCharError impl core::fmt::Debug for bech32::primitives::gf32::TryFromError impl core::fmt::Debug for bech32::primitives::hrp::Error impl core::fmt::Debug for bech32::primitives::hrp::Hrp impl core::fmt::Debug for bech32::primitives::segwit::InvalidWitnessVersionError impl core::fmt::Debug for bech32::primitives::segwit::WitnessLengthError impl core::fmt::Display for bech32::EncodeError impl core::fmt::Display for bech32::primitives::decode::CharError impl core::fmt::Display for bech32::primitives::decode::CheckedHrpstringError impl core::fmt::Display for bech32::primitives::decode::ChecksumError impl core::fmt::Display for bech32::primitives::decode::CodeLengthError impl core::fmt::Display for bech32::primitives::decode::PaddingError impl core::fmt::Display for bech32::primitives::decode::SegwitCodeLengthError impl core::fmt::Display for bech32::primitives::decode::SegwitHrpstringError impl core::fmt::Display for bech32::primitives::decode::UncheckedHrpstringError impl core::fmt::Display for bech32::primitives::gf32::Fe32 impl core::fmt::Display for bech32::primitives::gf32::FromCharError impl core::fmt::Display for bech32::primitives::gf32::TryFromError impl core::fmt::Display for bech32::primitives::hrp::Error impl core::fmt::Display for bech32::primitives::hrp::Hrp impl core::fmt::Display for bech32::primitives::segwit::InvalidWitnessVersionError impl core::fmt::Display for bech32::primitives::segwit::WitnessLengthError impl core::hash::Hash for bech32::primitives::Bech32 impl core::hash::Hash for bech32::primitives::Bech32m impl core::hash::Hash for bech32::primitives::NoChecksum impl core::hash::Hash for bech32::primitives::gf32::Fe32 impl core::hash::Hash for bech32::primitives::hrp::Hrp impl core::marker::Copy for bech32::primitives::Bech32 impl core::marker::Copy for bech32::primitives::Bech32m impl core::marker::Copy for bech32::primitives::NoChecksum impl core::marker::Copy for bech32::primitives::checksum::PackedNull impl core::marker::Copy for bech32::primitives::gf32::Fe32 impl core::marker::Copy for bech32::primitives::gf32::FromCharError impl core::marker::Copy for bech32::primitives::gf32::TryFromError impl core::marker::Copy for bech32::primitives::hrp::Hrp impl core::marker::Send for bech32::EncodeError impl core::marker::Send for bech32::primitives::Bech32 impl core::marker::Send for bech32::primitives::Bech32m impl core::marker::Send for bech32::primitives::NoChecksum impl core::marker::Send for bech32::primitives::checksum::PackedNull impl core::marker::Send for bech32::primitives::decode::CharError impl core::marker::Send for bech32::primitives::decode::CheckedHrpstringError impl core::marker::Send for bech32::primitives::decode::ChecksumError impl core::marker::Send for bech32::primitives::decode::CodeLengthError impl core::marker::Send for bech32::primitives::decode::PaddingError impl core::marker::Send for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::Send for bech32::primitives::decode::SegwitHrpstringError impl core::marker::Send for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::Send for bech32::primitives::gf32::Fe32 impl core::marker::Send for bech32::primitives::gf32::FromCharError impl core::marker::Send for bech32::primitives::gf32::TryFromError impl core::marker::Send for bech32::primitives::hrp::Error impl core::marker::Send for bech32::primitives::hrp::Hrp impl core::marker::Send for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::Send for bech32::primitives::segwit::WitnessLengthError impl core::marker::StructuralPartialEq for bech32::EncodeError impl core::marker::StructuralPartialEq for bech32::primitives::Bech32 impl core::marker::StructuralPartialEq for bech32::primitives::Bech32m impl core::marker::StructuralPartialEq for bech32::primitives::NoChecksum impl core::marker::StructuralPartialEq for bech32::primitives::checksum::PackedNull impl core::marker::StructuralPartialEq for bech32::primitives::decode::CharError impl core::marker::StructuralPartialEq for bech32::primitives::decode::CheckedHrpstringError impl core::marker::StructuralPartialEq for bech32::primitives::decode::ChecksumError impl core::marker::StructuralPartialEq for bech32::primitives::decode::CodeLengthError impl core::marker::StructuralPartialEq for bech32::primitives::decode::PaddingError impl core::marker::StructuralPartialEq for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::StructuralPartialEq for bech32::primitives::decode::SegwitHrpstringError impl core::marker::StructuralPartialEq for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::StructuralPartialEq for bech32::primitives::gf32::Fe32 impl core::marker::StructuralPartialEq for bech32::primitives::gf32::FromCharError impl core::marker::StructuralPartialEq for bech32::primitives::gf32::TryFromError impl core::marker::StructuralPartialEq for bech32::primitives::hrp::Error impl core::marker::StructuralPartialEq for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::StructuralPartialEq for bech32::primitives::segwit::WitnessLengthError impl core::marker::Sync for bech32::EncodeError impl core::marker::Sync for bech32::primitives::Bech32 impl core::marker::Sync for bech32::primitives::Bech32m impl core::marker::Sync for bech32::primitives::NoChecksum impl core::marker::Sync for bech32::primitives::checksum::PackedNull impl core::marker::Sync for bech32::primitives::decode::CharError impl core::marker::Sync for bech32::primitives::decode::CheckedHrpstringError impl core::marker::Sync for bech32::primitives::decode::ChecksumError impl core::marker::Sync for bech32::primitives::decode::CodeLengthError impl core::marker::Sync for bech32::primitives::decode::PaddingError impl core::marker::Sync for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::Sync for bech32::primitives::decode::SegwitHrpstringError impl core::marker::Sync for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::Sync for bech32::primitives::gf32::Fe32 impl core::marker::Sync for bech32::primitives::gf32::FromCharError impl core::marker::Sync for bech32::primitives::gf32::TryFromError impl core::marker::Sync for bech32::primitives::hrp::Error impl core::marker::Sync for bech32::primitives::hrp::Hrp impl core::marker::Sync for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::Sync for bech32::primitives::segwit::WitnessLengthError impl core::marker::Unpin for bech32::EncodeError impl core::marker::Unpin for bech32::primitives::Bech32 impl core::marker::Unpin for bech32::primitives::Bech32m impl core::marker::Unpin for bech32::primitives::NoChecksum impl core::marker::Unpin for bech32::primitives::checksum::PackedNull impl core::marker::Unpin for bech32::primitives::decode::CharError impl core::marker::Unpin for bech32::primitives::decode::CheckedHrpstringError impl core::marker::Unpin for bech32::primitives::decode::ChecksumError impl core::marker::Unpin for bech32::primitives::decode::CodeLengthError impl core::marker::Unpin for bech32::primitives::decode::PaddingError impl core::marker::Unpin for bech32::primitives::decode::SegwitCodeLengthError impl core::marker::Unpin for bech32::primitives::decode::SegwitHrpstringError impl core::marker::Unpin for bech32::primitives::decode::UncheckedHrpstringError impl core::marker::Unpin for bech32::primitives::gf32::Fe32 impl core::marker::Unpin for bech32::primitives::gf32::FromCharError impl core::marker::Unpin for bech32::primitives::gf32::TryFromError impl core::marker::Unpin for bech32::primitives::hrp::Error impl core::marker::Unpin for bech32::primitives::hrp::Hrp impl core::marker::Unpin for bech32::primitives::segwit::InvalidWitnessVersionError impl core::marker::Unpin for bech32::primitives::segwit::WitnessLengthError impl core::ops::arith::Add for bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Add<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Add for &bech32::primitives::gf32::Fe32 impl core::ops::arith::AddAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Div<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Div for &bech32::primitives::gf32::Fe32 impl core::ops::arith::DivAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Mul for &bech32::primitives::gf32::Fe32 impl core::ops::arith::MulAssign for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for &bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub<&bech32::primitives::gf32::Fe32> for bech32::primitives::gf32::Fe32 impl core::ops::arith::Sub for &bech32::primitives::gf32::Fe32 impl core::ops::arith::SubAssign for bech32::primitives::gf32::Fe32 impl core::ops::bit::BitXor for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::RefUnwindSafe for bech32::EncodeError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::Bech32 impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::Bech32m impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::NoChecksum impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CharError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CheckedHrpstringError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::ChecksumError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CodeLengthError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::PaddingError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::SegwitCodeLengthError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::SegwitHrpstringError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::UncheckedHrpstringError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32::Fe32 impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32::FromCharError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::gf32::TryFromError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::Error impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::Hrp impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::segwit::InvalidWitnessVersionError impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::segwit::WitnessLengthError impl core::panic::unwind_safe::UnwindSafe for bech32::EncodeError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::Bech32 impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::Bech32m impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::NoChecksum impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::checksum::PackedNull impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CharError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CheckedHrpstringError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::ChecksumError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CodeLengthError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::PaddingError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::SegwitCodeLengthError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::SegwitHrpstringError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::UncheckedHrpstringError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32::Fe32 impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32::FromCharError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::gf32::TryFromError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::Error impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::Hrp impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::segwit::InvalidWitnessVersionError impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::segwit::WitnessLengthError impl<'a, I, Ck> core::iter::traits::iterator::Iterator for bech32::primitives::encode::ByteIter<'a, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'a, I, Ck> core::iter::traits::iterator::Iterator for bech32::primitives::encode::CharIter<'a, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::double_ended::DoubleEndedIterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::iterator::Iterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::CharIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::iter::traits::marker::FusedIterator for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::CharIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::marker::Send for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::CharIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::marker::Sync for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::CharIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::marker::Unpin for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::CharIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::ByteIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::CharIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::LowercaseByteIter<'b> impl<'b> core::panic::unwind_safe::UnwindSafe for bech32::primitives::hrp::LowercaseCharIter<'b> impl<'hrp, I, Ck> bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> core::clone::Clone for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator + core::clone::Clone, Ck: bech32::primitives::checksum::Checksum + core::clone::Clone impl<'hrp, I, Ck> core::cmp::Eq for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator + core::cmp::Eq, Ck: bech32::primitives::checksum::Checksum + core::cmp::Eq impl<'hrp, I, Ck> core::cmp::PartialEq for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator + core::cmp::PartialEq, Ck: bech32::primitives::checksum::Checksum + core::cmp::PartialEq impl<'hrp, I, Ck> core::iter::traits::iterator::Iterator for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::marker::Send, I: core::marker::Send impl<'hrp, I, Ck> core::marker::Send for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl<'hrp, I, Ck> core::marker::StructuralPartialEq for bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::marker::Sync, I: core::marker::Sync impl<'hrp, I, Ck> core::marker::Sync for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::marker::Unpin, I: core::marker::Unpin impl<'hrp, I, Ck> core::marker::Unpin for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::panic::unwind_safe::RefUnwindSafe, I: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::Encoder<'hrp, I, Ck> where Ck: core::panic::unwind_safe::UnwindSafe, I: core::panic::unwind_safe::UnwindSafe impl<'hrp, I, Ck> core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl<'hrp> bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::iter::traits::iterator::Iterator for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::marker::Send for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::marker::Sync for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::marker::Unpin for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'hrp> core::panic::unwind_safe::UnwindSafe for bech32::primitives::checksum::HrpFe32Iter<'hrp> impl<'s> bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::fmt::Debug for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::fmt::Debug for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::fmt::Debug for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::decode::ByteIter<'s> impl<'s> core::iter::traits::iterator::Iterator for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::iter::traits::iterator::Iterator for bech32::primitives::decode::ByteIter<'s> impl<'s> core::iter::traits::iterator::Iterator for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::ByteIter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::marker::Send for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Send for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::marker::Send for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::ByteIter<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::marker::Sync for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::ByteIter<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::marker::Unpin for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::ByteIter<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::decode::UncheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::AsciiToFe32Iter<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::ByteIter<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::CheckedHrpstring<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::Fe32Iter<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::SegwitHrpstring<'s> impl<'s> core::panic::unwind_safe::UnwindSafe for bech32::primitives::decode::UncheckedHrpstring<'s> impl bech32::primitives::checksum::Engine impl core::default::Default for bech32::primitives::checksum::Engine impl core::marker::StructuralPartialEq for bech32::primitives::checksum::Engine impl core::clone::Clone for bech32::primitives::checksum::Engine where ::MidstateRepr: core::clone::Clone impl core::cmp::Eq for bech32::primitives::checksum::Engine where ::MidstateRepr: core::cmp::Eq impl core::cmp::PartialEq for bech32::primitives::checksum::Engine where ::MidstateRepr: core::cmp::PartialEq impl core::fmt::Debug for bech32::primitives::checksum::Engine where ::MidstateRepr: core::fmt::Debug impl core::marker::Copy for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Copy impl core::marker::Send for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Send impl core::marker::Sync for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Sync impl core::marker::Unpin for bech32::primitives::checksum::Engine where ::MidstateRepr: core::marker::Unpin impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::checksum::Engine where ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::checksum::Engine where ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl core::clone::Clone for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator + core::clone::Clone, Ck: bech32::primitives::checksum::Checksum + core::clone::Clone impl core::cmp::Eq for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator + core::cmp::Eq, Ck: bech32::primitives::checksum::Checksum + core::cmp::Eq impl core::cmp::PartialEq for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator + core::cmp::PartialEq, Ck: bech32::primitives::checksum::Checksum + core::cmp::PartialEq impl core::iter::traits::iterator::Iterator for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl core::marker::Send for bech32::primitives::iter::Checksummed where I: core::marker::Send, ::MidstateRepr: core::marker::Send impl core::marker::StructuralPartialEq for bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum impl core::marker::Sync for bech32::primitives::iter::Checksummed where I: core::marker::Sync, ::MidstateRepr: core::marker::Sync impl core::marker::Unpin for bech32::primitives::iter::Checksummed where I: core::marker::Unpin, ::MidstateRepr: core::marker::Unpin impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::Checksummed where I: core::panic::unwind_safe::RefUnwindSafe, ::MidstateRepr: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::Checksummed where I: core::panic::unwind_safe::UnwindSafe, ::MidstateRepr: core::panic::unwind_safe::UnwindSafe impl> core::clone::Clone for bech32::primitives::iter::FesToBytes impl> core::clone::Clone for bech32::primitives::iter::BytesToFes impl> core::cmp::Eq for bech32::primitives::iter::FesToBytes impl> core::cmp::Eq for bech32::primitives::iter::BytesToFes impl> core::cmp::PartialEq for bech32::primitives::iter::FesToBytes impl> core::cmp::PartialEq for bech32::primitives::iter::BytesToFes impl> core::marker::StructuralPartialEq for bech32::primitives::iter::FesToBytes impl> core::marker::StructuralPartialEq for bech32::primitives::iter::BytesToFes impl bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator impl bech32::primitives::iter::ByteIterExt for I where I: core::iter::traits::iterator::Iterator impl bech32::primitives::iter::Fe32IterExt for I where I: core::iter::traits::iterator::Iterator impl core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::iter::BytesToFes where I: core::iter::traits::iterator::Iterator + core::iter::traits::exact_size::ExactSizeIterator impl core::iter::traits::exact_size::ExactSizeIterator for bech32::primitives::iter::FesToBytes where I: core::iter::traits::iterator::Iterator + core::iter::traits::exact_size::ExactSizeIterator impl core::iter::traits::iterator::Iterator for bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator impl core::iter::traits::iterator::Iterator for bech32::primitives::iter::BytesToFes where I: core::iter::traits::iterator::Iterator impl core::iter::traits::iterator::Iterator for bech32::primitives::iter::FesToBytes where I: core::iter::traits::iterator::Iterator impl core::marker::Send for bech32::primitives::encode::WitnessVersionIter where I: core::marker::Send impl core::marker::Send for bech32::primitives::iter::BytesToFes where I: core::marker::Send impl core::marker::Send for bech32::primitives::iter::FesToBytes where I: core::marker::Send impl core::marker::Sync for bech32::primitives::encode::WitnessVersionIter where I: core::marker::Sync impl core::marker::Sync for bech32::primitives::iter::BytesToFes where I: core::marker::Sync impl core::marker::Sync for bech32::primitives::iter::FesToBytes where I: core::marker::Sync impl core::marker::Unpin for bech32::primitives::encode::WitnessVersionIter where I: core::marker::Unpin impl core::marker::Unpin for bech32::primitives::iter::BytesToFes where I: core::marker::Unpin impl core::marker::Unpin for bech32::primitives::iter::FesToBytes where I: core::marker::Unpin impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::encode::WitnessVersionIter where I: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::BytesToFes where I: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::RefUnwindSafe for bech32::primitives::iter::FesToBytes where I: core::panic::unwind_safe::RefUnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::encode::WitnessVersionIter where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::BytesToFes where I: core::panic::unwind_safe::UnwindSafe impl core::panic::unwind_safe::UnwindSafe for bech32::primitives::iter::FesToBytes where I: core::panic::unwind_safe::UnwindSafe pub bech32::EncodeError::Fmt(core::fmt::Error) pub bech32::EncodeError::TooLong(bech32::primitives::decode::CodeLengthError) pub bech32::primitives::decode::CharError::InvalidChar(char) pub bech32::primitives::decode::CharError::MissingSeparator pub bech32::primitives::decode::CharError::MixedCase pub bech32::primitives::decode::CharError::NothingAfterSeparator pub bech32::primitives::decode::CheckedHrpstringError::Checksum(bech32::primitives::decode::ChecksumError) pub bech32::primitives::decode::CheckedHrpstringError::Parse(bech32::primitives::decode::UncheckedHrpstringError) pub bech32::primitives::decode::ChecksumError::CodeLength(bech32::primitives::decode::CodeLengthError) pub bech32::primitives::decode::ChecksumError::InvalidLength pub bech32::primitives::decode::ChecksumError::InvalidResidue pub bech32::primitives::decode::CodeLengthError::code_length: usize pub bech32::primitives::decode::CodeLengthError::encoded_length: usize pub bech32::primitives::decode::PaddingError::NonZero pub bech32::primitives::decode::PaddingError::TooMuch pub bech32::primitives::decode::SegwitHrpstringError::Checksum(bech32::primitives::decode::ChecksumError) pub bech32::primitives::decode::SegwitHrpstringError::InvalidWitnessVersion(bech32::primitives::gf32::Fe32) pub bech32::primitives::decode::SegwitHrpstringError::NoData pub bech32::primitives::decode::SegwitHrpstringError::Padding(bech32::primitives::decode::PaddingError) pub bech32::primitives::decode::SegwitHrpstringError::TooLong(usize) pub bech32::primitives::decode::SegwitHrpstringError::Unchecked(bech32::primitives::decode::UncheckedHrpstringError) pub bech32::primitives::decode::SegwitHrpstringError::WitnessLength(bech32::primitives::segwit::WitnessLengthError) pub bech32::primitives::decode::UncheckedHrpstringError::Char(bech32::primitives::decode::CharError) pub bech32::primitives::decode::UncheckedHrpstringError::Hrp(bech32::primitives::hrp::Error) pub bech32::primitives::gf32::FromCharError::Invalid(char) pub bech32::primitives::gf32::FromCharError::NotAscii(char) pub bech32::primitives::gf32::TryFromError::InvalidByte(u8) pub bech32::primitives::gf32::TryFromError::NotAByte(core::num::error::TryFromIntError) pub bech32::primitives::hrp::Error::Empty pub bech32::primitives::hrp::Error::InvalidAsciiByte(u8) pub bech32::primitives::hrp::Error::MixedCase pub bech32::primitives::hrp::Error::NonAsciiChar(char) pub bech32::primitives::hrp::Error::TooLong(usize) pub bech32::primitives::segwit::WitnessLengthError::InvalidSegwitV0 pub bech32::primitives::segwit::WitnessLengthError::TooLong pub bech32::primitives::segwit::WitnessLengthError::TooShort pub const bech32::Checksum::CHECKSUM_LENGTH: usize pub const bech32::Checksum::CODE_LENGTH: usize pub const bech32::Checksum::GENERATOR_SH: [Self::MidstateRepr; 5] pub const bech32::Checksum::TARGET_RESIDUE: Self::MidstateRepr pub const bech32::hrp::BC: _ pub const bech32::hrp::BCRT: _ pub const bech32::hrp::TB: _ pub const bech32::primitives::Bech32::CHECKSUM_LENGTH: usize pub const bech32::primitives::Bech32::CODE_LENGTH: usize pub const bech32::primitives::Bech32::GENERATOR_SH: [u32; 5] pub const bech32::primitives::Bech32::TARGET_RESIDUE: u32 pub const bech32::primitives::Bech32m::CHECKSUM_LENGTH: usize pub const bech32::primitives::Bech32m::CODE_LENGTH: usize pub const bech32::primitives::Bech32m::GENERATOR_SH: [u32; 5] pub const bech32::primitives::Bech32m::TARGET_RESIDUE: u32 pub const bech32::primitives::NoChecksum::CHECKSUM_LENGTH: usize pub const bech32::primitives::NoChecksum::CODE_LENGTH: usize pub const bech32::primitives::NoChecksum::GENERATOR_SH: [bech32::primitives::checksum::PackedNull; 5] pub const bech32::primitives::NoChecksum::TARGET_RESIDUE: bech32::primitives::checksum::PackedNull pub const bech32::primitives::checksum::Checksum::CHECKSUM_LENGTH: usize pub const bech32::primitives::checksum::Checksum::CODE_LENGTH: usize pub const bech32::primitives::checksum::Checksum::GENERATOR_SH: [Self::MidstateRepr; 5] pub const bech32::primitives::checksum::Checksum::TARGET_RESIDUE: Self::MidstateRepr pub const bech32::primitives::checksum::PackedFe32::ONE: Self pub const bech32::primitives::checksum::PackedFe32::WIDTH: usize pub const bech32::primitives::checksum::PackedNull::ONE: Self pub const bech32::primitives::gf32::Fe32::A: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::C: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::D: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::E: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::F: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::G: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::H: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::J: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::K: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::L: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::M: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::N: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::P: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::Q: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::R: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::S: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::T: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::U: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::V: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::W: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::X: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::Y: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::Z: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_0: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_2: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_3: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_4: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_5: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_6: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_7: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_8: bech32::primitives::gf32::Fe32 pub const bech32::primitives::gf32::Fe32::_9: bech32::primitives::gf32::Fe32 pub const bech32::primitives::hrp::BC: _ pub const bech32::primitives::hrp::BCRT: _ pub const bech32::primitives::hrp::TB: _ pub const bech32::primitives::segwit::MAX_STRING_LENGTH: usize = 90usize pub const bech32::primitives::segwit::VERSION_0: Fe32::Q pub const bech32::primitives::segwit::VERSION_1: Fe32::P pub const bech32::segwit::VERSION_0: Fe32::Q pub const bech32::segwit::VERSION_1: Fe32::P pub const fn bech32::primitives::hrp::Hrp::parse_unchecked(hrp: &str) -> Self pub const u128::ONE: Self pub const u32::ONE: Self pub const u64::ONE: Self pub enum bech32::Bech32 pub enum bech32::Bech32m pub enum bech32::NoChecksum pub enum bech32::primitives::Bech32 pub enum bech32::primitives::Bech32m pub enum bech32::primitives::NoChecksum pub fn &bech32::primitives::gf32::Fe32::add(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::add(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::div(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::div(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::mul(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::mul(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn &bech32::primitives::gf32::Fe32::sub(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::ByteIterExt::bytes_to_fes(self) -> bech32::primitives::iter::BytesToFes pub fn bech32::Checksum::sanity_check() pub fn bech32::EncodeError::clone(&self) -> bech32::EncodeError pub fn bech32::EncodeError::eq(&self, other: &bech32::EncodeError) -> bool pub fn bech32::EncodeError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::EncodeError::from(e: bech32::primitives::decode::CodeLengthError) -> Self pub fn bech32::EncodeError::from(e: core::fmt::Error) -> Self pub fn bech32::Fe32IterExt::fes_to_bytes(self) -> bech32::primitives::iter::FesToBytes pub fn bech32::Fe32IterExt::with_checksum(self, hrp: &bech32::primitives::hrp::Hrp) -> bech32::primitives::encode::Encoder<'_, Self, Ck> pub fn bech32::encode_lower_to_fmt(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeError> pub fn bech32::encode_to_fmt(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeError> pub fn bech32::encode_upper_to_fmt(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result<(), bech32::EncodeError> pub fn bech32::encoded_length(hrp: bech32::primitives::hrp::Hrp, data: &[u8]) -> core::result::Result pub fn bech32::primitives::Bech32::clone(&self) -> bech32::primitives::Bech32 pub fn bech32::primitives::Bech32::cmp(&self, other: &bech32::primitives::Bech32) -> core::cmp::Ordering pub fn bech32::primitives::Bech32::eq(&self, other: &bech32::primitives::Bech32) -> bool pub fn bech32::primitives::Bech32::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::Bech32::partial_cmp(&self, other: &bech32::primitives::Bech32) -> core::option::Option pub fn bech32::primitives::Bech32m::clone(&self) -> bech32::primitives::Bech32m pub fn bech32::primitives::Bech32m::cmp(&self, other: &bech32::primitives::Bech32m) -> core::cmp::Ordering pub fn bech32::primitives::Bech32m::eq(&self, other: &bech32::primitives::Bech32m) -> bool pub fn bech32::primitives::Bech32m::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::Bech32m::partial_cmp(&self, other: &bech32::primitives::Bech32m) -> core::option::Option pub fn bech32::primitives::NoChecksum::clone(&self) -> bech32::primitives::NoChecksum pub fn bech32::primitives::NoChecksum::cmp(&self, other: &bech32::primitives::NoChecksum) -> core::cmp::Ordering pub fn bech32::primitives::NoChecksum::eq(&self, other: &bech32::primitives::NoChecksum) -> bool pub fn bech32::primitives::NoChecksum::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::NoChecksum::partial_cmp(&self, other: &bech32::primitives::NoChecksum) -> core::option::Option pub fn bech32::primitives::checksum::Checksum::sanity_check() pub fn bech32::primitives::checksum::Engine::clone(&self) -> bech32::primitives::checksum::Engine pub fn bech32::primitives::checksum::Engine::default() -> Self pub fn bech32::primitives::checksum::Engine::eq(&self, other: &bech32::primitives::checksum::Engine) -> bool pub fn bech32::primitives::checksum::Engine::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::checksum::Engine::input_fe(&mut self, e: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::checksum::Engine::input_hrp(&mut self, hrp: bech32::primitives::hrp::Hrp) pub fn bech32::primitives::checksum::Engine::input_target_residue(&mut self) pub fn bech32::primitives::checksum::Engine::new() -> Self pub fn bech32::primitives::checksum::Engine::residue(&self) -> &::MidstateRepr pub fn bech32::primitives::checksum::HrpFe32Iter<'hrp>::new(hrp: &'hrp bech32::primitives::hrp::Hrp) -> Self pub fn bech32::primitives::checksum::HrpFe32Iter<'hrp>::next(&mut self) -> core::option::Option pub fn bech32::primitives::checksum::HrpFe32Iter<'hrp>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::checksum::PackedFe32::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn bech32::primitives::checksum::PackedFe32::unpack(&self, n: usize) -> u8 pub fn bech32::primitives::checksum::PackedNull::bitxor(self, bech32::primitives::checksum::PackedNull) -> bech32::primitives::checksum::PackedNull pub fn bech32::primitives::checksum::PackedNull::clone(&self) -> bech32::primitives::checksum::PackedNull pub fn bech32::primitives::checksum::PackedNull::eq(&self, other: &bech32::primitives::checksum::PackedNull) -> bool pub fn bech32::primitives::checksum::PackedNull::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::checksum::PackedNull::mul_by_x_then_add(&mut self, usize, u8) -> u8 pub fn bech32::primitives::checksum::PackedNull::unpack(&self, usize) -> u8 pub fn bech32::primitives::decode::AsciiToFe32Iter<'s>::len(&self) -> usize pub fn bech32::primitives::decode::AsciiToFe32Iter<'s>::next(&mut self) -> core::option::Option pub fn bech32::primitives::decode::AsciiToFe32Iter<'s>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::decode::ByteIter<'s>::len(&self) -> usize pub fn bech32::primitives::decode::ByteIter<'s>::next(&mut self) -> core::option::Option pub fn bech32::primitives::decode::ByteIter<'s>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::decode::CharError::clone(&self) -> bech32::primitives::decode::CharError pub fn bech32::primitives::decode::CharError::eq(&self, other: &bech32::primitives::decode::CharError) -> bool pub fn bech32::primitives::decode::CharError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CheckedHrpstring<'s>::byte_iter(&self) -> bech32::primitives::decode::ByteIter<'_> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::data_part_ascii_no_checksum(&self) -> &'s [u8] pub fn bech32::primitives::decode::CheckedHrpstring<'s>::fe32_iter>(&self) -> bech32::primitives::decode::AsciiToFe32Iter<'_> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CheckedHrpstring<'s>::hrp(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::decode::CheckedHrpstring<'s>::new(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::CheckedHrpstring<'s>::remove_witness_version(&mut self) -> core::option::Option pub fn bech32::primitives::decode::CheckedHrpstring<'s>::validate_segwit(self) -> core::result::Result, bech32::primitives::decode::SegwitHrpstringError> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::validate_segwit_padding(&self) -> core::result::Result<(), bech32::primitives::decode::PaddingError> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::validate_witness_program_length(&self, witness_version: bech32::primitives::gf32::Fe32) -> core::result::Result<(), bech32::primitives::segwit::WitnessLengthError> pub fn bech32::primitives::decode::CheckedHrpstring<'s>::witness_version(&self) -> core::option::Option pub fn bech32::primitives::decode::CheckedHrpstringError::clone(&self) -> bech32::primitives::decode::CheckedHrpstringError pub fn bech32::primitives::decode::CheckedHrpstringError::eq(&self, other: &bech32::primitives::decode::CheckedHrpstringError) -> bool pub fn bech32::primitives::decode::CheckedHrpstringError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CheckedHrpstringError::from(e: bech32::primitives::decode::ChecksumError) -> Self pub fn bech32::primitives::decode::CheckedHrpstringError::from(e: bech32::primitives::decode::UncheckedHrpstringError) -> Self pub fn bech32::primitives::decode::ChecksumError::clone(&self) -> bech32::primitives::decode::ChecksumError pub fn bech32::primitives::decode::ChecksumError::eq(&self, other: &bech32::primitives::decode::ChecksumError) -> bool pub fn bech32::primitives::decode::ChecksumError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::CodeLengthError::clone(&self) -> bech32::primitives::decode::CodeLengthError pub fn bech32::primitives::decode::CodeLengthError::eq(&self, other: &bech32::primitives::decode::CodeLengthError) -> bool pub fn bech32::primitives::decode::CodeLengthError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::Fe32Iter<'s>::next(&mut self) -> core::option::Option pub fn bech32::primitives::decode::Fe32Iter<'s>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::decode::PaddingError::clone(&self) -> bech32::primitives::decode::PaddingError pub fn bech32::primitives::decode::PaddingError::eq(&self, other: &bech32::primitives::decode::PaddingError) -> bool pub fn bech32::primitives::decode::PaddingError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::SegwitCodeLengthError::clone(&self) -> bech32::primitives::decode::SegwitCodeLengthError pub fn bech32::primitives::decode::SegwitCodeLengthError::eq(&self, other: &bech32::primitives::decode::SegwitCodeLengthError) -> bool pub fn bech32::primitives::decode::SegwitCodeLengthError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::SegwitCodeLengthError::from(e: bech32::primitives::decode::CodeLengthError) -> Self pub fn bech32::primitives::decode::SegwitHrpstring<'s>::byte_iter(&self) -> bech32::primitives::decode::ByteIter<'_> pub fn bech32::primitives::decode::SegwitHrpstring<'s>::data_part_ascii_no_witver_no_checksum(&self) -> &'s [u8] pub fn bech32::primitives::decode::SegwitHrpstring<'s>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::SegwitHrpstring<'s>::has_valid_hrp(&self) -> bool pub fn bech32::primitives::decode::SegwitHrpstring<'s>::hrp(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::decode::SegwitHrpstring<'s>::new(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::SegwitHrpstring<'s>::new_bech32(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::SegwitHrpstring<'s>::witness_version(&self) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::decode::SegwitHrpstringError::clone(&self) -> bech32::primitives::decode::SegwitHrpstringError pub fn bech32::primitives::decode::SegwitHrpstringError::eq(&self, other: &bech32::primitives::decode::SegwitHrpstringError) -> bool pub fn bech32::primitives::decode::SegwitHrpstringError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::decode::ChecksumError) -> Self pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::decode::PaddingError) -> Self pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::decode::UncheckedHrpstringError) -> Self pub fn bech32::primitives::decode::SegwitHrpstringError::from(e: bech32::primitives::segwit::WitnessLengthError) -> Self pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::data_part_ascii(&self) -> &'s [u8] pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::has_valid_checksum(&self) -> bool pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::hrp(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::new(s: &'s str) -> core::result::Result pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::remove_checksum(self) -> bech32::primitives::decode::CheckedHrpstring<'s> pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::remove_witness_version(&mut self) -> core::option::Option pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::validate_and_remove_checksum(self) -> core::result::Result, bech32::primitives::decode::ChecksumError> pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::validate_checksum(&self) -> core::result::Result<(), bech32::primitives::decode::ChecksumError> pub fn bech32::primitives::decode::UncheckedHrpstring<'s>::witness_version(&self) -> core::option::Option pub fn bech32::primitives::decode::UncheckedHrpstringError::clone(&self) -> bech32::primitives::decode::UncheckedHrpstringError pub fn bech32::primitives::decode::UncheckedHrpstringError::eq(&self, other: &bech32::primitives::decode::UncheckedHrpstringError) -> bool pub fn bech32::primitives::decode::UncheckedHrpstringError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::decode::UncheckedHrpstringError::from(e: bech32::primitives::decode::CharError) -> Self pub fn bech32::primitives::decode::UncheckedHrpstringError::from(e: bech32::primitives::hrp::Error) -> Self pub fn bech32::primitives::encode::ByteIter<'a, I, Ck>::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::ByteIter<'a, I, Ck>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::encode::ByteIter<'hrp, I, Ck>::new(char_iter: bech32::primitives::encode::CharIter<'hrp, I, Ck>) -> Self pub fn bech32::primitives::encode::CharIter<'a, I, Ck>::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::CharIter<'a, I, Ck>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::encode::CharIter<'hrp, I, Ck>::new(hrp: &'hrp bech32::primitives::hrp::Hrp, data: bech32::primitives::encode::WitnessVersionIter) -> Self pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::bytes(self) -> bech32::primitives::encode::ByteIter<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::chars(self) -> bech32::primitives::encode::CharIter<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::clone(&self) -> bech32::primitives::encode::Encoder<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::eq(&self, other: &bech32::primitives::encode::Encoder<'hrp, I, Ck>) -> bool pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::fes(self) -> bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::new(data: I, hrp: &'hrp bech32::primitives::hrp::Hrp) -> Self pub fn bech32::primitives::encode::Encoder<'hrp, I, Ck>::with_witness_version(self, witness_version: bech32::primitives::gf32::Fe32) -> Self pub fn bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::new(hrp: &'hrp bech32::primitives::hrp::Hrp, data: bech32::primitives::encode::WitnessVersionIter) -> Self pub fn bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::encode::WitnessVersionIter::new(witness_version: core::option::Option, iter: I) -> Self pub fn bech32::primitives::encode::WitnessVersionIter::next(&mut self) -> core::option::Option pub fn bech32::primitives::encode::WitnessVersionIter::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::gf32::Fe32::add(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::add(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::add_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::as_ref(&self) -> &u8 pub fn bech32::primitives::gf32::Fe32::clone(&self) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::div(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::div(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::div_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::eq(&self, other: &bech32::primitives::gf32::Fe32) -> bool pub fn bech32::primitives::gf32::Fe32::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::gf32::Fe32::from_char(c: char) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::from_char_unchecked(c: u8) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bech32::primitives::gf32::Fe32::iter_alpha() -> impl core::iter::traits::iterator::Iterator pub fn bech32::primitives::gf32::Fe32::mul(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::mul(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::mul_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::sub(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::sub(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32 pub fn bech32::primitives::gf32::Fe32::sub_assign(&mut self, other: bech32::primitives::gf32::Fe32) pub fn bech32::primitives::gf32::Fe32::to_char(self) -> char pub fn bech32::primitives::gf32::Fe32::to_u8(self) -> u8 pub fn bech32::primitives::gf32::Fe32::try_from(value: i128) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i16) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i32) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i64) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: i8) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u128) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u16) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u32) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u64) -> core::result::Result pub fn bech32::primitives::gf32::Fe32::try_from(value: u8) -> core::result::Result pub fn bech32::primitives::gf32::FromCharError::clone(&self) -> bech32::primitives::gf32::FromCharError pub fn bech32::primitives::gf32::FromCharError::eq(&self, other: &bech32::primitives::gf32::FromCharError) -> bool pub fn bech32::primitives::gf32::FromCharError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::gf32::TryFromError::clone(&self) -> bech32::primitives::gf32::TryFromError pub fn bech32::primitives::gf32::TryFromError::eq(&self, other: &bech32::primitives::gf32::TryFromError) -> bool pub fn bech32::primitives::gf32::TryFromError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::gf32::TryFromError::from(e: core::num::error::TryFromIntError) -> Self pub fn bech32::primitives::gf32::TryFromError::from(i: core::convert::Infallible) -> Self pub fn bech32::primitives::hrp::ByteIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::ByteIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::ByteIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::ByteIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::hrp::CharIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::CharIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::CharIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::CharIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::hrp::Error::clone(&self) -> bech32::primitives::hrp::Error pub fn bech32::primitives::hrp::Error::eq(&self, other: &bech32::primitives::hrp::Error) -> bool pub fn bech32::primitives::hrp::Error::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::hrp::Hrp::as_bytes(&self) -> &[u8] pub fn bech32::primitives::hrp::Hrp::as_str(&self) -> &str pub fn bech32::primitives::hrp::Hrp::byte_iter(&self) -> bech32::primitives::hrp::ByteIter<'_> pub fn bech32::primitives::hrp::Hrp::char_iter(&self) -> bech32::primitives::hrp::CharIter<'_> pub fn bech32::primitives::hrp::Hrp::clone(&self) -> bech32::primitives::hrp::Hrp pub fn bech32::primitives::hrp::Hrp::cmp(&self, other: &Self) -> core::cmp::Ordering pub fn bech32::primitives::hrp::Hrp::eq(&self, other: &Self) -> bool pub fn bech32::primitives::hrp::Hrp::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::hrp::Hrp::hash(&self, h: &mut H) pub fn bech32::primitives::hrp::Hrp::is_valid_on_mainnet(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_on_regtest(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_on_signet(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_on_testnet(&self) -> bool pub fn bech32::primitives::hrp::Hrp::is_valid_segwit(&self) -> bool pub fn bech32::primitives::hrp::Hrp::len(&self) -> usize pub fn bech32::primitives::hrp::Hrp::lowercase_byte_iter(&self) -> bech32::primitives::hrp::LowercaseByteIter<'_> pub fn bech32::primitives::hrp::Hrp::lowercase_char_iter(&self) -> bech32::primitives::hrp::LowercaseCharIter<'_> pub fn bech32::primitives::hrp::Hrp::parse(hrp: &str) -> core::result::Result pub fn bech32::primitives::hrp::Hrp::partial_cmp(&self, other: &Self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseByteIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::len(&self) -> usize pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::next(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::next_back(&mut self) -> core::option::Option pub fn bech32::primitives::hrp::LowercaseCharIter<'b>::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::iter::ByteIterExt::bytes_to_fes(self) -> bech32::primitives::iter::BytesToFes pub fn bech32::primitives::iter::BytesToFes::clone(&self) -> bech32::primitives::iter::BytesToFes pub fn bech32::primitives::iter::BytesToFes::eq(&self, other: &bech32::primitives::iter::BytesToFes) -> bool pub fn bech32::primitives::iter::BytesToFes::len(&self) -> usize pub fn bech32::primitives::iter::BytesToFes::next(&mut self) -> core::option::Option pub fn bech32::primitives::iter::BytesToFes::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::iter::Checksummed::clone(&self) -> bech32::primitives::iter::Checksummed pub fn bech32::primitives::iter::Checksummed::eq(&self, other: &bech32::primitives::iter::Checksummed) -> bool pub fn bech32::primitives::iter::Checksummed::new(data: I) -> bech32::primitives::iter::Checksummed pub fn bech32::primitives::iter::Checksummed::new_hrp(hrp: bech32::primitives::hrp::Hrp, data: I) -> bech32::primitives::iter::Checksummed pub fn bech32::primitives::iter::Checksummed::next(&mut self) -> core::option::Option pub fn bech32::primitives::iter::Checksummed::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::iter::Fe32IterExt::fes_to_bytes(self) -> bech32::primitives::iter::FesToBytes pub fn bech32::primitives::iter::Fe32IterExt::with_checksum(self, hrp: &bech32::primitives::hrp::Hrp) -> bech32::primitives::encode::Encoder<'_, Self, Ck> pub fn bech32::primitives::iter::FesToBytes::clone(&self) -> bech32::primitives::iter::FesToBytes pub fn bech32::primitives::iter::FesToBytes::eq(&self, other: &bech32::primitives::iter::FesToBytes) -> bool pub fn bech32::primitives::iter::FesToBytes::len(&self) -> usize pub fn bech32::primitives::iter::FesToBytes::next(&mut self) -> core::option::Option pub fn bech32::primitives::iter::FesToBytes::size_hint(&self) -> (usize, core::option::Option) pub fn bech32::primitives::segwit::InvalidWitnessVersionError::clone(&self) -> bech32::primitives::segwit::InvalidWitnessVersionError pub fn bech32::primitives::segwit::InvalidWitnessVersionError::eq(&self, other: &bech32::primitives::segwit::InvalidWitnessVersionError) -> bool pub fn bech32::primitives::segwit::InvalidWitnessVersionError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::segwit::WitnessLengthError::clone(&self) -> bech32::primitives::segwit::WitnessLengthError pub fn bech32::primitives::segwit::WitnessLengthError::eq(&self, other: &bech32::primitives::segwit::WitnessLengthError) -> bool pub fn bech32::primitives::segwit::WitnessLengthError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn bech32::primitives::segwit::is_valid_witness_program_length(length: usize, witness_version: bech32::primitives::gf32::Fe32) -> bool pub fn bech32::primitives::segwit::is_valid_witness_version(witness_version: bech32::primitives::gf32::Fe32) -> bool pub fn bech32::primitives::segwit::validate_witness_program_length(length: usize, version: bech32::primitives::gf32::Fe32) -> core::result::Result<(), bech32::primitives::segwit::WitnessLengthError> pub fn bech32::primitives::segwit::validate_witness_version(witness_version: bech32::primitives::gf32::Fe32) -> core::result::Result<(), bech32::primitives::segwit::InvalidWitnessVersionError> pub fn bech32::segwit::encode_lower_to_fmt_unchecked(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::fmt::Result pub fn bech32::segwit::encode_to_fmt_unchecked(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::fmt::Result pub fn bech32::segwit::encode_upper_to_fmt_unchecked(fmt: &mut W, hrp: bech32::primitives::hrp::Hrp, witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::fmt::Result pub fn bech32::segwit::encoded_length(hrp: bech32::primitives::hrp::Hrp, _witness_version: bech32::primitives::gf32::Fe32, witness_program: &[u8]) -> core::result::Result pub fn u128::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn u128::unpack(&self, n: usize) -> u8 pub fn u32::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn u32::unpack(&self, n: usize) -> u8 pub fn u64::mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 pub fn u64::unpack(&self, n: usize) -> u8 pub fn u8::from(v: bech32::primitives::gf32::Fe32) -> u8 pub mod bech32 pub mod bech32::hrp pub mod bech32::primitives pub mod bech32::primitives::checksum pub mod bech32::primitives::decode pub mod bech32::primitives::encode pub mod bech32::primitives::gf32 pub mod bech32::primitives::hrp pub mod bech32::primitives::iter pub mod bech32::primitives::segwit pub mod bech32::segwit pub struct bech32::Hrp pub struct bech32::hrp::Hrp pub struct bech32::primitives::checksum::Engine pub struct bech32::primitives::checksum::HrpFe32Iter<'hrp> pub struct bech32::primitives::checksum::PackedNull pub struct bech32::primitives::decode::AsciiToFe32Iter<'s> pub struct bech32::primitives::decode::ByteIter<'s> pub struct bech32::primitives::decode::CheckedHrpstring<'s> pub struct bech32::primitives::decode::Fe32Iter<'s> pub struct bech32::primitives::decode::SegwitHrpstring<'s> pub struct bech32::primitives::decode::UncheckedHrpstring<'s> pub struct bech32::primitives::encode::ByteIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::CharIter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::Encoder<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::Fe32Iter<'hrp, I, Ck> where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::encode::WitnessVersionIter where I: core::iter::traits::iterator::Iterator pub struct bech32::primitives::hrp::ByteIter<'b> pub struct bech32::primitives::hrp::CharIter<'b> pub struct bech32::primitives::hrp::Hrp pub struct bech32::primitives::hrp::LowercaseByteIter<'b> pub struct bech32::primitives::hrp::LowercaseCharIter<'b> pub struct bech32::primitives::iter::BytesToFes> pub struct bech32::primitives::iter::Checksummed where I: core::iter::traits::iterator::Iterator, Ck: bech32::primitives::checksum::Checksum pub struct bech32::primitives::iter::FesToBytes> pub trait bech32::ByteIterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::Checksum pub trait bech32::Fe32IterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::primitives::checksum::Checksum pub trait bech32::primitives::checksum::PackedFe32: core::marker::Copy + core::cmp::PartialEq + core::cmp::Eq + core::ops::bit::BitXor pub trait bech32::primitives::iter::ByteIterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub trait bech32::primitives::iter::Fe32IterExt: core::marker::Sized + core::iter::traits::iterator::Iterator pub type &bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 pub type bech32::Checksum::MidstateRepr: bech32::primitives::checksum::PackedFe32 pub type bech32::primitives::Bech32::MidstateRepr = u32 pub type bech32::primitives::Bech32m::MidstateRepr = u32 pub type bech32::primitives::NoChecksum::MidstateRepr = bech32::primitives::checksum::PackedNull pub type bech32::primitives::checksum::Checksum::MidstateRepr: bech32::primitives::checksum::PackedFe32 pub type bech32::primitives::checksum::HrpFe32Iter<'hrp>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::checksum::PackedNull::Output = bech32::primitives::checksum::PackedNull pub type bech32::primitives::decode::AsciiToFe32Iter<'s>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::decode::ByteIter<'s>::Item = u8 pub type bech32::primitives::decode::Fe32Iter<'s>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::encode::ByteIter<'a, I, Ck>::Item = u8 pub type bech32::primitives::encode::CharIter<'a, I, Ck>::Item = char pub type bech32::primitives::encode::Fe32Iter<'hrp, I, Ck>::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::encode::WitnessVersionIter::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::gf32::Fe32::Error = bech32::primitives::gf32::TryFromError pub type bech32::primitives::gf32::Fe32::Output = bech32::primitives::gf32::Fe32 pub type bech32::primitives::hrp::ByteIter<'b>::Item = u8 pub type bech32::primitives::hrp::CharIter<'b>::Item = char pub type bech32::primitives::hrp::LowercaseByteIter<'b>::Item = u8 pub type bech32::primitives::hrp::LowercaseCharIter<'b>::Item = char pub type bech32::primitives::iter::BytesToFes::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::iter::Checksummed::Item = bech32::primitives::gf32::Fe32 pub type bech32::primitives::iter::FesToBytes::Item = u8 bech32-0.11.0/clippy.toml000064400000000000000000000000201046102023000131360ustar 00000000000000msrv = "1.48.0" bech32-0.11.0/contrib/check-for-api-changes.sh000075500000000000000000000031771046102023000167760ustar 00000000000000#!/usr/bin/env bash # # Checks the public API of crates, exits with non-zero if there are currently # changes to the public API not already committed to in the various api/*.txt # files. set -e REPO_DIR=$(git rev-parse --show-toplevel) API_DIR="$REPO_DIR/api" CARGO="cargo +nightly public-api --simplified" # `sort -n -u` doesn't work for some reason. SORT="sort --numeric-sort" # Sort order is effected by locale. See `man sort`. # > Set LC_ALL=C to get the traditional sort order that uses native byte values. export LC_ALL=C main() { # cargo public-api uses nightly so the toolchain must be available. if ! cargo +nightly --version > /dev/null; then echo "script requires a nightly toolchain to be installed (possibly >= nightly-2023-05-24)" >&2 exit 1 fi generate_api_files check_for_changes } generate_api_files() { pushd "$REPO_DIR" > /dev/null $CARGO --no-default-features | $SORT | uniq > "$API_DIR/no-features.txt" $CARGO --no-default-features --features=alloc | $SORT | uniq > "$API_DIR/alloc-only.txt" $CARGO --all-features | $SORT | uniq > "$API_DIR/all-features.txt" popd > /dev/null } # Check if there are changes (dirty git index) to the `api/` directory. check_for_changes() { pushd "$REPO_DIR" > /dev/null if [[ $(git status --porcelain api) ]]; then git diff --color=always echo echo "You have introduced changes to the public API, commit the changes to api/ currently in your working directory" >&2 exit 1 else echo "No changes to the current public API" fi popd > /dev/null } # # Main script # main "$@" exit 0 bech32-0.11.0/contrib/test.sh000075500000000000000000000035111046102023000137270ustar 00000000000000#!/bin/sh # # CI test script for rust-bech32. set -eu set -x # Some tests require certain toolchain types. NIGHTLY=false MSRV=false if cargo --version | grep nightly; then NIGHTLY=true fi if cargo --version | grep "1\.48"; then MSRV=true fi build_and_test () { cargo build --no-default-features --features="$1" cargo test --no-default-features --features="$1" } # Sanity, check tools exist. cargo --version rustc --version # Run the linter if told to. if [ "${DO_LINT-false}" = true ] then cargo clippy --all-features --all-targets -- -D warnings fi # Run formatter if told to. if [ "${DO_FMT-false}" = true ]; then if [ "$NIGHTLY" = false ]; then echo "DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)" exit 1 fi rustup component add rustfmt cargo fmt --check fi if [ "${DO_FEATURE_MATRIX-false}" = true ]; then # No features build_and_test "" # Feature combos build_and_test "std" build_and_test "alloc" build_and_test "std alloc" fi # Build the docs if told to (this only works with the nightly toolchain) if [ "${DO_DOCSRS-false}" = true ]; then RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features fi # Build the docs with a stable toolchain, in unison with the DO_DOCSRS command # above this checks that we feature guarded docs imports correctly. if [ "${DO_DOCS-false}" = true ]; then RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features fi # Bench if told to. if [ "${DO_BENCH-false}" = true ] then # Technically we could use beta too but we only run this in CI using nightly. if [ "$NIGHTLY" = false ]; then echo "DO_BENCH requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)" exit 1 fi RUSTFLAGS='--cfg=bench' cargo bench fi exit 0 bech32-0.11.0/embedded/README.md000064400000000000000000000006051046102023000137620ustar 00000000000000## Embedded tests These no-std tests are a bit peculiar. They are cross compiled to ARM and run in an emulator. Here's why: - We want to build for an exotic platform to help make sure `std` doesn't sneak in by accident. - We use an emulator and build something runnable, rather than merely testing whether a library builds, because we want to actually run our integration test. bech32-0.11.0/githooks/pre-commit000075500000000000000000000032751046102023000146110ustar 00000000000000#!/bin/sh # # Verify what is about to be committed. Called by "git commit" with no # arguments. The hook should exit with non-zero status after issuing an # appropriate message if it wants to stop the commit. if git rev-parse --verify HEAD >/dev/null 2>&1 then against=HEAD else # Initial commit: diff against an empty tree object against=$(git hash-object -t tree /dev/null) fi # If you want to allow non-ASCII filenames set this variable to true. allownonascii=$(git config --bool hooks.allownonascii) # Redirect output to stderr. exec 1>&2 # Cross platform projects tend to avoid non-ASCII filenames; prevent # them from being added to the repository. We exploit the fact that the # printable range starts at the space character and ends with tilde. if [ "$allownonascii" != "true" ] && # Note that the use of brackets around a tr range is ok here, (it's # even required, for portability to Solaris 10's /usr/bin/tr), since # the square bracket bytes happen to fall in the designated range. test $(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 then cat <<\EOF Error: Attempt to add a non-ASCII file name. This can cause problems if you want to work with people on other platforms. To be portable it is advisable to rename the file. If you know what you are doing you can disable this check using: git config hooks.allownonascii true EOF exit 1 fi # If there are whitespace errors, print the offending file names and fail. git diff-index --check --cached $against -- || exit 1 # Check that code lints cleanly. cargo clippy --all-features -- -D warnings || exit 1 # Check that there are no formatting issues. cargo +nightly fmt --check || exit 1 bech32-0.11.0/justfile000064400000000000000000000011551046102023000125230ustar 00000000000000[private] default: @just --list # run `cargo build` on everything build: cargo build --workspace --all-targets # run `cargo check` on everything check: cargo check --workspace --all-targets # run code formatter format: cargo +nightly fmt # run tests test: build cargo test --all-features # run `cargo clippy` on everything clippy: cargo clippy --locked --offline --workspace --all-targets -- --deny warnings # run `cargo clippy --fix` on everything clippy-fix: cargo clippy --locked --offline --workspace --all-targets --fix # Check for API changes. check-api: contrib/check-for-api-changes.sh bech32-0.11.0/rustfmt.toml000064400000000000000000000044211046102023000133530ustar 00000000000000ignore = [] hard_tabs = false tab_spaces = 4 newline_style = "Auto" indent_style = "Block" max_width = 100 # This is number of characters. # `use_small_heuristics` is ignored if the granular width config values are explicitly set. use_small_heuristics = "Max" # "Max" == All granular width settings same as `max_width`. # # Granular width configuration settings. These are percentages of `max_width`. # fn_call_width = 60 # attr_fn_like_width = 70 # struct_lit_width = 18 # struct_variant_width = 35 # array_width = 60 # chain_width = 60 # single_line_if_else_max_width = 50 wrap_comments = false format_code_in_doc_comments = false comment_width = 100 # Default 80 normalize_comments = false normalize_doc_attributes = false format_strings = false format_macro_matchers = false format_macro_bodies = true hex_literal_case = "Preserve" empty_item_single_line = true struct_lit_single_line = true fn_single_line = true # Default false where_single_line = false imports_indent = "Block" imports_layout = "Mixed" imports_granularity = "Module" # Default "Preserve" group_imports = "StdExternalCrate" # Default "Preserve" reorder_imports = true reorder_modules = true reorder_impl_items = false type_punctuation_density = "Wide" space_before_colon = false space_after_colon = true spaces_around_ranges = false binop_separator = "Front" remove_nested_parens = true combine_control_expr = true overflow_delimited_expr = false struct_field_align_threshold = 0 enum_discrim_align_threshold = 0 match_arm_blocks = false # Default true match_arm_leading_pipes = "Never" force_multiline_blocks = false fn_params_layout = "Tall" brace_style = "SameLineWhere" control_brace_style = "AlwaysSameLine" trailing_semicolon = true trailing_comma = "Vertical" match_block_trailing_comma = false blank_lines_upper_bound = 1 blank_lines_lower_bound = 0 edition = "2018" version = "One" inline_attribute_width = 0 format_generated_files = true merge_derives = true use_try_shorthand = false use_field_init_shorthand = false force_explicit_abi = true condense_wildcard_suffixes = false color = "Auto" unstable_features = false disable_all_formatting = false skip_children = false hide_parse_errors = false error_on_line_overflow = false error_on_unformatted = false emit_mode = "Files" make_backup = false bech32-0.11.0/src/error.rs000064400000000000000000000013531046102023000132410ustar 00000000000000// SPDX-License-Identifier: CC0-1.0 /// Formats error. /// /// If `std` feature is OFF appends error source (delimited by `: `). We do this because /// `e.source()` is only available in std builds, without this macro the error source is lost for /// no-std builds. macro_rules! write_err { ($writer:expr, $string:literal $(, $args:expr)*; $source:expr) => { { #[cfg(feature = "std")] { let _ = &$source; // Prevents clippy warnings. write!($writer, $string $(, $args)*) } #[cfg(not(feature = "std"))] { write!($writer, concat!($string, ": {}") $(, $args)*, $source) } } } } pub(crate) use write_err; bech32-0.11.0/src/hrp.rs000064400000000000000000000004041046102023000126750ustar 00000000000000// SPDX-License-Identifier: MIT //! Re-exports the hrp types from [`primitives::hrp`] to make importing ergonomic for the top level APIs. //! //! [`primitives::hrp`]: crate::primitives::hrp #[doc(inline)] pub use crate::primitives::hrp::{Hrp, BC, BCRT, TB}; bech32-0.11.0/src/lib.rs000064400000000000000000000555231046102023000126660ustar 00000000000000// Written by Clark Moody and the rust-bitcoin developers. // SPDX-License-Identifier: MIT //! Encoding and decoding of the Bech32 format. //! //! Bech32 is an encoding scheme that is easy to use for humans and efficient to encode in QR codes. //! //! A Bech32 string consists of a human-readable part (HRP), a separator (the character `'1'`), and //! a data part. A checksum at the end of the string provides error detection to prevent mistakes //! when the string is written off or read out loud. //! //! # Usage //! //! - If you are doing segwit stuff you likely want to use the [`segwit`] API. //! - Non-segwit stuff and you have an allocator, use the top level API. For normal usage the //! `encode` and `decode` functions should suffice. There are also various other functions for //! explicit control of the checksum algorithm and the case used when encoding. //! - Non-segwit stuff and you do *not* have an allocator, use the [`CheckedHrpstring`] type for //! decoding. For encoding we provide various top level functions of the form `encode*_to_fmt`. //! - To define your own checksum algorithm implement [`Checksum`] (see example below). //! //! The original description in [BIP-173] has more details. See also [BIP-350]. //! //! # Deviation from spec //! //! We do not enforce the 90 character limit specified by [BIP-173], instead we enforce the code //! length for the respective checksum algorithm (see [`Checksum::CODE_LENGTH`]). We do however //! enforce the 90 character limit within the `segwit` modules and types. //! //! # Examples //! //! ## Encoding //! //! ``` //! # #[cfg(feature = "alloc")] { //! use bech32::{hrp, segwit, Hrp, Bech32m}; //! //! const DATA: [u8; 20] = [0xab; 20]; // Arbitrary data to be encoded. //! const STRING: &str = "abc14w46h2at4w46h2at4w46h2at4w46h2at958ngu"; //! const TAP_ADDR: &str = "bc1p4w46h2at4w46h2at4w46h2at4w46h2at5kreae"; //! //! // Encode arbitrary data using "abc" as the human-readable part and append a bech32m checksum. //! let hrp = Hrp::parse("abc").expect("valid hrp"); //! let string = bech32::encode::(hrp, &DATA).expect("failed to encode string"); //! assert_eq!(string, STRING); //! //! // Encode arbitrary data as a Bitcoin taproot address. //! let taproot_address = segwit::encode(hrp::BC, segwit::VERSION_1, &DATA).expect("valid witness version and program"); //! assert_eq!(taproot_address, TAP_ADDR); //! //! // No-alloc: Encode without allocating (ignoring that String::new() allocates :). //! let mut buf = String::new(); //! bech32::encode_to_fmt::(&mut buf, hrp, &DATA).expect("failed to encode to buffer"); //! assert_eq!(buf, STRING); //! # } //! ``` //! //! ## Decoding //! //! ``` //! # #[cfg(feature = "alloc")] { //! use bech32::primitives::decode::{CheckedHrpstring, SegwitHrpstring}; //! use bech32::{hrp, segwit, Hrp, Bech32m}; //! //! const DATA: [u8; 20] = [0xab; 20]; // Arbitrary data to be encoded. //! const STRING: &str = "abc14w46h2at4w46h2at4w46h2at4w46h2at958ngu"; //! const TAP_ADDR: &str = "bc1p4w46h2at4w46h2at4w46h2at4w46h2at5kreae"; //! //! // Decode a bech32 encoded string that includes a bech32/bech32m checksum. //! // //! // The input address MUST include a valid bech32 or bech32m checksum, for individual specific //! // checksum algorithms see [`decode_bech32`], [`decode_bech32m`], [`decode_no_checksum`] or use //! // the [`primitives::decode::CheckedHrpstring`] type directly. //! let (hrp, data) = bech32::decode(&STRING).expect("failed to decode"); //! assert_eq!(hrp, Hrp::parse("abc").unwrap()); //! assert_eq!(data, DATA); //! //! // Decode a Bitcoin taproot address. //! let (_hrp, _version, program) = segwit::decode(&TAP_ADDR).expect("valid address"); //! assert_eq!(program, DATA); //! //! // No-alloc: Decode a bech32m checksummed address without allocating. //! let p = CheckedHrpstring::new::(&STRING).expect("failed to parse string"); //! assert_eq!(hrp, p.hrp()); //! assert!(p.byte_iter().eq(DATA.iter().map(|&b| b))); // We yield bytes not references. //! //! // No-alloc: Decode a taproot address without allocating. //! let taproot = SegwitHrpstring::new(&TAP_ADDR).expect("valid address"); //! // Do something with the encoded data. //! let _ = taproot.byte_iter(); //! # } //! ``` //! //! ## Custom Checksum //! //! ``` //! # #[cfg(feature = "alloc")] { //! use bech32::Checksum; //! //! /// The codex32 checksum algorithm, defined in BIP-93. //! #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] //! pub enum Codex32 {} //! //! impl Checksum for Codex32 { //! type MidstateRepr = u128; //! const CHECKSUM_LENGTH: usize = 13; //! const CODE_LENGTH: usize = 93; //! // Copied from BIP-93 //! const GENERATOR_SH: [u128; 5] = [ //! 0x19dc500ce73fde210, //! 0x1bfae00def77fe529, //! 0x1fbd920fffe7bee52, //! 0x1739640bdeee3fdad, //! 0x07729a039cfc75f5a, //! ]; //! const TARGET_RESIDUE: u128 = 0x10ce0795c2fd1e62a; //! } //! //! # } //! ``` //! //! [BIP-173]: //! [BIP-350]: //! [`CheckedHrpstring`]: crate::primitives::decode::CheckedHrpstring //! [`Checksum::CODE_LENGTH`]: crate::primitives::checksum::Checksum::CODE_LENGTH #![cfg_attr(all(not(feature = "std"), not(test)), no_std)] // Experimental features we need. #![cfg_attr(bench, feature(test))] #![cfg_attr(docsrs, feature(doc_auto_cfg))] // Coding conventions #![deny(missing_docs)] #[cfg(bench)] extern crate test; #[cfg(feature = "alloc")] extern crate alloc; #[cfg(any(test, feature = "std"))] extern crate core; mod error; pub mod hrp; pub mod primitives; pub mod segwit; #[cfg(all(feature = "alloc", not(feature = "std"), not(test)))] use alloc::{string::String, vec::Vec}; use core::fmt; use crate::error::write_err; #[cfg(doc)] use crate::primitives::decode::CheckedHrpstring; use crate::primitives::decode::CodeLengthError; #[cfg(feature = "alloc")] use crate::primitives::decode::{ChecksumError, UncheckedHrpstring, UncheckedHrpstringError}; #[rustfmt::skip] // Keep public re-exports separate. #[doc(inline)] pub use { crate::primitives::checksum::Checksum, crate::primitives::gf32::Fe32, crate::primitives::hrp::Hrp, crate::primitives::iter::{ByteIterExt, Fe32IterExt}, crate::primitives::{Bech32, Bech32m, NoChecksum}, }; // Write to fmt buffer, small during testing to exercise full code path. #[cfg(not(test))] const BUF_LENGTH: usize = 1024; #[cfg(test)] const BUF_LENGTH: usize = 10; /// Decodes a bech32 encoded string. /// /// If this function succeeds the input string was found to be well formed (hrp, separator, bech32 /// characters), and to have either a valid bech32m checksum or a valid bech32 checksum. /// /// If your input string has no checksum use the [`CheckedHrpstring`] constructor, which allows /// selecting the checksum algorithm explicitly. /// /// # Returns /// /// The human-readable part and the encoded data with the checksum removed. /// /// # Examples /// ``` /// # #[cfg(feature = "alloc")] { /// use bech32::{decode, Bech32, Bech32m, NoChecksum}; /// use bech32::primitives::decode::CheckedHrpstring; /// /// const BECH32: &str = "abc14w46h2at4w46h2at4w46h2at4w46h2atsghld7"; /// const BECH32M: &str = "abc14w46h2at4w46h2at4w46h2at4w46h2at958ngu"; /// const NO_CHECKSUM: &str = "abc14w46h2at4w46h2at4w46h2at4w46h2at"; /// /// let (hrp, data) = decode(&BECH32).expect("valid bech32 string with valid bech32 checksum"); /// let (hrp, data) = decode(&BECH32M).expect("valid bech32 string with valid bech32m checksum"); /// assert!(decode(&NO_CHECKSUM).is_err()); /// /// // You can control the checksum algorithm directly by using the [`CheckedHrpstring`] type. /// let p = CheckedHrpstring::new::(&BECH32).expect("valid bech32 string with valid bech32 checksum"); /// let p = CheckedHrpstring::new::(&BECH32M).expect("valid bech32 string with valid bech32 checksum"); /// let p = CheckedHrpstring::new::(&NO_CHECKSUM).expect("valid bech32 string with no checksum"); /// # } /// ``` #[cfg(feature = "alloc")] #[inline] pub fn decode(s: &str) -> Result<(Hrp, Vec), DecodeError> { let unchecked = UncheckedHrpstring::new(s)?; if let Err(e) = unchecked.validate_checksum::() { if !unchecked.has_valid_checksum::() { return Err(DecodeError::Checksum(e)); } }; // One of the checksums was valid, Ck is only for length and since // they are both the same we can use either here. let checked = unchecked.remove_checksum::(); Ok((checked.hrp(), checked.byte_iter().collect())) } /// Encodes `data` as a lowercase bech32 encoded string. /// /// Encoded string will be prefixed with the `hrp` and have a checksum appended as specified by the /// `Ck` algorithm (`NoChecksum` to exclude checksum all together). #[cfg(feature = "alloc")] #[inline] pub fn encode(hrp: Hrp, data: &[u8]) -> Result { encode_lower::(hrp, data) } /// Encodes `data` as a lowercase bech32 encoded string. /// /// Encoded string will be prefixed with the `hrp` and have a checksum appended as specified by the /// `Ck` algorithm (`NoChecksum` to exclude checksum all together). #[cfg(feature = "alloc")] #[inline] pub fn encode_lower(hrp: Hrp, data: &[u8]) -> Result { let mut buf = String::new(); encode_lower_to_fmt::(&mut buf, hrp, data)?; Ok(buf) } /// Encodes `data` as an uppercase bech32 encoded string. /// /// Encoded string will be prefixed with the `hrp` and have a checksum appended as specified by the /// `Ck` algorithm (`NoChecksum` to exclude checksum all together). #[cfg(feature = "alloc")] #[inline] pub fn encode_upper(hrp: Hrp, data: &[u8]) -> Result { let mut buf = String::new(); encode_upper_to_fmt::(&mut buf, hrp, data)?; Ok(buf) } /// Encodes `data` to a writer ([`fmt::Write`]) as a lowercase bech32 encoded string. /// /// Encoded string will be prefixed with the `hrp` and have a checksum appended as specified by the /// `Ck` algorithm (`NoChecksum` to exclude checksum all together). #[inline] pub fn encode_to_fmt( fmt: &mut W, hrp: Hrp, data: &[u8], ) -> Result<(), EncodeError> { encode_lower_to_fmt::(fmt, hrp, data) } /// Encodes `data` to a writer ([`fmt::Write`]) as a lowercase bech32 encoded string. /// /// Encoded string will be prefixed with the `hrp` and have a checksum appended as specified by the /// `Ck` algorithm (`NoChecksum` to exclude checksum all together). #[inline] pub fn encode_lower_to_fmt( fmt: &mut W, hrp: Hrp, data: &[u8], ) -> Result<(), EncodeError> { let _ = encoded_length::(hrp, data)?; let mut buf = [0u8; BUF_LENGTH]; let mut pos = 0; let iter = data.iter().copied().bytes_to_fes(); let chars = iter.with_checksum::(&hrp).chars(); for c in chars { buf[pos] = c as u8; pos += 1; if pos == BUF_LENGTH { let s = core::str::from_utf8(&buf).expect("we only write ASCII"); fmt.write_str(s)?; pos = 0; } } let s = core::str::from_utf8(&buf[..pos]).expect("we only write ASCII"); fmt.write_str(s)?; Ok(()) } /// Encodes `data` to a writer ([`fmt::Write`]) as a uppercase bech32 encoded string. /// /// Encoded string will be prefixed with the `hrp` and have a checksum appended as specified by the /// `Ck` algorithm (`NoChecksum` to exclude checksum all together). #[inline] pub fn encode_upper_to_fmt( fmt: &mut W, hrp: Hrp, data: &[u8], ) -> Result<(), EncodeError> { let _ = encoded_length::(hrp, data)?; let mut buf = [0u8; BUF_LENGTH]; let mut pos = 0; let iter = data.iter().copied().bytes_to_fes(); let chars = iter.with_checksum::(&hrp).chars(); for c in chars { buf[pos] = c.to_ascii_uppercase() as u8; pos += 1; if pos == BUF_LENGTH { let s = core::str::from_utf8(&buf).expect("we only write ASCII"); fmt.write_str(s)?; pos = 0; } } let s = core::str::from_utf8(&buf[..pos]).expect("we only write ASCII"); fmt.write_str(s)?; Ok(()) } /// Encodes `data` to a writer ([`io::Write`]) as a lowercase bech32 encoded string. /// /// Encoded string will be prefixed with the `hrp` and have a checksum appended as specified by the /// `Ck` algorithm (`NoChecksum` to exclude checksum all together). /// /// [`io::Write`]: std::io::Write #[cfg(feature = "std")] #[inline] pub fn encode_to_writer( w: &mut W, hrp: Hrp, data: &[u8], ) -> Result<(), EncodeIoError> { encode_lower_to_writer::(w, hrp, data) } /// Encodes `data` to a writer ([`io::Write`]) as a lowercase bech32 encoded string. /// /// Encoded string will be prefixed with the `hrp` and have a checksum appended as specified by the /// `Ck` algorithm (`NoChecksum` to exclude checksum all together). /// /// [`io::Write`]: std::io::Write #[cfg(feature = "std")] #[inline] pub fn encode_lower_to_writer( w: &mut W, hrp: Hrp, data: &[u8], ) -> Result<(), EncodeIoError> { let _ = encoded_length::(hrp, data)?; let mut buf = [0u8; BUF_LENGTH]; let mut pos = 0; let iter = data.iter().copied().bytes_to_fes(); let chars = iter.with_checksum::(&hrp).chars(); for c in chars { buf[pos] = c as u8; pos += 1; if pos == BUF_LENGTH { w.write_all(&buf)?; pos = 0; } } w.write_all(&buf[..pos])?; Ok(()) } /// Encodes `data` to a writer ([`io::Write`]) as a uppercase bech32 encoded string. /// /// Encoded string will be prefixed with the `hrp` and have a checksum appended as specified by the /// `Ck` algorithm (`NoChecksum` to exclude checksum all together). /// /// [`io::Write`]: std::io::Write #[cfg(feature = "std")] #[inline] pub fn encode_upper_to_writer( w: &mut W, hrp: Hrp, data: &[u8], ) -> Result<(), EncodeIoError> { let _ = encoded_length::(hrp, data)?; let mut buf = [0u8; BUF_LENGTH]; let mut pos = 0; let iter = data.iter().copied().bytes_to_fes(); let chars = iter.with_checksum::(&hrp).chars(); for c in chars { buf[pos] = c.to_ascii_uppercase() as u8; pos += 1; if pos == BUF_LENGTH { w.write_all(&buf)?; pos = 0; } } w.write_all(&buf[..pos])?; Ok(()) } /// Checks that encoding `hrp` and `data` creates a code that is less than the code length for `Ck`. /// /// The length of the code is how long a coded message can be (including the checksum!) for the code /// to retain its error-correcting properties. /// /// # Returns /// /// `Ok(encoded_string_length)` if the encoded length is less than or equal to `Ck::CODE_LENGTH` /// otherwise a [`CodeLengthError`] containing the encoded length and the maximum allowed. pub fn encoded_length(hrp: Hrp, data: &[u8]) -> Result { let iter = data.iter().copied().bytes_to_fes(); let len = hrp.len() + 1 + iter.len() + Ck::CHECKSUM_LENGTH; // +1 for separator if len > Ck::CODE_LENGTH { Err(CodeLengthError { encoded_length: len, code_length: Ck::CODE_LENGTH }) } else { Ok(len) } } /// An error while decoding a bech32 string. #[cfg(feature = "alloc")] #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum DecodeError { /// Parsing failed. Parse(UncheckedHrpstringError), /// No valid bech32 or bech32m checksum. Checksum(ChecksumError), } #[cfg(feature = "alloc")] impl fmt::Display for DecodeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use DecodeError::*; match *self { Parse(ref e) => write_err!(f, "parsing failed"; e), Checksum(ref e) => write_err!(f, "no valid bech32 or bech32m checksum"; e), } } } #[cfg(feature = "std")] impl std::error::Error for DecodeError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use DecodeError::*; match *self { Parse(ref e) => Some(e), Checksum(ref e) => Some(e), } } } #[cfg(feature = "alloc")] impl From for DecodeError { #[inline] fn from(e: UncheckedHrpstringError) -> Self { Self::Parse(e) } } /// An error while encoding a bech32 string. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum EncodeError { /// Encoding HRP and data into a bech32 string exceeds maximum allowed. TooLong(CodeLengthError), /// Encode to formatter failed. Fmt(fmt::Error), } impl fmt::Display for EncodeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use EncodeError::*; match *self { TooLong(ref e) => write_err!(f, "encode error"; e), Fmt(ref e) => write_err!(f, "encode to formatter failed"; e), } } } #[cfg(feature = "std")] impl std::error::Error for EncodeError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use EncodeError::*; match *self { TooLong(ref e) => Some(e), Fmt(ref e) => Some(e), } } } impl From for EncodeError { #[inline] fn from(e: CodeLengthError) -> Self { Self::TooLong(e) } } impl From for EncodeError { #[inline] fn from(e: fmt::Error) -> Self { Self::Fmt(e) } } /// An error while encoding a bech32 string. #[cfg(feature = "std")] #[derive(Debug)] #[non_exhaustive] pub enum EncodeIoError { /// Encoding HRP and data into a bech32 string exceeds maximum allowed. TooLong(CodeLengthError), /// Encode to writer failed. Write(std::io::Error), } #[cfg(feature = "std")] impl fmt::Display for EncodeIoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use EncodeIoError::*; match *self { TooLong(ref e) => write_err!(f, "encode error"; e), Write(ref e) => write_err!(f, "encode to writer failed"; e), } } } #[cfg(feature = "std")] impl std::error::Error for EncodeIoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use EncodeIoError::*; match *self { TooLong(ref e) => Some(e), Write(ref e) => Some(e), } } } #[cfg(feature = "std")] impl From for EncodeIoError { #[inline] fn from(e: CodeLengthError) -> Self { Self::TooLong(e) } } #[cfg(feature = "std")] impl From for EncodeIoError { #[inline] fn from(e: std::io::Error) -> Self { Self::Write(e) } } #[cfg(test)] #[cfg(feature = "alloc")] mod tests { use super::*; use crate::{Bech32, Bech32m}; // Tests below using this data, are based on the test vector (from BIP-173): // BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4: 0014751e76e8199196d454941c45d1b3a323f1433bd6 #[rustfmt::skip] const DATA: [u8; 20] = [ 0xff, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6, ]; #[test] fn encode_bech32m() { let hrp = Hrp::parse_unchecked("test"); let got = encode::(hrp, &DATA).expect("failed to encode"); let want = "test1lu08d6qejxtdg4y5r3zarvary0c5xw7kmz4lky"; assert_eq!(got, want); } #[test] fn encode_bech32_lower() { let hrp = Hrp::parse_unchecked("test"); let got = encode_lower::(hrp, &DATA).expect("failed to encode"); let want = "test1lu08d6qejxtdg4y5r3zarvary0c5xw7kw79nnx"; assert_eq!(got, want); } #[test] #[cfg(feature = "std")] fn encode_bech32_lower_to_writer() { let hrp = Hrp::parse_unchecked("test"); let mut buf = Vec::new(); encode_lower_to_writer::(&mut buf, hrp, &DATA).expect("failed to encode"); let got = std::str::from_utf8(&buf).expect("ascii is valid utf8"); let want = "test1lu08d6qejxtdg4y5r3zarvary0c5xw7kw79nnx"; assert_eq!(got, want); } #[test] fn encode_bech32_upper() { let hrp = Hrp::parse_unchecked("test"); let got = encode_upper::(hrp, &DATA).expect("failed to encode"); let want = "TEST1LU08D6QEJXTDG4Y5R3ZARVARY0C5XW7KW79NNX"; assert_eq!(got, want); } #[test] #[cfg(feature = "std")] fn encode_bech32_upper_to_writer() { let hrp = Hrp::parse_unchecked("test"); let mut buf = Vec::new(); encode_upper_to_writer::(&mut buf, hrp, &DATA).expect("failed to encode"); let got = std::str::from_utf8(&buf).expect("ascii is valid utf8"); let want = "TEST1LU08D6QEJXTDG4Y5R3ZARVARY0C5XW7KW79NNX"; assert_eq!(got, want); } #[test] fn decode_bech32m() { let s = "test1lu08d6qejxtdg4y5r3zarvary0c5xw7kmz4lky"; let (hrp, data) = decode(s).expect("failed to encode"); assert_eq!(hrp, Hrp::parse_unchecked("test")); assert_eq!(data, DATA); } #[test] fn decode_bech32_lower() { let s = "test1lu08d6qejxtdg4y5r3zarvary0c5xw7kw79nnx"; let (hrp, data) = decode(s).expect("failed to encode"); assert_eq!(hrp, Hrp::parse_unchecked("test")); assert_eq!(data, DATA); } #[test] fn decode_bech32_upper() { let s = "TEST1LU08D6QEJXTDG4Y5R3ZARVARY0C5XW7KW79NNX"; let (hrp, data) = decode(s).expect("failed to encode"); assert_eq!(hrp, Hrp::parse_unchecked("TEST")); assert_eq!(data, DATA); } #[test] fn encoded_length_works() { let s = "test1lu08d6qejxtdg4y5r3zarvary0c5xw7kmz4lky"; let (hrp, data) = decode(s).expect("valid string"); let encoded = encode::(hrp, &data).expect("valid data"); let want = encoded.len(); let got = encoded_length::(hrp, &data).expect("encoded length"); assert_eq!(got, want); } #[test] fn can_encode_maximum_length_string() { let data = [0_u8; 632]; let hrp = Hrp::parse_unchecked("abcd"); let s = encode::(hrp, &data).expect("valid data"); assert_eq!(s.len(), 1023); } #[test] fn can_not_encode_string_too_long() { let data = [0_u8; 632]; let hrp = Hrp::parse_unchecked("abcde"); match encode::(hrp, &data) { Ok(_) => panic!("false positive"), Err(EncodeError::TooLong(CodeLengthError { encoded_length, code_length: _ })) => assert_eq!(encoded_length, 1024), _ => panic!("false negative"), } } #[test] fn can_decode_segwit_too_long_string() { // A 91 character long string, greater than the segwit enforced maximum of 90. let s = "abcd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrw9z3s"; assert!(decode(s).is_ok()); } } bech32-0.11.0/src/primitives/checksum.rs000064400000000000000000000240361046102023000161100ustar 00000000000000// SPDX-License-Identifier: MIT //! Degree-2 [BCH] code checksum. //! //! [BCH]: use core::{mem, ops}; use crate::primitives::gf32::Fe32; use crate::primitives::hrp::Hrp; /// Trait defining a particular checksum. /// /// For users, this can be treated as a marker trait; none of the associated data /// are end-user relevant. pub trait Checksum { /// An unsigned integer type capable of holding a packed version of the generator /// polynomial (without its leading 1) and target residue (which will have the /// same width). /// /// Generally, this is the number of characters in the checksum times 5. So e.g. /// for bech32, which has a 6-character checksum, we need 30 bits, so we can use /// u32 here. /// /// The smallest type possible should be used, for efficiency reasons, but the /// only operations we do on these types are bitwise xor and shifts, so it should /// be pretty efficient no matter what. type MidstateRepr: PackedFe32; /// The length of the code. /// /// The length of the code is how long a coded message can be (including the /// checksum!) for the code to retain its error-correcting properties. const CODE_LENGTH: usize; /// The number of characters in the checksum. /// /// Alternately, the degree of the generator polynomial. This is **not** the same /// as `Self::CODE_LENGTH`. const CHECKSUM_LENGTH: usize; /// The coefficients of the generator polynomial, except the leading monic term, /// in "big-endian" (highest-degree coefficients get leftmost bits) order, along /// with the 4 shifts of the generator. /// /// The shifts are literally the generator polynomial left-shifted (i.e. multiplied /// by the appropriate power of 2) in the field. That is, the 5 entries in this /// array are the generator times { P, Z, Y, G, S } in that order. /// /// These cannot be usefully pre-computed because of Rust's limited constfn support /// as of 1.67, so they must be specified manually for each checksum. To check the /// values for consistency, run `Self::sanity_check()`. const GENERATOR_SH: [Self::MidstateRepr; 5]; /// The residue, modulo the generator polynomial, that a valid codeword will have. const TARGET_RESIDUE: Self::MidstateRepr; /// Sanity checks that the various constants of the trait are set in a way that they /// are consistent with each other. /// /// This function never needs to be called by users, but anyone defining a checksum /// should add a unit test to their codebase which calls this. fn sanity_check() { // Check that the declared midstate type can actually hold the whole checksum. assert!(Self::CHECKSUM_LENGTH <= Self::MidstateRepr::WIDTH); // Check that the provided generator polynomials are, indeed, the same polynomial just shifted. for i in 1..5 { for j in 0..Self::MidstateRepr::WIDTH { let last = Self::GENERATOR_SH[i - 1].unpack(j); let curr = Self::GENERATOR_SH[i].unpack(j); // GF32 is defined by extending GF2 with a root of x^5 + x^3 + 1 = 0 // which when written as bit coefficients is 41 = 0. Hence xoring // (adding, in GF32) by 41 is the way to reduce x^5. assert_eq!( curr, (last << 1) ^ if last & 0x10 == 0x10 { 41 } else { 0 }, "Element {} of generator << 2^{} was incorrectly computed. (Should have been {} << 1)", j, i, last, ); } } } } /// A checksum engine, which can be used to compute or verify a checksum. /// /// Use this to verify a checksum, feed it the data to be checksummed using /// the `Self::input_*` methods. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct Engine { residue: Ck::MidstateRepr, } impl Default for Engine { fn default() -> Self { Self::new() } } impl Engine { /// Constructs a new checksum engine with no data input. #[inline] pub fn new() -> Self { Engine { residue: Ck::MidstateRepr::ONE } } /// Feeds `hrp` into the checksum engine. #[inline] pub fn input_hrp(&mut self, hrp: Hrp) { for fe in HrpFe32Iter::new(&hrp) { self.input_fe(fe) } } /// Adds a single gf32 element to the checksum engine. /// /// This is where the actual checksum computation magic happens. #[inline] pub fn input_fe(&mut self, e: Fe32) { let xn = self.residue.mul_by_x_then_add(Ck::CHECKSUM_LENGTH, e.into()); for i in 0..5 { if xn & (1 << i) != 0 { self.residue = self.residue ^ Ck::GENERATOR_SH[i]; } } } /// Inputs the target residue of the checksum. /// /// Checksums are generated by appending the target residue to the input /// string, then computing the actual residue, and then replacing the /// target with the actual. This method lets us compute the actual residue /// without doing any string concatenations. #[inline] pub fn input_target_residue(&mut self) { for i in 0..Ck::CHECKSUM_LENGTH { self.input_fe(Fe32(Ck::TARGET_RESIDUE.unpack(Ck::CHECKSUM_LENGTH - i - 1))); } } /// Returns for the current checksum residue. #[inline] pub fn residue(&self) -> &Ck::MidstateRepr { &self.residue } } /// Trait describing an integer type which can be used as a "packed" sequence of Fe32s. /// /// This is implemented for u32, u64 and u128, as a way to treat these primitive types as /// packed coefficients of polynomials over GF32 (up to some maximal degree, of course). /// /// This is useful because then multiplication by x reduces to simply left-shifting by 5, /// and addition of entire polynomials can be done by xor. pub trait PackedFe32: Copy + PartialEq + Eq + ops::BitXor { /// The one constant, for which stdlib provides no existing trait. const ONE: Self; /// The number of fe32s that can fit into the type; computed as floor(bitwidth / 5). const WIDTH: usize = mem::size_of::() * 8 / 5; /// Extracts the coefficient of the x^n from the packed polynomial. fn unpack(&self, n: usize) -> u8; /// Multiply the polynomial by x, drop its highest coefficient (and return it), and /// add a new field element to the now-0 constant coefficient. /// /// Takes the degree of the polynomial as an input; for checksum applications /// this should basically always be `Checksum::CHECKSUM_WIDTH`. fn mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8; } /// A placeholder type used as part of the [`NoChecksum`] "checksum". /// /// [`NoChecksum`]: crate::primitives::NoChecksum #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct PackedNull; impl ops::BitXor for PackedNull { type Output = PackedNull; #[inline] fn bitxor(self, _: PackedNull) -> PackedNull { PackedNull } } impl PackedFe32 for PackedNull { const ONE: Self = PackedNull; #[inline] fn unpack(&self, _: usize) -> u8 { 0 } #[inline] fn mul_by_x_then_add(&mut self, _: usize, _: u8) -> u8 { 0 } } macro_rules! impl_packed_fe32 { ($ty:ident) => { impl PackedFe32 for $ty { const ONE: Self = 1; #[inline] fn unpack(&self, n: usize) -> u8 { debug_assert!(n < Self::WIDTH); (*self >> (n * 5)) as u8 & 0x1f } #[inline] fn mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8 { debug_assert!(degree > 0); debug_assert!(degree <= Self::WIDTH); debug_assert!(add < 32); let ret = self.unpack(degree - 1); *self &= !(0x1f << ((degree - 1) * 5)); *self <<= 5; *self |= Self::from(add); ret } } }; } impl_packed_fe32!(u32); impl_packed_fe32!(u64); impl_packed_fe32!(u128); /// Iterator that yields the field elements that are input into a checksum algorithm for an [`Hrp`]. pub struct HrpFe32Iter<'hrp> { /// `None` once the hrp high fes have been yielded. high_iter: Option>, /// `None` once the hrp low fes have been yielded. low_iter: Option>, } impl<'hrp> HrpFe32Iter<'hrp> { /// Creates an iterator that yields the field elements of `hrp` as they are input into the /// checksum algorithm. #[inline] pub fn new(hrp: &'hrp Hrp) -> Self { let high_iter = hrp.lowercase_byte_iter(); let low_iter = hrp.lowercase_byte_iter(); Self { high_iter: Some(high_iter), low_iter: Some(low_iter) } } } impl<'hrp> Iterator for HrpFe32Iter<'hrp> { type Item = Fe32; #[inline] fn next(&mut self) -> Option { if let Some(ref mut high_iter) = &mut self.high_iter { match high_iter.next() { Some(high) => return Some(Fe32(high >> 5)), None => { self.high_iter = None; return Some(Fe32::Q); } } } if let Some(ref mut low_iter) = &mut self.low_iter { match low_iter.next() { Some(low) => return Some(Fe32(low & 0x1f)), None => self.low_iter = None, } } None } #[inline] fn size_hint(&self) -> (usize, Option) { let high = match &self.high_iter { Some(high_iter) => { let (min, max) = high_iter.size_hint(); (min + 1, max.map(|max| max + 1)) // +1 for the extra Q } None => (0, Some(0)), }; let low = match &self.low_iter { Some(low_iter) => low_iter.size_hint(), None => (0, Some(0)), }; let min = high.0 + 1 + low.0; let max = high.1.zip(low.1).map(|(high, low)| high + 1 + low); (min, max) } } bech32-0.11.0/src/primitives/decode.rs000064400000000000000000001304501046102023000155270ustar 00000000000000// SPDX-License-Identifier: MIT //! Decoding of bech32 encoded strings as specified by [BIP-173] and [BIP-350]. //! //! You should only need to use this module directly if you want control over exactly what is //! checked and when it is checked (correct bech32 characters, valid checksum, valid checksum for //! specific checksum algorithm, etc). If you are parsing/validating modern (post BIP-350) bitcoin //! segwit addresses consider using the [`crate::segwit`] API. //! //! If you do find yourself using this module directly then consider using the most general type //! that serves your purposes, each type can be created by parsing an address string to `new`. You //! likely do not want to arbitrarily transition from one type to the next even though possible. And //! be prepared to spend some time with the bips - you have been warned :) //! //! # Details //! //! A Bech32 string is at most 90 characters long and consists of: //! //! - The human-readable part, which is intended to convey the type of data, or anything else that //! is relevant to the reader. This part MUST contain 1 to 83 US-ASCII characters. //! - The separator, which is always "1". //! - The data part, which is at least 6 characters long and only consists of alphanumeric //! characters excluding "1", "b", "i", and "o". //! //! The types in this module heavily lean on the wording in BIP-173: *We first //! describe the general checksummed base32 format called Bech32 and then define Segregated Witness //! addresses using it.* //! //! - `UncheckedHrpstring`: Parses the general checksummed base32 format and provides checksum validation. //! - `CheckedHrpstring`: Provides access to the data encoded by a general checksummed base32 string and segwit checks. //! - `SegwitHrpstring`: Provides access to the data encoded by a segwit address. //! //! # Examples //! //! ``` //! use bech32::{Bech32, Bech32m, Fe32, Hrp}; //! use bech32::primitives::decode::{CheckedHrpstring, SegwitHrpstring, UncheckedHrpstring}; //! use bech32::segwit::VERSION_1; //! //! // An arbitrary HRP and a string of valid bech32 characters. //! let s = "abcd143hj65vxw49rts6kcw35u6r6tgzguyr03vvveeewjqpn05efzq444444"; //! assert!(UncheckedHrpstring::new(s).is_ok()); //! // But it has an invalid checksum. //! assert!(CheckedHrpstring::new::(s).is_err()); //! assert!(CheckedHrpstring::new::(s).is_err()); //! assert!(SegwitHrpstring::new(s).is_err()); //! //! // An arbitrary HRP, a string of valid bech32 characters, and a valid bech32 checksum. //! let s = "abcd14g08d6qejxtdg4y5r3zarvary0c5xw7kxugcx9"; //! assert!(UncheckedHrpstring::new(s).is_ok()); //! assert!(CheckedHrpstring::new::(s).is_ok()); //! // But not a valid segwit address. //! assert!(SegwitHrpstring::new(s).is_err()); //! // And not a valid bech32m checksum. //! assert!(CheckedHrpstring::new::(s).is_err()); //! //! // A valid Bitcoin taproot address. //! let s = "bc1pdp43hj65vxw49rts6kcw35u6r6tgzguyr03vvveeewjqpn05efzq7un9w0"; //! assert!(UncheckedHrpstring::new(s).is_ok()); //! assert!(CheckedHrpstring::new::(s).is_ok()); //! assert!(SegwitHrpstring::new(s).is_ok()); //! // But not a valid segwit v0 checksum. //! assert!(CheckedHrpstring::new::(s).is_err()); //! //! // Get the HRP, witness version, and encoded data. //! let address = "bc1pdp43hj65vxw49rts6kcw35u6r6tgzguyr03vvveeewjqpn05efzq7un9w0"; //! let segwit = SegwitHrpstring::new(address).expect("valid segwit address"); //! let _encoded_data = segwit.byte_iter(); //! assert_eq!(segwit.hrp(), Hrp::parse("bc").unwrap()); //! assert_eq!(segwit.witness_version(), VERSION_1); //! ``` //! //! [BIP-173]: //! [BIP-350]: use core::{fmt, iter, slice, str}; use crate::error::write_err; use crate::primitives::checksum::{self, Checksum}; use crate::primitives::gf32::Fe32; use crate::primitives::hrp::{self, Hrp}; use crate::primitives::iter::{Fe32IterExt, FesToBytes}; use crate::primitives::segwit::{self, WitnessLengthError, VERSION_0}; use crate::{Bech32, Bech32m}; /// Separator between the hrp and payload (as defined by BIP-173). const SEP: char = '1'; /// An HRP string that has been parsed but not yet had the checksum checked. /// /// Parsing an HRP string only checks validity of the characters, it does not validate the /// checksum in any way. /// /// Unless you are attempting to validate a string with multiple checksums then you likely do not /// want to use this type directly, instead use [`CheckedHrpstring::new(s)`]. /// /// # Examples /// /// ``` /// use bech32::{Bech32, Bech32m, primitives::decode::UncheckedHrpstring}; /// /// let addr = "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4"; /// let unchecked = UncheckedHrpstring::new(addr).expect("valid bech32 character encoded string"); /// if unchecked.has_valid_checksum::() { /// // Remove the checksum and do something with the data. /// let checked = unchecked.remove_checksum::(); /// let _ = checked.byte_iter(); /// } else if unchecked.has_valid_checksum::() { /// // Remove the checksum and do something with the data as above. /// } else { /// // Checksum is not valid for either the bech32 or bech32 checksum algorithms. /// } /// ``` #[derive(Debug)] pub struct UncheckedHrpstring<'s> { /// The human-readable part, guaranteed to be lowercase ASCII characters. hrp: Hrp, /// This is ASCII byte values of the parsed string, guaranteed to be valid bech32 characters. /// /// The characters after the separator i.e., the "data part" defined by BIP-173. data_part_ascii: &'s [u8], /// The length of the parsed hrpstring. hrpstring_length: usize, } impl<'s> UncheckedHrpstring<'s> { /// Parses an bech32 encode string and constructs a [`UncheckedHrpstring`] object. /// /// Checks for valid ASCII values, does not validate the checksum. #[inline] pub fn new(s: &'s str) -> Result { let sep_pos = check_characters(s)?; let (hrp, rest) = s.split_at(sep_pos); let ret = UncheckedHrpstring { hrp: Hrp::parse(hrp)?, data_part_ascii: rest[1..].as_bytes(), // Skip the separator. hrpstring_length: s.len(), }; Ok(ret) } /// Returns the human-readable part. #[inline] pub fn hrp(&self) -> Hrp { self.hrp } /// Returns the data part as ASCII bytes i.e., everything after the separator '1'. /// /// The byte values are guaranteed to be valid bech32 characters. Includes the checksum /// if one was present in the parsed string. /// /// # Examples /// /// ``` /// use bech32::primitives::decode::UncheckedHrpstring; /// /// let addr = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; /// let ascii = "qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; /// /// let unchecked = UncheckedHrpstring::new(&addr).unwrap(); /// assert!(unchecked.data_part_ascii().iter().eq(ascii.as_bytes().iter())) /// ``` #[inline] pub fn data_part_ascii(&self) -> &'s [u8] { self.data_part_ascii } /// Attempts to remove the first byte of the data part, treating it as a witness version. /// /// If [`Self::witness_version`] succeeds this function removes the first character (witness /// version byte) from the internal ASCII data part buffer. Future calls to /// [`Self::data_part_ascii`] will no longer include it. /// /// # Examples /// /// ``` /// use bech32::{primitives::decode::UncheckedHrpstring, Fe32}; /// /// let addr = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; /// let ascii = "ar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; /// /// let mut unchecked = UncheckedHrpstring::new(&addr).unwrap(); /// let witness_version = unchecked.remove_witness_version().unwrap(); /// assert_eq!(witness_version, Fe32::Q); /// assert!(unchecked.data_part_ascii().iter().eq(ascii.as_bytes().iter())) /// ``` #[inline] pub fn remove_witness_version(&mut self) -> Option { self.witness_version().map(|witver| { self.data_part_ascii = &self.data_part_ascii[1..]; // Remove the witness version byte. witver }) } /// Returns the segwit witness version if there is one. /// /// Attempts to convert the first character of the data part to a witness version. If this /// succeeds, and it is a valid version (0..16 inclusive) we return it, otherwise `None`. /// /// Future calls to [`Self::data_part_ascii`] will still include the witness version, use /// [`Self::remove_witness_version`] to remove it. /// /// This function makes no guarantees on the validity of the checksum. /// /// # Examples /// /// ``` /// use bech32::{primitives::decode::UncheckedHrpstring, Fe32}; /// /// // Note the invalid checksum! /// let addr = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzffffff"; /// /// let unchecked = UncheckedHrpstring::new(&addr).unwrap(); /// assert_eq!(unchecked.witness_version(), Some(Fe32::Q)); /// ``` #[inline] pub fn witness_version(&self) -> Option { let data_part = self.data_part_ascii(); if data_part.is_empty() { return None; } // unwrap ok because we know we gave valid bech32 characters. let witness_version = Fe32::from_char(data_part[0].into()).unwrap(); if witness_version.to_u8() > 16 { return None; } Some(witness_version) } /// Validates that data has a valid checksum for the `Ck` algorithm and returns a [`CheckedHrpstring`]. #[inline] pub fn validate_and_remove_checksum( self, ) -> Result, ChecksumError> { self.validate_checksum::()?; Ok(self.remove_checksum::()) } /// Validates that data has a valid checksum for the `Ck` algorithm (this may mean an empty /// checksum if `NoChecksum` is used). /// /// This is useful if you do not know which checksum algorithm was used and wish to validate /// against multiple algorithms consecutively. If this function returns `true` then call /// `remove_checksum` to get a [`CheckedHrpstring`]. #[inline] pub fn has_valid_checksum(&self) -> bool { self.validate_checksum::().is_ok() } /// Validates that data has a valid checksum for the `Ck` algorithm (this may mean an empty /// checksum if `NoChecksum` is used). #[inline] pub fn validate_checksum(&self) -> Result<(), ChecksumError> { use ChecksumError::*; if self.hrpstring_length > Ck::CODE_LENGTH { return Err(ChecksumError::CodeLength(CodeLengthError { encoded_length: self.hrpstring_length, code_length: Ck::CODE_LENGTH, })); } if Ck::CHECKSUM_LENGTH == 0 { // Called with NoChecksum return Ok(()); } if self.data_part_ascii.len() < Ck::CHECKSUM_LENGTH { return Err(InvalidLength); } let mut checksum_eng = checksum::Engine::::new(); checksum_eng.input_hrp(self.hrp()); // Unwrap ok since we checked all characters in our constructor. for fe in self.data_part_ascii.iter().map(|&b| Fe32::from_char_unchecked(b)) { checksum_eng.input_fe(fe); } if checksum_eng.residue() != &Ck::TARGET_RESIDUE { return Err(InvalidResidue); } Ok(()) } /// Removes the checksum for the `Ck` algorithm and returns an [`CheckedHrpstring`]. /// /// Data must be valid (ie, first call `has_valid_checksum` or `validate_checksum()`). This /// function is typically paired with `has_valid_checksum` when validating against multiple /// checksum algorithms consecutively. /// /// # Panics /// /// May panic if data is not valid. #[inline] pub fn remove_checksum(self) -> CheckedHrpstring<'s> { let end = self.data_part_ascii.len() - Ck::CHECKSUM_LENGTH; CheckedHrpstring { hrp: self.hrp(), ascii: &self.data_part_ascii[..end], hrpstring_length: self.hrpstring_length, } } } /// An HRP string that has been parsed and had the checksum validated. /// /// This type does not treat the first byte of the data part in any special way i.e., as the witness /// version byte. If you are parsing Bitcoin segwit addresses consider using [`SegwitHrpstring`]. /// /// > We first describe the general checksummed base32 format called Bech32 and then /// > define Segregated Witness addresses using it. /// /// This type abstracts over the general checksummed base32 format called Bech32. /// /// # Examples /// /// ``` /// use bech32::{Bech32m, primitives::decode::CheckedHrpstring}; /// /// // Parse a general checksummed bech32 encoded string. /// let s = "abcd14g08d6qejxtdg4y5r3zarvary0c5xw7knqc5r8"; /// let checked = CheckedHrpstring::new::(s) /// .expect("valid bech32 string with a valid checksum according to the bech32m algorithm"); /// /// // Do something with the encoded data. /// let _ = checked.byte_iter(); /// ``` #[derive(Debug)] pub struct CheckedHrpstring<'s> { /// The human-readable part, guaranteed to be lowercase ASCII characters. hrp: Hrp, /// This is ASCII byte values of the parsed string, guaranteed to be valid bech32 characters. /// /// The characters after the '1' separator and the before the checksum. ascii: &'s [u8], /// The length of the parsed hrpstring. hrpstring_length: usize, // Guaranteed to be <= CK::CODE_LENGTH } impl<'s> CheckedHrpstring<'s> { /// Parses and validates an HRP string, without treating the first data character specially. /// /// If you are validating the checksum multiple times consider using [`UncheckedHrpstring`]. /// /// This is equivalent to `UncheckedHrpstring::new().validate_and_remove_checksum::()`. #[inline] pub fn new(s: &'s str) -> Result { let unchecked = UncheckedHrpstring::new(s)?; let checked = unchecked.validate_and_remove_checksum::()?; Ok(checked) } /// Returns the human-readable part. #[inline] pub fn hrp(&self) -> Hrp { self.hrp } /// Returns a partial slice of the data part, as ASCII bytes, everything after the separator '1' /// before the checksum. /// /// The byte values are guaranteed to be valid bech32 characters. /// /// # Examples /// /// ``` /// use bech32::{Bech32, primitives::decode::CheckedHrpstring}; /// /// let addr = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; /// let ascii = "qar0srrr7xfkvy5l643lydnw9re59gtzz"; /// /// let checked = CheckedHrpstring::new::(&addr).unwrap(); /// assert!(checked.data_part_ascii_no_checksum().iter().eq(ascii.as_bytes().iter())) /// ``` #[inline] pub fn data_part_ascii_no_checksum(&self) -> &'s [u8] { self.ascii } /// Attempts to remove the first byte of the data part, treating it as a witness version. /// /// If [`Self::witness_version`] succeeds this function removes the first character (witness /// version byte) from the internal ASCII data part buffer. Future calls to /// [`Self::data_part_ascii_no_checksum`] will no longer include it. /// /// # Examples /// /// ``` /// use bech32::{primitives::decode::CheckedHrpstring, Bech32, Fe32}; /// /// let addr = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; /// let ascii = "ar0srrr7xfkvy5l643lydnw9re59gtzz"; /// /// let mut checked = CheckedHrpstring::new::(&addr).unwrap(); /// let witness_version = checked.remove_witness_version().unwrap(); /// assert_eq!(witness_version, Fe32::Q); /// assert!(checked.data_part_ascii_no_checksum().iter().eq(ascii.as_bytes().iter())) /// ``` #[inline] pub fn remove_witness_version(&mut self) -> Option { self.witness_version().map(|witver| { self.ascii = &self.ascii[1..]; // Remove the witness version byte. witver }) } /// Returns the segwit witness version if there is one. /// /// Attempts to convert the first character of the data part to a witness version. If this /// succeeds, and it is a valid version (0..16 inclusive) we return it, otherwise `None`. /// /// Future calls to [`Self::data_part_ascii_no_checksum`] will still include the witness /// version, use [`Self::remove_witness_version`] to remove it. /// /// This function makes no guarantees on the validity of the checksum. /// /// # Examples /// /// ``` /// use bech32::{primitives::decode::CheckedHrpstring, Bech32, Fe32}; /// /// let addr = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; /// /// let checked = CheckedHrpstring::new::(&addr).unwrap(); /// assert_eq!(checked.witness_version(), Some(Fe32::Q)); /// ``` #[inline] pub fn witness_version(&self) -> Option { let data_part = self.data_part_ascii_no_checksum(); if data_part.is_empty() { return None; } // unwrap ok because we know we gave valid bech32 characters. let witness_version = Fe32::from_char(data_part[0].into()).unwrap(); if witness_version.to_u8() > 16 { return None; } Some(witness_version) } /// Returns an iterator that yields the data part of the parsed bech32 encoded string as [`Fe32`]s. /// /// Converts the ASCII bytes representing field elements to the respective field elements. #[inline] pub fn fe32_iter>(&self) -> AsciiToFe32Iter { AsciiToFe32Iter { iter: self.ascii.iter().copied() } } /// Returns an iterator that yields the data part of the parsed bech32 encoded string. /// /// Converts the ASCII bytes representing field elements to the respective field elements, then /// converts the stream of field elements to a stream of bytes. #[inline] pub fn byte_iter(&self) -> ByteIter { ByteIter { iter: AsciiToFe32Iter { iter: self.ascii.iter().copied() }.fes_to_bytes() } } /// Converts this type to a [`SegwitHrpstring`] after validating the witness and HRP. #[inline] pub fn validate_segwit(mut self) -> Result, SegwitHrpstringError> { if self.ascii.is_empty() { return Err(SegwitHrpstringError::NoData); } if self.hrpstring_length > segwit::MAX_STRING_LENGTH { return Err(SegwitHrpstringError::TooLong(self.hrpstring_length)); } // Unwrap ok since check_characters checked the bech32-ness of this char. let witness_version = Fe32::from_char(self.ascii[0].into()).unwrap(); self.ascii = &self.ascii[1..]; // Remove the witness version byte. self.validate_segwit_padding()?; self.validate_witness_program_length(witness_version)?; Ok(SegwitHrpstring { hrp: self.hrp(), witness_version, ascii: self.ascii }) } /// Validates the segwit padding rules. /// /// Must be called after the witness version byte is removed from the data part. /// /// From BIP-173: /// > Re-arrange those bits into groups of 8 bits. Any incomplete group at the /// > end MUST be 4 bits or less, MUST be all zeroes, and is discarded. #[inline] pub fn validate_segwit_padding(&self) -> Result<(), PaddingError> { if self.ascii.is_empty() { return Ok(()); // Empty data implies correct padding. } let fe_iter = AsciiToFe32Iter { iter: self.ascii.iter().copied() }; let padding_len = fe_iter.len() * 5 % 8; if padding_len > 4 { return Err(PaddingError::TooMuch)?; } let last_fe = fe_iter.last().expect("checked above"); let last_byte = last_fe.0; let padding_contains_non_zero_bits = match padding_len { 0 => false, 1 => last_byte & 0b0001 > 0, 2 => last_byte & 0b0011 > 0, 3 => last_byte & 0b0111 > 0, 4 => last_byte & 0b1111 > 0, _ => unreachable!("checked above"), }; if padding_contains_non_zero_bits { Err(PaddingError::NonZero) } else { Ok(()) } } /// Validates the segwit witness length rules. /// /// Must be called after the witness version byte is removed from the data part. #[inline] pub fn validate_witness_program_length( &self, witness_version: Fe32, ) -> Result<(), WitnessLengthError> { segwit::validate_witness_program_length(self.byte_iter().len(), witness_version) } } /// An valid length HRP string that has been parsed, had the checksum validated, had the witness /// version validated, had the witness data length checked, and the had witness version and checksum /// removed. /// /// # Examples /// /// ``` /// use bech32::primitives::decode::SegwitHrpstring; /// /// // Parse a segwit V0 address. /// let address = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; /// let segwit = SegwitHrpstring::new(address).expect("valid segwit address"); /// /// // Do something with the encoded data. /// let _ = segwit.byte_iter(); /// ``` #[derive(Debug)] pub struct SegwitHrpstring<'s> { /// The human-readable part, valid for segwit addresses. hrp: Hrp, /// The first byte of the parsed data part. witness_version: Fe32, /// This is ASCII byte values of the parsed string, guaranteed to be valid bech32 characters. /// /// The characters after the witness version and before the checksum. ascii: &'s [u8], } impl<'s> SegwitHrpstring<'s> { /// Parses an HRP string, treating the first data character as a witness version. /// /// The version byte does not appear in the extracted binary data, but is covered by the /// checksum. It can be accessed with [`Self::witness_version`]. /// /// NOTE: We do not enforce any restrictions on the HRP, use [`SegwitHrpstring::has_valid_hrp`] /// to get strict BIP conformance (also [`Hrp::is_valid_on_mainnet`] and friends). #[inline] pub fn new(s: &'s str) -> Result { let len = s.len(); if len > segwit::MAX_STRING_LENGTH { return Err(SegwitHrpstringError::TooLong(len)); } let unchecked = UncheckedHrpstring::new(s)?; let data_part = unchecked.data_part_ascii(); if data_part.is_empty() { return Err(SegwitHrpstringError::NoData); } // Unwrap ok since check_characters (in `Self::new`) checked the bech32-ness of this char. let witness_version = Fe32::from_char(data_part[0].into()).unwrap(); if witness_version.to_u8() > 16 { return Err(SegwitHrpstringError::InvalidWitnessVersion(witness_version)); } let checked: CheckedHrpstring<'s> = match witness_version { VERSION_0 => unchecked.validate_and_remove_checksum::()?, _ => unchecked.validate_and_remove_checksum::()?, }; checked.validate_segwit() } /// Parses an HRP string, treating the first data character as a witness version. /// /// ## WARNING /// /// You almost certainly do not want to use this function. /// /// It is provided for backwards comparability to parse addresses that have an non-zero witness /// version because [BIP-173] explicitly allows using the bech32 checksum with any witness /// version however [BIP-350] specifies all witness version > 0 now MUST use bech32m. /// /// [BIP-173]: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki /// [BIP-350]: https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki #[inline] pub fn new_bech32(s: &'s str) -> Result { let unchecked = UncheckedHrpstring::new(s)?; let data_part = unchecked.data_part_ascii(); // Unwrap ok since check_characters (in `Self::new`) checked the bech32-ness of this char. let witness_version = Fe32::from_char(data_part[0].into()).unwrap(); if witness_version.to_u8() > 16 { return Err(SegwitHrpstringError::InvalidWitnessVersion(witness_version)); } let checked = unchecked.validate_and_remove_checksum::()?; checked.validate_segwit() } /// Returns `true` if the HRP is "bc" or "tb". /// /// BIP-173 requires that the HRP is "bc" or "tb" but software in the Bitcoin ecosystem uses /// other HRPs, specifically "bcrt" for regtest addresses. We provide this function in order to /// be BIP-173 compliant but their are no restrictions on the HRP of [`SegwitHrpstring`]. #[inline] pub fn has_valid_hrp(&self) -> bool { self.hrp().is_valid_segwit() } /// Returns the human-readable part. #[inline] pub fn hrp(&self) -> Hrp { self.hrp } /// Returns the witness version. #[inline] pub fn witness_version(&self) -> Fe32 { self.witness_version } /// Returns a partial slice of the data part, as ASCII bytes, everything after the witness /// version and before the checksum. /// /// The byte values are guaranteed to be valid bech32 characters. /// /// # Examples /// /// ``` /// use bech32::{Bech32, primitives::decode::SegwitHrpstring}; /// /// let addr = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; /// let ascii = "ar0srrr7xfkvy5l643lydnw9re59gtzz"; /// /// let segwit = SegwitHrpstring::new(&addr).unwrap(); /// assert!(segwit.data_part_ascii_no_witver_no_checksum().iter().eq(ascii.as_bytes().iter())) /// ``` #[inline] pub fn data_part_ascii_no_witver_no_checksum(&self) -> &'s [u8] { self.ascii } /// Returns an iterator that yields the data part, excluding the witness version, of the parsed /// bech32 encoded string. /// /// Converts the ASCII bytes representing field elements to the respective field elements, then /// converts the stream of field elements to a stream of bytes. /// /// Use `self.witness_version()` to get the witness version. #[inline] pub fn byte_iter(&self) -> ByteIter { ByteIter { iter: AsciiToFe32Iter { iter: self.ascii.iter().copied() }.fes_to_bytes() } } } /// Checks whether a given HRP string has data part characters in the bech32 alphabet (incl. /// checksum characters), and that the whole string has consistent casing (hrp and data part). /// /// # Returns /// /// The byte-index into the string where the '1' separator occurs, or an error if it does not. fn check_characters(s: &str) -> Result { use CharError::*; let mut has_upper = false; let mut has_lower = false; let mut req_bech32 = true; let mut sep_pos = None; for (n, ch) in s.char_indices().rev() { if ch == SEP && sep_pos.is_none() { req_bech32 = false; sep_pos = Some(n); } if req_bech32 { Fe32::from_char(ch).map_err(|_| InvalidChar(ch))?; } if ch.is_ascii_uppercase() { has_upper = true; } else if ch.is_ascii_lowercase() { has_lower = true; } } if has_upper && has_lower { Err(MixedCase) } else if let Some(pos) = sep_pos { Ok(pos) } else { Err(MissingSeparator) } } /// An iterator over a parsed HRP string data as bytes. pub struct ByteIter<'s> { iter: FesToBytes>, } impl<'s> Iterator for ByteIter<'s> { type Item = u8; #[inline] fn next(&mut self) -> Option { self.iter.next() } #[inline] fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } } impl<'s> ExactSizeIterator for ByteIter<'s> { #[inline] fn len(&self) -> usize { self.iter.len() } } /// An iterator over a parsed HRP string data as field elements. pub struct Fe32Iter<'s> { iter: AsciiToFe32Iter<'s>, } impl<'s> Iterator for Fe32Iter<'s> { type Item = Fe32; #[inline] fn next(&mut self) -> Option { self.iter.next() } #[inline] fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } } /// Iterator adaptor that maps an iterator of valid bech32 character ASCII bytes to an /// iterator of field elements. /// /// # Panics /// /// If any `u8` in the input iterator is out of range for an [`Fe32`]. Should only be used on data /// that has already been checked for validity (eg, by using `check_characters`). pub struct AsciiToFe32Iter<'s> { iter: iter::Copied>, } impl<'s> Iterator for AsciiToFe32Iter<'s> { type Item = Fe32; #[inline] fn next(&mut self) -> Option { self.iter.next().map(Fe32::from_char_unchecked) } #[inline] fn size_hint(&self) -> (usize, Option) { // Each ASCII character is an fe32 so iterators are the same size. self.iter.size_hint() } } impl<'s> ExactSizeIterator for AsciiToFe32Iter<'s> { #[inline] fn len(&self) -> usize { self.iter.len() } } /// An error while constructing a [`SegwitHrpstring`] type. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum SegwitHrpstringError { /// Error while parsing the encoded address string. Unchecked(UncheckedHrpstringError), /// No data found after removing the checksum. NoData, /// String exceeds maximum allowed length. TooLong(usize), /// Invalid witness version (must be 0-16 inclusive). InvalidWitnessVersion(Fe32), /// Invalid padding on the witness data. Padding(PaddingError), /// Invalid witness length. WitnessLength(WitnessLengthError), /// Invalid checksum. Checksum(ChecksumError), } #[rustfmt::skip] impl fmt::Display for SegwitHrpstringError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use SegwitHrpstringError::*; match *self { Unchecked(ref e) => write_err!(f, "parsing unchecked hrpstring failed"; e), NoData => write!(f, "no data found after removing the checksum"), TooLong(len) => write!(f, "encoded length {} exceeds spec limit {} chars", len, segwit::MAX_STRING_LENGTH), InvalidWitnessVersion(fe) => write!(f, "invalid segwit witness version: {} (bech32 character: '{}')", fe.to_u8(), fe), Padding(ref e) => write_err!(f, "invalid padding on the witness data"; e), WitnessLength(ref e) => write_err!(f, "invalid witness length"; e), Checksum(ref e) => write_err!(f, "invalid checksum"; e), } } } #[cfg(feature = "std")] impl std::error::Error for SegwitHrpstringError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use SegwitHrpstringError::*; match *self { Unchecked(ref e) => Some(e), Padding(ref e) => Some(e), WitnessLength(ref e) => Some(e), Checksum(ref e) => Some(e), NoData | TooLong(_) | InvalidWitnessVersion(_) => None, } } } impl From for SegwitHrpstringError { #[inline] fn from(e: UncheckedHrpstringError) -> Self { Self::Unchecked(e) } } impl From for SegwitHrpstringError { #[inline] fn from(e: WitnessLengthError) -> Self { Self::WitnessLength(e) } } impl From for SegwitHrpstringError { #[inline] fn from(e: PaddingError) -> Self { Self::Padding(e) } } impl From for SegwitHrpstringError { #[inline] fn from(e: ChecksumError) -> Self { Self::Checksum(e) } } /// An error while constructing a [`CheckedHrpstring`] type. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum CheckedHrpstringError { /// Error while parsing the encoded address string. Parse(UncheckedHrpstringError), /// Invalid checksum. Checksum(ChecksumError), } impl fmt::Display for CheckedHrpstringError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use CheckedHrpstringError::*; match *self { Parse(ref e) => write_err!(f, "parse failed"; e), Checksum(ref e) => write_err!(f, "invalid checksum"; e), } } } #[cfg(feature = "std")] impl std::error::Error for CheckedHrpstringError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use CheckedHrpstringError::*; match *self { Parse(ref e) => Some(e), Checksum(ref e) => Some(e), } } } impl From for CheckedHrpstringError { #[inline] fn from(e: UncheckedHrpstringError) -> Self { Self::Parse(e) } } impl From for CheckedHrpstringError { #[inline] fn from(e: ChecksumError) -> Self { Self::Checksum(e) } } /// Errors when parsing a bech32 encoded string. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum UncheckedHrpstringError { /// An error with the characters of the input string. Char(CharError), /// The human-readable part is invalid. Hrp(hrp::Error), } impl fmt::Display for UncheckedHrpstringError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use UncheckedHrpstringError::*; match *self { Char(ref e) => write_err!(f, "character error"; e), Hrp(ref e) => write_err!(f, "invalid human-readable part"; e), } } } #[cfg(feature = "std")] impl std::error::Error for UncheckedHrpstringError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use UncheckedHrpstringError::*; match *self { Char(ref e) => Some(e), Hrp(ref e) => Some(e), } } } impl From for UncheckedHrpstringError { #[inline] fn from(e: CharError) -> Self { Self::Char(e) } } impl From for UncheckedHrpstringError { #[inline] fn from(e: hrp::Error) -> Self { Self::Hrp(e) } } /// Character errors in a bech32 encoded string. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum CharError { /// String does not contain the separator character. MissingSeparator, /// No characters after the separator. NothingAfterSeparator, /// Some part of the string contains an invalid character. InvalidChar(char), /// The whole string must be of one case. MixedCase, } impl fmt::Display for CharError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use CharError::*; match *self { MissingSeparator => write!(f, "missing human-readable separator, \"{}\"", SEP), NothingAfterSeparator => write!(f, "invalid data - no characters after the separator"), InvalidChar(n) => write!(f, "invalid character (code={})", n), MixedCase => write!(f, "mixed-case strings not allowed"), } } } #[cfg(feature = "std")] impl std::error::Error for CharError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use CharError::*; match *self { MissingSeparator | NothingAfterSeparator | InvalidChar(_) | MixedCase => None, } } } /// Errors in the checksum of a bech32 encoded string. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum ChecksumError { /// String exceeds maximum allowed length. CodeLength(CodeLengthError), /// The checksum residue is not valid for the data. InvalidResidue, /// The checksummed string is not a valid length. InvalidLength, } impl fmt::Display for ChecksumError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use ChecksumError::*; match *self { CodeLength(ref e) => write_err!(f, "string exceeds maximum allowed length"; e), InvalidResidue => write!(f, "the checksum residue is not valid for the data"), InvalidLength => write!(f, "the checksummed string is not a valid length"), } } } #[cfg(feature = "std")] impl std::error::Error for ChecksumError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use ChecksumError::*; match *self { CodeLength(ref e) => Some(e), InvalidResidue | InvalidLength => None, } } } /// Encoding HRP and data into a bech32 string exceeds the checksum code length. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub struct CodeLengthError { /// The length of the string if encoded with checksum. pub encoded_length: usize, /// The checksum specific code length. pub code_length: usize, } impl fmt::Display for CodeLengthError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "encoded length {} exceeds maximum (code length) {}", self.encoded_length, self.code_length ) } } #[cfg(feature = "std")] impl std::error::Error for CodeLengthError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None } } /// Encoding HRP, witver, and program into an address exceeds maximum allowed. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub struct SegwitCodeLengthError(pub usize); impl fmt::Display for SegwitCodeLengthError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "encoded length {} exceeds maximum (code length) {}", self.0, segwit::MAX_STRING_LENGTH ) } } #[cfg(feature = "std")] impl std::error::Error for SegwitCodeLengthError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None } } impl From for SegwitCodeLengthError { fn from(e: CodeLengthError) -> Self { Self(e.encoded_length) } } /// Error validating the padding bits on the witness data. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum PaddingError { /// The data payload has too many bits of padding. TooMuch, /// The data payload is padded with non-zero bits. NonZero, } impl fmt::Display for PaddingError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use PaddingError::*; match *self { TooMuch => write!(f, "the data payload has too many bits of padding"), NonZero => write!(f, "the data payload is padded with non-zero bits"), } } } #[cfg(feature = "std")] impl std::error::Error for PaddingError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use PaddingError::*; match *self { TooMuch | NonZero => None, } } } #[cfg(test)] mod tests { use super::*; #[test] fn bip_173_invalid_parsing_fails() { use UncheckedHrpstringError::*; let invalid: Vec<(&str, UncheckedHrpstringError)> = vec!( ("\u{20}1nwldj5", // TODO: Rust >= 1.59.0 use Hrp(hrp::Error::InvalidAsciiByte('\u{20}'.try_into().unwrap()))), Hrp(hrp::Error::InvalidAsciiByte(32))), ("\u{7F}1axkwrx", Hrp(hrp::Error::InvalidAsciiByte(127))), ("\u{80}1eym55h", Hrp(hrp::Error::NonAsciiChar('\u{80}'))), ("an84characterslonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11d6pts4", Hrp(hrp::Error::TooLong(84))), ("pzry9x0s0muk", Char(CharError::MissingSeparator)), ("1pzry9x0s0muk", Hrp(hrp::Error::Empty)), ("x1b4n0q5v", Char(CharError::InvalidChar('b'))), // "li1dgmt3" in separate test because error is a checksum error. ("de1lg7wt\u{ff}", Char(CharError::InvalidChar('\u{ff}'))), // "A1G7SGD8" in separate test because error is a checksum error. ("10a06t8", Hrp(hrp::Error::Empty)), ("1qzzfhee", Hrp(hrp::Error::Empty)), ); for (s, want) in invalid { let got = UncheckedHrpstring::new(s).unwrap_err(); assert_eq!(got, want); } } #[test] fn bip_173_invalid_parsing_fails_invalid_checksum() { use ChecksumError::*; let err = UncheckedHrpstring::new("li1dgmt3") .expect("string parses correctly") .validate_checksum::() .unwrap_err(); assert_eq!(err, InvalidLength); let err = UncheckedHrpstring::new("A1G7SGD8") .expect("string parses correctly") .validate_checksum::() .unwrap_err(); assert_eq!(err, InvalidResidue); } #[test] fn bip_350_invalid_parsing_fails() { use UncheckedHrpstringError::*; let invalid: Vec<(&str, UncheckedHrpstringError)> = vec!( ("\u{20}1xj0phk", // TODO: Rust >= 1.59.0 use Hrp(hrp::Error::InvalidAsciiByte('\u{20}'.try_into().unwrap()))), Hrp(hrp::Error::InvalidAsciiByte(32))), ("\u{7F}1g6xzxy", Hrp(hrp::Error::InvalidAsciiByte(127))), ("\u{80}1g6xzxy", Hrp(hrp::Error::NonAsciiChar('\u{80}'))), ("an84characterslonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1569pvx", Hrp(hrp::Error::TooLong(84))), ("qyrz8wqd2c9m", Char(CharError::MissingSeparator)), ("1qyrz8wqd2c9m", Hrp(hrp::Error::Empty)), ("y1b0jsk6g", Char(CharError::InvalidChar('b'))), ("lt1igcx5c0", Char(CharError::InvalidChar('i'))), // "in1muywd" in separate test because error is a checksum error. ("mm1crxm3i", Char(CharError::InvalidChar('i'))), ("au1s5cgom", Char(CharError::InvalidChar('o'))), // "M1VUXWEZ" in separate test because error is a checksum error. ("16plkw9", Hrp(hrp::Error::Empty)), ("1p2gdwpf", Hrp(hrp::Error::Empty)), ); for (s, want) in invalid { let got = UncheckedHrpstring::new(s).unwrap_err(); assert_eq!(got, want); } } #[test] fn bip_350_invalid_because_of_invalid_checksum() { use ChecksumError::*; // Note the "bc1p2" test case is not from the bip test vectors. let invalid: Vec<&str> = vec!["in1muywd", "bc1p2"]; for s in invalid { let err = UncheckedHrpstring::new(s).unwrap().validate_checksum::().unwrap_err(); assert_eq!(err, InvalidLength); } let err = UncheckedHrpstring::new("M1VUXWEZ") .unwrap() .validate_checksum::() .unwrap_err(); assert_eq!(err, InvalidResidue); } #[test] fn check_hrp_uppercase_returns_lower() { let addr = "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4"; let unchecked = UncheckedHrpstring::new(addr).expect("failed to parse address"); assert_eq!(unchecked.hrp(), Hrp::parse_unchecked("bc")); } #[test] #[cfg(feature = "alloc")] fn check_hrp_max_length() { let hrps = "an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio"; let hrp = Hrp::parse_unchecked(hrps); let s = crate::encode::(hrp, &[]).expect("failed to encode empty buffer"); let unchecked = UncheckedHrpstring::new(&s).expect("failed to parse address"); assert_eq!(unchecked.hrp(), hrp); } #[test] fn mainnet_valid_addresses() { let addresses = vec![ "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq", "23451QAR0SRRR7XFKVY5L643LYDNW9RE59GTZZLKULZK", ]; for valid in addresses { assert!(CheckedHrpstring::new::(valid).is_ok()) } } macro_rules! check_invalid_segwit_addresses { ($($test_name:ident, $reason:literal, $address:literal);* $(;)?) => { $( #[test] fn $test_name() { let res = SegwitHrpstring::new($address); if res.is_ok() { panic!("{} sting should not be valid: {}", $address, $reason); } } )* } } check_invalid_segwit_addresses! { invalid_segwit_address_0, "missing hrp", "1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; invalid_segwit_address_1, "missing data-checksum", "91111"; invalid_segwit_address_2, "invalid witness version", "bc14r0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; invalid_segwit_address_3, "invalid checksum length", "bc1q5mdq"; invalid_segwit_address_4, "missing data", "bc1qwf5mdq"; invalid_segwit_address_5, "invalid program length", "bc14r0srrr7xfkvy5l643lydnw9rewf5mdq"; } } bech32-0.11.0/src/primitives/encode.rs000064400000000000000000000314221046102023000155400ustar 00000000000000// SPDX-License-Identifier: MIT //! Bech32 address encoding. //! //! This module provides types and iterators that can be used to encode data as a bech32 address in //! a variety of ways without any allocations, generating, verifying, and appending checksums, //! prepending HRP strings etc. //! //! In general, directly using these adaptors is not very ergonomic, and users are recommended to //! instead use the crate level API. //! //! WARNING: This module does not enforce the maximum length of an encoded bech32 string (90 chars). //! //! # Examples //! //! ``` //! use bech32::{Bech32, ByteIterExt, Fe32IterExt, Fe32, Hrp}; //! //! let witness_prog = [ //! 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, //! 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, //! 0xf1, 0x43, 0x3b, 0xd6, //! ]; //! //! // Get a stream of characters representing the bech32 encoded //! // address using "bc" for the human-readable part. //! let hrp = Hrp::parse("bc").expect("bc is valid hrp string"); //! let chars = witness_prog //! .iter() //! .copied() //! .bytes_to_fes() //! .with_checksum::(&hrp) //! .with_witness_version(Fe32::Q) // Optionally add witness version. //! .chars(); //! //! #[cfg(feature = "alloc")] //! { //! let addr = chars.collect::(); //! assert_eq!(addr.to_uppercase(), "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4"); //! } //! ``` use core::iter::Iterator; use core::marker::PhantomData; use crate::primitives::checksum::HrpFe32Iter; use crate::primitives::hrp::{self, Hrp}; use crate::primitives::iter::Checksummed; use crate::{Checksum, Fe32}; /// The `Encoder` builds iterators that can be used to encode field elements into a bech32 address. /// /// Construct the encoder by calling [`Fe32IterExt::with_checksum`] on an iterator of field /// elements, optionally prefix the data with a witness version, and then get the encoding as either /// a stream of characters ([`Encoder::chars`]) or a stream of field elements ([`Encoder::fes`]). /// /// # Examples /// /// ``` /// use bech32::{Bech32, ByteIterExt, Fe32IterExt, Hrp}; /// /// let data = [0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4]; /// /// let hrp = Hrp::parse("abc").expect("bc is valid hrp string"); /// let chars = data /// .iter() /// .copied() /// .bytes_to_fes() /// .with_checksum::(&hrp) /// .chars(); /// ``` /// [`Fe32IterExt::with_checksum`]: crate::Fe32IterExt::with_checksum #[derive(Clone, PartialEq, Eq)] pub struct Encoder<'hrp, I, Ck> where I: Iterator, Ck: Checksum, { /// The field elements to encode. data: I, /// The human-readable part used at the front of the address encoding. hrp: &'hrp Hrp, /// The witness version, if present. witness_version: Option, /// Checksum marker. marker: PhantomData, } impl<'hrp, I, Ck> Encoder<'hrp, I, Ck> where I: Iterator, Ck: Checksum, { /// Constructs a new bech32 encoder. #[inline] pub fn new(data: I, hrp: &'hrp Hrp) -> Self { Self { data, hrp, witness_version: None, marker: PhantomData:: } } /// Adds `witness_version` to the encoder (as first byte of encoded data). /// /// Note, caller to guarantee that witness version is within valid range (0-16). #[inline] pub fn with_witness_version(mut self, witness_version: Fe32) -> Self { self.witness_version = Some(witness_version); self } /// Returns an iterator that yields the bech32 encoded address as field ASCII characters. #[inline] pub fn chars(self) -> CharIter<'hrp, I, Ck> { let witver_iter = WitnessVersionIter::new(self.witness_version, self.data); CharIter::new(self.hrp, witver_iter) } /// Returns an iterator that yields the bech32 encoded address as field ASCII characters, as /// byte values. #[inline] pub fn bytes(self) -> ByteIter<'hrp, I, Ck> { let char_iter = self.chars(); ByteIter::new(char_iter) } /// Returns an iterator that yields the field elements that go into the checksum, as well as the checksum at the end. /// /// Each field element yielded has been input into the checksum algorithm (including the HRP as it is fed into the algorithm). #[inline] pub fn fes(self) -> Fe32Iter<'hrp, I, Ck> { let witver_iter = WitnessVersionIter::new(self.witness_version, self.data); Fe32Iter::new(self.hrp, witver_iter) } } /// Iterator adaptor that just prepends a single character to a field element stream. /// /// More ergonomic to use than `std::iter::once(fe).chain(iter)`. pub struct WitnessVersionIter where I: Iterator, { witness_version: Option, iter: I, } impl WitnessVersionIter where I: Iterator, { /// Creates a [`WitnessVersionIter`]. #[inline] pub fn new(witness_version: Option, iter: I) -> Self { Self { witness_version, iter } } } impl Iterator for WitnessVersionIter where I: Iterator, { type Item = Fe32; #[inline] fn next(&mut self) -> Option { self.witness_version.take().or_else(|| self.iter.next()) } #[inline] fn size_hint(&self) -> (usize, Option) { let (min, max) = self.iter.size_hint(); match self.witness_version { Some(_) => (min + 1, max.map(|max| max + 1)), None => (min, max), } } } /// Iterator adaptor which takes a stream of field elements, converts it to characters prefixed by /// an HRP (and separator), and suffixed by the checksum i.e., converts the data in a stream of /// field elements into stream of characters representing the encoded bech32 string. pub struct CharIter<'hrp, I, Ck> where I: Iterator, Ck: Checksum, { /// `None` once the hrp has been yielded. hrp_iter: Option>, /// Iterator over field elements made up of the optional witness version, the data to be /// encoded, plus the checksum. checksummed: Checksummed, Ck>, } impl<'hrp, I, Ck> CharIter<'hrp, I, Ck> where I: Iterator, Ck: Checksum, { /// Adapts the `Fe32Iter` iterator to yield characters representing the bech32 encoding. #[inline] pub fn new(hrp: &'hrp Hrp, data: WitnessVersionIter) -> Self { let checksummed = Checksummed::new_hrp(*hrp, data); Self { hrp_iter: Some(hrp.lowercase_char_iter()), checksummed } } } impl<'a, I, Ck> Iterator for CharIter<'a, I, Ck> where I: Iterator, Ck: Checksum, { type Item = char; #[inline] fn next(&mut self) -> Option { if let Some(ref mut hrp_iter) = self.hrp_iter { match hrp_iter.next() { Some(c) => return Some(c), None => { self.hrp_iter = None; return Some('1'); } } } self.checksummed.next().map(|fe| fe.to_char()) } #[inline] fn size_hint(&self) -> (usize, Option) { match &self.hrp_iter { // We have yielded the hrp and separator already. None => self.checksummed.size_hint(), // Yet to finish yielding the hrp (and the separator). Some(hrp_iter) => { let (hrp_min, hrp_max) = hrp_iter.size_hint(); let (chk_min, chk_max) = self.checksummed.size_hint(); let min = hrp_min + 1 + chk_min; // +1 for the separator. // To provide a max boundary we need to have gotten a value from the hrp iter as well as the // checksummed iter, otherwise we have to return None since we cannot know the maximum. let max = match (hrp_max, chk_max) { (Some(hrp_max), Some(chk_max)) => Some(hrp_max + 1 + chk_max), (_, _) => None, }; (min, max) } } } } /// Iterator adaptor which takes a stream of ASCII field elements (an encoded string) and yields a stream of bytes. /// /// This is equivalent to using the `CharsIter` and the casting each character to a byte. Doing /// so is technically sound because we only yield ASCII characters but it makes for ugly code so /// we provide this iterator also. pub struct ByteIter<'hrp, I, Ck> where I: Iterator, Ck: Checksum, { char_iter: CharIter<'hrp, I, Ck>, } impl<'hrp, I, Ck> ByteIter<'hrp, I, Ck> where I: Iterator, Ck: Checksum, { /// Adapts the `CharIter` iterator to yield bytes representing the bech32 encoding as ASCII bytes. #[inline] pub fn new(char_iter: CharIter<'hrp, I, Ck>) -> Self { Self { char_iter } } } impl<'a, I, Ck> Iterator for ByteIter<'a, I, Ck> where I: Iterator, Ck: Checksum, { type Item = u8; #[inline] fn next(&mut self) -> Option { self.char_iter.next().map(|c| c as u8) } #[inline] fn size_hint(&self) -> (usize, Option) { self.char_iter.size_hint() } } /// Iterator adaptor for a checksummed iterator that inputs the HRP into the checksum algorithm /// before yielding the HRP as field elements followed by the data then checksum. pub struct Fe32Iter<'hrp, I, Ck> where I: Iterator, Ck: Checksum, { /// `None` once the hrp field elements have been yielded. hrp_iter: Option>, /// Iterator over field elements made up of the optional witness version, the data to be /// encoded, plus the checksum. checksummed: Checksummed, Ck>, } impl<'hrp, I, Ck> Fe32Iter<'hrp, I, Ck> where I: Iterator, Ck: Checksum, { /// Creates a [`Fe32Iter`] which yields all the field elements which go into the checksum algorithm. #[inline] pub fn new(hrp: &'hrp Hrp, data: WitnessVersionIter) -> Self { let hrp_iter = HrpFe32Iter::new(hrp); let checksummed = Checksummed::new_hrp(*hrp, data); Self { hrp_iter: Some(hrp_iter), checksummed } } } impl<'hrp, I, Ck> Iterator for Fe32Iter<'hrp, I, Ck> where I: Iterator, Ck: Checksum, { type Item = Fe32; #[inline] fn next(&mut self) -> Option { if let Some(ref mut hrp_iter) = &mut self.hrp_iter { match hrp_iter.next() { Some(fe) => return Some(fe), None => self.hrp_iter = None, } } self.checksummed.next() } #[inline] fn size_hint(&self) -> (usize, Option) { let hrp = match &self.hrp_iter { Some(hrp_iter) => hrp_iter.size_hint(), None => (0, Some(0)), }; let data = self.checksummed.size_hint(); let min = hrp.0 + data.0; let max = hrp.1.zip(data.1).map(|(hrp, data)| hrp + data); (min, max) } } #[cfg(test)] mod tests { use crate::{Bech32, ByteIterExt, Fe32, Fe32IterExt, Hrp}; // Tests below using this data, are based on the test vector (from BIP-173): // BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4: 0014751e76e8199196d454941c45d1b3a323f1433bd6 #[rustfmt::skip] const DATA: [u8; 20] = [ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6, ]; #[test] fn hrpstring_iter() { let iter = DATA.iter().copied().bytes_to_fes(); let hrp = Hrp::parse_unchecked("bc"); let iter = iter.with_checksum::(&hrp).with_witness_version(Fe32::Q).chars(); assert!(iter.eq("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4".chars())); } #[test] #[cfg(feature = "alloc")] fn hrpstring_iter_collect() { let iter = DATA.iter().copied().bytes_to_fes(); let hrp = Hrp::parse_unchecked("bc"); let iter = iter.with_checksum::(&hrp).with_witness_version(Fe32::Q).chars(); let encoded = iter.collect::(); assert_eq!(encoded, "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"); } #[test] fn hrpstring_iter_size_hint() { let char_len = "w508d6qejxtdg4y5r3zarvary0c5xw7k".len(); let iter = DATA.iter().copied().bytes_to_fes(); let hrp = Hrp::parse_unchecked("bc"); let iter = iter.with_checksum::(&hrp).with_witness_version(Fe32::Q).chars(); let checksummed_len = 2 + 1 + 1 + char_len + 6; // bc + SEP + Q + chars + checksum assert_eq!(iter.size_hint().0, checksummed_len); } #[test] #[cfg(feature = "alloc")] fn hrpstring_iter_bytes() { let hrp = Hrp::parse_unchecked("bc"); let fes = DATA.iter().copied().bytes_to_fes(); let iter = fes.with_checksum::(&hrp).with_witness_version(Fe32::Q); let chars = iter.clone().chars(); let bytes = iter.bytes(); for (c, b) in chars.zip(bytes) { assert_eq!(c as u8, b) } } } bech32-0.11.0/src/primitives/gf32.rs000064400000000000000000000425501046102023000150500ustar 00000000000000// SPDX-License-Identifier: MIT //! GF32 - Galois Field over 32 elements. //! //! Implements GF32 arithmetic, defined and encoded as in [BIP-173] "bech32". //! //! > A finite field is a finite set which is a field; this means that multiplication, addition, //! > subtraction and division (excluding division by zero) are defined and satisfy the rules of //! > arithmetic known as the field axioms. //! //! ref: //! //! [BIP-173]: use core::convert::{Infallible, TryFrom}; use core::{fmt, num, ops}; #[cfg(all(test, mutate))] use mutagen::mutate; use crate::error::write_err; /// Logarithm table of each bech32 element, as a power of alpha = Z. /// /// Includes Q as 0 but this is false; you need to exclude Q because it has no discrete log. If we /// could have a 1-indexed array that would panic on a 0 index that would be better. #[rustfmt::skip] const LOG: [isize; 32] = [ 0, 0, 1, 14, 2, 28, 15, 22, 3, 5, 29, 26, 16, 7, 23, 11, 4, 25, 6, 10, 30, 13, 27, 21, 17, 18, 8, 19, 24, 9, 12, 20, ]; /// Mapping of powers of 2 to the numeric value of the element. #[rustfmt::skip] const LOG_INV: [u8; 31] = [ 1, 2, 4, 8, 16, 9, 18, 13, 26, 29, 19, 15, 30, 21, 3, 6, 12, 24, 25, 27, 31, 23, 7, 14, 28, 17, 11, 22, 5, 10, 20, ]; /// Mapping from numeric value to bech32 character. #[rustfmt::skip] const CHARS_LOWER: [char; 32] = [ 'q', 'p', 'z', 'r', 'y', '9', 'x', '8', // +0 'g', 'f', '2', 't', 'v', 'd', 'w', '0', // +8 's', '3', 'j', 'n', '5', '4', 'k', 'h', // +16 'c', 'e', '6', 'm', 'u', 'a', '7', 'l', // +24 ]; /// Mapping from bech32 character (either case) to numeric value. /// /// E.g., 'z' is CHARS_LOWER[2] and is ASCII value 122 so CHARS_INV[122] == 2 #[rustfmt::skip] const CHARS_INV: [i8; 128] = [ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 10, 17, 21, 20, 26, 30, 7, 5, -1, -1, -1, -1, -1, -1, -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1, 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1, -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1, 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1, ]; /// An element in GF(32), the finite field containing elements `[0,31]` inclusive. #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[repr(transparent)] pub struct Fe32(pub(crate) u8); impl Fe32 { // These are a little gratuitous for a reference implementation, but it makes me happy to do it. /// Numeric value maps to bech32 character: 0 == "q". pub const Q: Fe32 = Fe32(0); /// Numeric value maps to bech32 character: 1 == "p". pub const P: Fe32 = Fe32(1); /// Numeric value maps to bech32 character: 2 == "z". pub const Z: Fe32 = Fe32(2); /// Numeric value maps to bech32 character: 3 == "r". pub const R: Fe32 = Fe32(3); /// Numeric value maps to bech32 character: 4 == "y". pub const Y: Fe32 = Fe32(4); /// Numeric value maps to bech32 character: 5 == "9". pub const _9: Fe32 = Fe32(5); /// Numeric value maps to bech32 character: 6 == "x". pub const X: Fe32 = Fe32(6); /// Numeric value maps to bech32 character: 7 == "8". pub const _8: Fe32 = Fe32(7); /// Numeric value maps to bech32 character: 8 == "g". pub const G: Fe32 = Fe32(8); /// Numeric value maps to bech32 character: 9 == "f". pub const F: Fe32 = Fe32(9); /// Numeric value maps to bech32 character: 10 == "2". pub const _2: Fe32 = Fe32(10); /// Numeric value maps to bech32 character: 11 == "t". pub const T: Fe32 = Fe32(11); /// Numeric value maps to bech32 character: 12 == "v". pub const V: Fe32 = Fe32(12); /// Numeric value maps to bech32 character: 13 == "d". pub const D: Fe32 = Fe32(13); /// Numeric value maps to bech32 character: 14 == "w". pub const W: Fe32 = Fe32(14); /// Numeric value maps to bech32 character: 15 == "0". pub const _0: Fe32 = Fe32(15); /// Numeric value maps to bech32 character: 16 == "s". pub const S: Fe32 = Fe32(16); /// Numeric value maps to bech32 character: 17 == "3". pub const _3: Fe32 = Fe32(17); /// Numeric value maps to bech32 character: 18 == "j". pub const J: Fe32 = Fe32(18); /// Numeric value maps to bech32 character: 19 == "n". pub const N: Fe32 = Fe32(19); /// Numeric value maps to bech32 character: 20 == "5". pub const _5: Fe32 = Fe32(20); /// Numeric value maps to bech32 character: 21 == "4". pub const _4: Fe32 = Fe32(21); /// Numeric value maps to bech32 character: 22 == "k". pub const K: Fe32 = Fe32(22); /// Numeric value maps to bech32 character: 23 == "h". pub const H: Fe32 = Fe32(23); /// Numeric value maps to bech32 character: 24 == "c". pub const C: Fe32 = Fe32(24); /// Numeric value maps to bech32 character: 25 == "e". pub const E: Fe32 = Fe32(25); /// Numeric value maps to bech32 character: 26 == "6". pub const _6: Fe32 = Fe32(26); /// Numeric value maps to bech32 character: 27 == "m". pub const M: Fe32 = Fe32(27); /// Numeric value maps to bech32 character: 28 == "u". pub const U: Fe32 = Fe32(28); /// Numeric value maps to bech32 character: 29 == "a". pub const A: Fe32 = Fe32(29); /// Numeric value maps to bech32 character: 30 == "7". pub const _7: Fe32 = Fe32(30); /// Numeric value maps to bech32 character: 31 == "l". pub const L: Fe32 = Fe32(31); /// Iterator over all field elements, in alphabetical order. #[inline] pub fn iter_alpha() -> impl Iterator { [ Fe32::A, Fe32::C, Fe32::D, Fe32::E, Fe32::F, Fe32::G, Fe32::H, Fe32::J, Fe32::K, Fe32::L, Fe32::M, Fe32::N, Fe32::P, Fe32::Q, Fe32::R, Fe32::S, Fe32::T, Fe32::U, Fe32::V, Fe32::W, Fe32::X, Fe32::Y, Fe32::Z, Fe32::_0, Fe32::_2, Fe32::_3, Fe32::_4, Fe32::_5, Fe32::_6, Fe32::_7, Fe32::_8, Fe32::_9, ] .iter() .copied() } /// Creates a field element from a single bech32 character. /// /// # Errors /// /// If the input char is not part of the bech32 alphabet. #[inline] pub fn from_char(c: char) -> Result { use FromCharError::*; // i8::try_from gets a value in the range 0..=127 since char is unsigned. let byte = i8::try_from(u32::from(c)).map_err(|_| NotAscii(c))?; // Now we have a valid ASCII value cast is safe. let ascii = byte as usize; // We use -1 for any array element that is an invalid char to trigger error from u8::try_from let u5 = u8::try_from(CHARS_INV[ascii]).map_err(|_| Invalid(c))?; Ok(Fe32(u5)) } /// Creates a field element from a single bech32 character. /// /// # Panics /// /// If the input character is not part of the bech32 alphabet. pub fn from_char_unchecked(c: u8) -> Fe32 { Fe32(CHARS_INV[usize::from(c)] as u8) } /// Converts the field element to a lowercase bech32 character. #[inline] pub fn to_char(self) -> char { // Indexing fine as we have self.0 in [0, 32) as an invariant. CHARS_LOWER[usize::from(self.0)] } /// Converts the field element to a 5-bit u8, with bits representing the coefficients /// of the polynomial representation. #[inline] pub fn to_u8(self) -> u8 { self.0 } fn _add(self, other: Fe32) -> Fe32 { Fe32(self.0 ^ other.0) } // Subtraction is the same as addition in a char-2 field. fn _sub(self, other: Fe32) -> Fe32 { self + other } #[cfg_attr(all(test, mutate), mutate)] fn _mul(self, other: Fe32) -> Fe32 { if self.0 == 0 || other.0 == 0 { Fe32(0) } else { let log1 = LOG[self.0 as usize]; let log2 = LOG[other.0 as usize]; Fe32(LOG_INV[((log1 + log2) % 31) as usize]) } } #[cfg_attr(all(test, mutate), mutate)] fn _div(self, other: Fe32) -> Fe32 { if self.0 == 0 { Fe32(0) } else if other.0 == 0 { panic!("Attempt to divide {} by 0 in GF32", self); } else { let log1 = LOG[self.0 as usize]; let log2 = LOG[other.0 as usize]; Fe32(LOG_INV[((31 + log1 - log2) % 31) as usize]) } } } impl fmt::Display for Fe32 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.to_char(), f) } } impl From for u8 { #[inline] fn from(v: Fe32) -> u8 { v.0 } } macro_rules! impl_try_from { ($($ty:ident)+) => { $( impl TryFrom<$ty> for Fe32 { type Error = TryFromError; /// Tries to create an [`Fe32`] type from a signed source number type. /// /// # Errors /// /// Returns an error if `value` is outside of the range of an `Fe32`. #[inline] fn try_from(value: $ty) -> Result { let byte = u8::try_from(value)?; if byte > 31 { Err(TryFromError::InvalidByte(byte))?; } Ok(Fe32(byte)) } } )+ } } impl_try_from!(u8 u16 u32 u64 u128 i8 i16 i32 i64 i128); impl AsRef for Fe32 { #[inline] fn as_ref(&self) -> &u8 { &self.0 } } /// Implements $op for the 2x2 matrix of type by ref to type macro_rules! impl_op_matrix { ($op:ident, $op_fn:ident, $call_fn:ident) => { impl ops::$op for Fe32 { type Output = Fe32; #[inline] fn $op_fn(self, other: Fe32) -> Fe32 { self.$call_fn(other) } } impl ops::$op for &Fe32 { type Output = Fe32; #[inline] fn $op_fn(self, other: Fe32) -> Fe32 { self.$call_fn(other) } } impl ops::$op<&Fe32> for Fe32 { type Output = Fe32; #[inline] fn $op_fn(self, other: &Fe32) -> Fe32 { self.$call_fn(*other) } } impl ops::$op<&Fe32> for &Fe32 { type Output = Fe32; #[inline] fn $op_fn(self, other: &Fe32) -> Fe32 { self.$call_fn(*other) } } }; } impl_op_matrix!(Add, add, _add); impl_op_matrix!(Sub, sub, _sub); impl_op_matrix!(Mul, mul, _mul); impl_op_matrix!(Div, div, _div); impl ops::AddAssign for Fe32 { #[inline] fn add_assign(&mut self, other: Fe32) { *self = *self + other; } } impl ops::SubAssign for Fe32 { #[inline] fn sub_assign(&mut self, other: Fe32) { *self = *self - other; } } impl ops::MulAssign for Fe32 { #[inline] fn mul_assign(&mut self, other: Fe32) { *self = *self * other; } } impl ops::DivAssign for Fe32 { #[inline] fn div_assign(&mut self, other: Fe32) { *self = *self / other; } } /// A galois field error when converting from a character. #[derive(Copy, Clone, PartialEq, Eq, Debug)] #[non_exhaustive] pub enum FromCharError { /// Tried to interpret a character as a GF32 element but it is not an ASCII character. NotAscii(char), /// Tried to interpret a character as a GF32 element but it is not part of the bech32 character set. Invalid(char), } impl fmt::Display for FromCharError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use FromCharError::*; match *self { NotAscii(c) => write!(f, "non-ascii char in field element: {}", c), Invalid(c) => write!(f, "invalid char in field element: {}", c), } } } #[cfg(feature = "std")] impl std::error::Error for FromCharError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use FromCharError::*; match *self { NotAscii(_) | Invalid(_) => None, } } } /// A galois field error when converting from an integer. #[derive(Copy, Clone, PartialEq, Eq, Debug)] #[non_exhaustive] pub enum TryFromError { /// Tried to interpret an integer as a GF32 element but it could not be converted to an u8. NotAByte(num::TryFromIntError), /// Tried to interpret a byte as a GF32 element but its numeric value was outside of [0, 32). InvalidByte(u8), } impl fmt::Display for TryFromError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use TryFromError::*; match *self { NotAByte(ref e) => write_err!(f, "invalid field element"; e), InvalidByte(ref b) => write!(f, "invalid byte in field element: {:#04x}", b), } } } #[cfg(feature = "std")] impl std::error::Error for TryFromError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use TryFromError::*; match *self { NotAByte(ref e) => Some(e), InvalidByte(_) => None, } } } impl From for TryFromError { #[inline] fn from(e: num::TryFromIntError) -> Self { Self::NotAByte(e) } } impl From for TryFromError { #[inline] fn from(i: Infallible) -> Self { match i {} } } #[cfg(test)] mod tests { use super::*; #[test] fn numeric_string() { let s: String = (0..32).map(Fe32).map(Fe32::to_char).collect(); assert_eq!(s, "qpzry9x8gf2tvdw0s3jn54khce6mua7l"); } // For what a "translation wheel" is refer to the codex32 book: // https://github.com/BlockstreamResearch/codex32/blob/master/SSS32.ps #[test] fn translation_wheel() { // 1. Produce the translation wheel by multiplying let logbase = Fe32(20); let mut init = Fe32(1); let mut s = String::new(); for _ in 0..31 { s.push(init.to_char()); init *= logbase; } // Can be verified against the multiplication disk, starting with P and moving clockwise assert_eq!(s, "p529kt3uw8hlmecvxr470na6djfsgyz"); // 2. By dividing let logbase = Fe32(20); let mut init = Fe32(1); let mut s = String::new(); for _ in 0..31 { s.push(init.to_char()); init /= logbase; } // Same deal, but counterclockwise assert_eq!(s, "pzygsfjd6an074rxvcemlh8wu3tk925"); } // For what a "recovery wheel" is refer to the codex32 book: // https://github.com/BlockstreamResearch/codex32/blob/master/SSS32.ps #[test] fn recovery_wheel() { // Remarkably, the recovery wheel can be produced in the same way as the // multiplication wheel, though with a different log base and with every // element added by S. // // We spent quite some time deriving this, but honestly we probably could've // just guessed it if we'd known a priori that a wheel existed. let logbase = Fe32(10); let mut init = Fe32(1); let mut s = String::new(); for _ in 0..31 { s.push((init + Fe32(16)).to_char()); init *= logbase; } // To verify, start with 3 and move clockwise on the Recovery Wheel assert_eq!(s, "36xp78tgk9ldaecjy4mvh0funwr2zq5"); } #[test] fn reverse_charset() { fn get_char_value(c: char) -> i8 { let charset = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"; match charset.find(c.to_ascii_lowercase()) { Some(x) => x as i8, None => -1, } } let expected_rev_charset = (0u8..128).map(|i| get_char_value(i as char)).collect::>(); assert_eq!(&(CHARS_INV[..]), expected_rev_charset.as_slice()); } #[test] fn from_char() { for c in &CHARS_LOWER[..] { assert!(Fe32::from_char(*c).is_ok()) } } #[test] fn from_upper_char() { let lower = Fe32::from_char('q').expect("failed to create fe32 from lowercase ascii char"); let upper = Fe32::from_char('Q').expect("failed to create fe32 from uppercase ascii char"); assert_eq!(lower, upper); } #[test] fn mul_zero() { for c in &CHARS_LOWER[..] { let fe = Fe32::from_char(*c).unwrap(); assert_eq!(fe._mul(Fe32::Q), Fe32::Q) // Fe32::Q == Fe32(0) } } #[test] #[should_panic] fn div_zero() { let _ = Fe32::P / Fe32::Q; // Fe32::Q == Fe32(0) } #[test] fn div_self_zero() { let fe = Fe32::Z; // Value of Z not meaningful to the test. assert_eq!(Fe32::Q / fe, Fe32::Q) // Fe32::Q == Fe32(0) } #[test] fn mul_one() { for c in &CHARS_LOWER[..] { let fe = Fe32::from_char(*c).unwrap(); assert_eq!(fe * Fe32::P, fe) // Fe32::P == Fe32(1) } } } #[cfg(kani)] mod verification { use super::*; #[kani::proof] fn check_char_conversion() { let any: char = kani::any(); // Checks that we can pass any char to from_char and not cause a panic ... I think. if let Ok(fe) = Fe32::from_char(any) { let got = fe.to_char(); let want = any.to_ascii_lowercase(); assert_eq!(got, want); } } } bech32-0.11.0/src/primitives/hrp.rs000064400000000000000000000425661046102023000151070ustar 00000000000000// SPDX-License-Identifier: MIT //! Provides an [`Hrp`] type that represents the human-readable part of a bech32 encoded string. //! //! > The human-readable part, which is intended to convey the type of data, or anything else that //! > is relevant to the reader. This part MUST contain 1 to 83 US-ASCII characters, with each //! > character having a value in the range [33-126]. HRP validity may be further restricted by //! > specific applications. //! //! ref: [BIP-173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#user-content-Bech32) #[cfg(feature = "alloc")] use alloc::string::String; use core::cmp::Ordering; use core::fmt::{self, Write}; use core::iter::FusedIterator; use core::{slice, str}; /// Maximum length of the human-readable part, as defined by BIP-173. const MAX_HRP_LEN: usize = 83; // Defines HRP constants for the different bitcoin networks. // You can also access these at `crate::hrp::BC` etc. #[rustfmt::skip] macro_rules! define_hrp_const { ( #[$doc:meta] pub const $name:ident $size:literal $v:expr; ) => { #[$doc] pub const $name: Hrp = Hrp { buf: [ $v[0], $v[1], $v[2], $v[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], size: $size }; }; } define_hrp_const! { /// The human-readable part used by the Bitcoin mainnet network. pub const BC 2 [98, 99, 0, 0]; } define_hrp_const! { /// The human-readable part used by the Bitcoin testnet networks (testnet, signet). pub const TB 2 [116, 98, 0, 0]; } define_hrp_const! { /// The human-readable part used when running a Bitcoin regtest network. pub const BCRT 4 [98, 99, 114, 116]; } /// The human-readable part (human readable prefix before the '1' separator). #[derive(Clone, Copy, Debug)] pub struct Hrp { /// ASCII byte values, guaranteed not to be mixed-case. buf: [u8; MAX_HRP_LEN], /// Number of characters currently stored in this HRP. size: usize, } impl Hrp { /// Parses the human-readable part checking it is valid as defined by [BIP-173]. /// /// This does _not_ check that the `hrp` is an in-use HRP within Bitcoin (eg, "bc"), rather it /// checks that the HRP string is valid as per the specification in [BIP-173]: /// /// > The human-readable part, which is intended to convey the type of data, or anything else that /// > is relevant to the reader. This part MUST contain 1 to 83 US-ASCII characters, with each /// > character having a value in the range [33-126]. HRP validity may be further restricted by /// > specific applications. /// /// [BIP-173]: pub fn parse(hrp: &str) -> Result { use Error::*; let mut new = Hrp { buf: [0_u8; MAX_HRP_LEN], size: 0 }; if hrp.is_empty() { return Err(Empty); } if hrp.len() > MAX_HRP_LEN { return Err(TooLong(hrp.len())); } let mut has_lower: bool = false; let mut has_upper: bool = false; for (i, c) in hrp.chars().enumerate() { if !c.is_ascii() { return Err(NonAsciiChar(c)); } let b = c as u8; // cast OK as we just checked that c is an ASCII value // Valid subset of ASCII if !(33..=126).contains(&b) { return Err(InvalidAsciiByte(b)); } if b.is_ascii_lowercase() { if has_upper { return Err(MixedCase); } has_lower = true; } else if b.is_ascii_uppercase() { if has_lower { return Err(MixedCase); } has_upper = true; }; new.buf[i] = b; new.size += 1; } Ok(new) } /// Parses the human-readable part (see [`Hrp::parse`] for full docs). /// /// Does not check that `hrp` is valid according to BIP-173 but does check for valid ASCII /// values, replacing any invalid characters with `X`. pub const fn parse_unchecked(hrp: &str) -> Self { let mut new = Hrp { buf: [0_u8; MAX_HRP_LEN], size: 0 }; let hrp_bytes = hrp.as_bytes(); let mut i = 0; // Funky code so we can be const. while i < hrp.len() { let mut b = hrp_bytes[i]; // Valid subset of ASCII if b < 33 || b > 126 { b = b'X'; } new.buf[i] = b; new.size += 1; i += 1; } new } /// Returns this human-readable part as a lowercase string. #[cfg(feature = "alloc")] #[inline] pub fn to_lowercase(&self) -> String { self.lowercase_char_iter().collect() } /// Returns this human-readable part as bytes. #[inline] pub fn as_bytes(&self) -> &[u8] { &self.buf[..self.size] } /// Returns this human-readable part as str. #[inline] pub fn as_str(&self) -> &str { str::from_utf8(&self.buf[..self.size]).expect("we only store ASCII bytes") } /// Creates a byte iterator over the ASCII byte values (ASCII characters) of this HRP. /// /// If an uppercase HRP was parsed during object construction then this iterator will yield /// uppercase ASCII `char`s. For lowercase bytes see [`Self::lowercase_byte_iter`] #[inline] pub fn byte_iter(&self) -> ByteIter { ByteIter { iter: self.buf[..self.size].iter() } } /// Creates a character iterator over the ASCII characters of this HRP. /// /// If an uppercase HRP was parsed during object construction then this iterator will yield /// uppercase ASCII `char`s. For lowercase bytes see [`Self::lowercase_char_iter`]. #[inline] pub fn char_iter(&self) -> CharIter { CharIter { iter: self.byte_iter() } } /// Creates a lowercase iterator over the byte values (ASCII characters) of this HRP. #[inline] pub fn lowercase_byte_iter(&self) -> LowercaseByteIter { LowercaseByteIter { iter: self.byte_iter() } } /// Creates a lowercase character iterator over the ASCII characters of this HRP. #[inline] pub fn lowercase_char_iter(&self) -> LowercaseCharIter { LowercaseCharIter { iter: self.lowercase_byte_iter() } } /// Returns the length (number of characters) of the human-readable part. /// /// Guaranteed to be between 1 and 83 inclusive. #[inline] #[allow(clippy::len_without_is_empty)] // HRP is never empty. pub fn len(&self) -> usize { self.size } /// Returns `true` if this HRP is valid according to the bips. /// /// [BIP-173] states that the HRP must be either "bc" or "tb". /// /// [BIP-173]: #[inline] pub fn is_valid_segwit(&self) -> bool { self.is_valid_on_mainnet() || self.is_valid_on_testnet() } /// Returns `true` if this HRP is valid on the Bitcoin network i.e., HRP is "bc". #[inline] pub fn is_valid_on_mainnet(&self) -> bool { *self == self::BC } /// Returns `true` if this HRP is valid on the Bitcoin testnet network i.e., HRP is "tb". #[inline] pub fn is_valid_on_testnet(&self) -> bool { *self == self::TB } /// Returns `true` if this HRP is valid on the Bitcoin signet network i.e., HRP is "tb". #[inline] pub fn is_valid_on_signet(&self) -> bool { *self == self::TB } /// Returns `true` if this HRP is valid on the Bitcoin regtest network i.e., HRP is "bcrt". #[inline] pub fn is_valid_on_regtest(&self) -> bool { *self == self::BCRT } } /// Displays the human-readable part. /// /// If an uppercase HRP was parsed during object construction then the returned string will be /// in uppercase also. For a lowercase string see `Self::to_lowercase`. impl fmt::Display for Hrp { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for c in self.char_iter() { f.write_char(c)?; } Ok(()) } } /// Case insensitive comparison. impl Ord for Hrp { #[inline] fn cmp(&self, other: &Self) -> Ordering { self.lowercase_byte_iter().cmp(other.lowercase_byte_iter()) } } /// Case insensitive comparison. impl PartialOrd for Hrp { #[inline] fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } /// Case insensitive comparison. impl PartialEq for Hrp { #[inline] fn eq(&self, other: &Self) -> bool { self.lowercase_byte_iter().eq(other.lowercase_byte_iter()) } } impl Eq for Hrp {} impl core::hash::Hash for Hrp { #[inline] fn hash(&self, h: &mut H) { self.buf.hash(h) } } /// Iterator over bytes (ASCII values) of the human-readable part. /// /// ASCII byte values as they were initially parsed (i.e., in the original case). pub struct ByteIter<'b> { iter: slice::Iter<'b, u8>, } impl<'b> Iterator for ByteIter<'b> { type Item = u8; #[inline] fn next(&mut self) -> Option { self.iter.next().copied() } #[inline] fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } } impl<'b> ExactSizeIterator for ByteIter<'b> { #[inline] fn len(&self) -> usize { self.iter.len() } } impl<'b> DoubleEndedIterator for ByteIter<'b> { #[inline] fn next_back(&mut self) -> Option { self.iter.next_back().copied() } } impl<'b> FusedIterator for ByteIter<'b> {} /// Iterator over ASCII characters of the human-readable part. /// /// ASCII `char`s as they were initially parsed (i.e., in the original case). pub struct CharIter<'b> { iter: ByteIter<'b>, } impl<'b> Iterator for CharIter<'b> { type Item = char; #[inline] fn next(&mut self) -> Option { self.iter.next().map(Into::into) } #[inline] fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } } impl<'b> ExactSizeIterator for CharIter<'b> { #[inline] fn len(&self) -> usize { self.iter.len() } } impl<'b> DoubleEndedIterator for CharIter<'b> { #[inline] fn next_back(&mut self) -> Option { self.iter.next_back().map(Into::into) } } impl<'b> FusedIterator for CharIter<'b> {} /// Iterator over lowercase bytes (ASCII characters) of the human-readable part. pub struct LowercaseByteIter<'b> { iter: ByteIter<'b>, } impl<'b> Iterator for LowercaseByteIter<'b> { type Item = u8; #[inline] fn next(&mut self) -> Option { self.iter.next().map(|b| if is_ascii_uppercase(b) { b | 32 } else { b }) } #[inline] fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } } impl<'b> ExactSizeIterator for LowercaseByteIter<'b> { #[inline] fn len(&self) -> usize { self.iter.len() } } impl<'b> DoubleEndedIterator for LowercaseByteIter<'b> { #[inline] fn next_back(&mut self) -> Option { self.iter.next_back().map(|b| if is_ascii_uppercase(b) { b | 32 } else { b }) } } impl<'b> FusedIterator for LowercaseByteIter<'b> {} /// Iterator over lowercase ASCII characters of the human-readable part. pub struct LowercaseCharIter<'b> { iter: LowercaseByteIter<'b>, } impl<'b> Iterator for LowercaseCharIter<'b> { type Item = char; #[inline] fn next(&mut self) -> Option { self.iter.next().map(Into::into) } #[inline] fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } } impl<'b> ExactSizeIterator for LowercaseCharIter<'b> { #[inline] fn len(&self) -> usize { self.iter.len() } } impl<'b> DoubleEndedIterator for LowercaseCharIter<'b> { #[inline] fn next_back(&mut self) -> Option { self.iter.next_back().map(Into::into) } } impl<'b> FusedIterator for LowercaseCharIter<'b> {} fn is_ascii_uppercase(b: u8) -> bool { (65..=90).contains(&b) } /// Errors encountered while checking the human-readable part as defined by [BIP-173]. /// /// [BIP-173]: #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum Error { /// The human-readable part is too long. TooLong(usize), /// The human-readable part is empty. Empty, /// Found a non-ASCII character. NonAsciiChar(char), /// Byte value not within acceptable US-ASCII range. InvalidAsciiByte(u8), /// The human-readable part cannot mix upper and lower case. MixedCase, } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use Error::*; match *self { TooLong(len) => write!(f, "hrp is too long, found {} characters, must be <= 126", len), Empty => write!(f, "hrp is empty, must have at least 1 character"), NonAsciiChar(c) => write!(f, "found non-ASCII character: {}", c), InvalidAsciiByte(b) => write!(f, "byte value is not valid US-ASCII: \'{:x}\'", b), MixedCase => write!(f, "hrp cannot mix upper and lower case"), } } } #[cfg(feature = "std")] impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use Error::*; match *self { TooLong(_) | Empty | NonAsciiChar(_) | InvalidAsciiByte(_) | MixedCase => None, } } } #[cfg(test)] mod tests { use super::*; macro_rules! check_parse_ok { ($($test_name:ident, $hrp:literal);* $(;)?) => { $( #[test] fn $test_name() { assert!(Hrp::parse($hrp).is_ok()); } )* } } check_parse_ok! { parse_ok_0, "a"; parse_ok_1, "A"; parse_ok_2, "abcdefg"; parse_ok_3, "ABCDEFG"; parse_ok_4, "abc123def"; parse_ok_5, "ABC123DEF"; parse_ok_6, "!\"#$%&'()*+,-./"; parse_ok_7, "1234567890"; } macro_rules! check_parse_err { ($($test_name:ident, $hrp:literal);* $(;)?) => { $( #[test] fn $test_name() { assert!(Hrp::parse($hrp).is_err()); } )* } } check_parse_err! { parse_err_0, "has-capitals-aAbB"; parse_err_1, "has-value-out-of-range-∈∈∈∈∈∈∈∈"; parse_err_2, "toolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolong"; parse_err_3, "has spaces in it"; } macro_rules! check_iter { ($($test_name:ident, $hrp:literal, $len:literal);* $(;)?) => { $( #[test] fn $test_name() { let hrp = Hrp::parse($hrp).expect(&format!("failed to parse hrp {}", $hrp)); // Test ByteIter forwards. for (got, want) in hrp.byte_iter().zip($hrp.bytes()) { assert_eq!(got, want); } // Test ByteIter backwards. for (got, want) in hrp.byte_iter().rev().zip($hrp.bytes().rev()) { assert_eq!(got, want); } // Test exact sized works. let mut iter = hrp.byte_iter(); for i in 0..$len { assert_eq!(iter.len(), $len - i); let _ = iter.next(); } assert!(iter.next().is_none()); // Test CharIter forwards. let iter = hrp.char_iter(); assert_eq!($hrp.to_string(), iter.collect::()); for (got, want) in hrp.char_iter().zip($hrp.chars()) { assert_eq!(got, want); } // Test CharIter backwards. for (got, want) in hrp.char_iter().rev().zip($hrp.chars().rev()) { assert_eq!(got, want); } // Test LowercaseCharIter forwards (implicitly tests LowercaseByteIter) for (got, want) in hrp.lowercase_char_iter().zip($hrp.chars().map(|c| c.to_ascii_lowercase())) { assert_eq!(got, want); } // Test LowercaseCharIter backwards (implicitly tests LowercaseByteIter) for (got, want) in hrp.lowercase_char_iter().rev().zip($hrp.chars().rev().map(|c| c.to_ascii_lowercase())) { assert_eq!(got, want); } } )* } } check_iter! { char_0, "abc", 3; char_1, "ABC", 3; char_2, "abc123", 6; char_3, "ABC123", 6; char_4, "abc123def", 9; char_5, "ABC123DEF", 9; } #[cfg(feature = "alloc")] #[test] fn hrp_consts() { use crate::primitives::hrp::{BC, BCRT, TB}; assert_eq!(BC, Hrp::parse_unchecked("bc")); assert_eq!(TB, Hrp::parse_unchecked("tb")); assert_eq!(BCRT, Hrp::parse_unchecked("bcrt")); } #[test] fn as_str() { let s = "arbitraryhrp"; let hrp = Hrp::parse_unchecked(s); assert_eq!(hrp.as_str(), s); } #[test] fn as_bytes() { let s = "arbitraryhrp"; let hrp = Hrp::parse_unchecked(s); assert_eq!(hrp.as_bytes(), s.as_bytes()); } } bech32-0.11.0/src/primitives/iter.rs000064400000000000000000000374571046102023000152640ustar 00000000000000// SPDX-License-Identifier: MIT //! Iterator Adaptors. //! //! Iterator extension traits and blanket implementations to convert: //! //! - `BytesToFes`: An iterator over bytes to an iterator over field elements. //! - `FesToBytes`: An iterator over field elements to an iterator over bytes. //! - `Checksummed`: An iterator over field elements that appends the checksum. //! //! WARNING: This module does not enforce the maximum length of an encoded bech32 string (90 chars). //! //! # Examples //! //! ``` //! use bech32::{Bech32, ByteIterExt, Fe32IterExt, Fe32, Hrp}; //! //! let data = [ //! 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, //! 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, //! 0xf1, 0x43, 0x3b, 0xd6, //! ]; //! //! // Convert byte data to GF32 field elements. //! let fe_iter = data.iter().copied().bytes_to_fes(); //! //! // Convert field elements back to bytes. //! let byte_iter = fe_iter.fes_to_bytes(); //! //! # assert!(data.iter().copied().eq(byte_iter)); //! ``` use crate::primitives::checksum::{self, Checksum, PackedFe32}; use crate::primitives::encode::Encoder; use crate::primitives::gf32::Fe32; use crate::primitives::hrp::Hrp; /// Extension trait for byte iterators which provides an adaptor to GF32 elements. pub trait ByteIterExt: Sized + Iterator { /// Adapts the byte iterator to output GF32 field elements instead. /// /// If the total number of bits is not a multiple of 5 we pad with 0s #[inline] fn bytes_to_fes(mut self) -> BytesToFes { BytesToFes { last_byte: self.next(), bit_offset: 0, iter: self } } } impl ByteIterExt for I where I: Iterator {} /// Extension trait for field element iterators. pub trait Fe32IterExt: Sized + Iterator { /// Adapts the `Fe32` iterator to output bytes instead. /// /// If the total number of bits is not a multiple of 8, any trailing bits /// are simply dropped. #[inline] fn fes_to_bytes(mut self) -> FesToBytes { FesToBytes { last_fe: self.next(), bit_offset: 0, iter: self } } /// Adapts the Fe32 iterator to encode the field elements into a bech32 address. #[inline] fn with_checksum(self, hrp: &Hrp) -> Encoder { Encoder::new(self, hrp) } } impl Fe32IterExt for I where I: Iterator {} /// Iterator adaptor that converts bytes to GF32 elements. /// /// If the total number of bits is not a multiple of 5, it right-pads with 0 bits. #[derive(Clone, PartialEq, Eq)] pub struct BytesToFes> { last_byte: Option, bit_offset: usize, iter: I, } impl Iterator for BytesToFes where I: Iterator, { type Item = Fe32; #[inline] fn next(&mut self) -> Option { use core::cmp::Ordering::*; let bit_offset = { let ret = self.bit_offset; self.bit_offset = (self.bit_offset + 5) % 8; ret }; if let Some(last) = self.last_byte { match bit_offset.cmp(&3) { Less => Some(Fe32((last >> (3 - bit_offset)) & 0x1f)), Equal => { self.last_byte = self.iter.next(); Some(Fe32(last & 0x1f)) } Greater => { self.last_byte = self.iter.next(); let next = self.last_byte.unwrap_or(0); Some(Fe32(((last << (bit_offset - 3)) | (next >> (11 - bit_offset))) & 0x1f)) } } } else { None } } #[inline] fn size_hint(&self) -> (usize, Option) { let (min, max) = self.iter.size_hint(); let (min, max) = match self.last_byte { // +1 because we set last_byte with call to `next`. Some(_) => (min + 1, max.map(|max| max + 1)), None => (min, max), }; let min = bytes_len_to_fes_len(min); let max = max.map(bytes_len_to_fes_len); (min, max) } } /// The number of fes encoded by n bytes, rounded up because we pad the fes. fn bytes_len_to_fes_len(bytes: usize) -> usize { let bits = bytes * 8; (bits + 4) / 5 } impl ExactSizeIterator for BytesToFes where I: Iterator + ExactSizeIterator, { #[inline] fn len(&self) -> usize { let len = match self.last_byte { Some(_) => self.iter.len() + 1, None => self.iter.len(), }; bytes_len_to_fes_len(len) } } /// Iterator adaptor that converts GF32 elements to bytes. /// /// If the total number of bits is not a multiple of 8, any trailing bits are dropped. /// /// Note that if there are 5 or more trailing bits, the result will be that an entire field element /// is dropped. If this occurs, the input was an invalid length for a bech32 string, but this /// iterator does not do any checks for this. #[derive(Clone, PartialEq, Eq)] pub struct FesToBytes> { last_fe: Option, bit_offset: usize, iter: I, } impl Iterator for FesToBytes where I: Iterator, { type Item = u8; fn next(&mut self) -> Option { let bit_offset = { let ret = self.bit_offset; self.bit_offset = (self.bit_offset + 8) % 5; ret }; if let Some(last) = self.last_fe { let mut ret = last.0 << (3 + bit_offset); self.last_fe = self.iter.next(); let next1 = self.last_fe?; if bit_offset > 2 { self.last_fe = self.iter.next(); let next2 = self.last_fe?; ret |= next1.0 << (bit_offset - 2); ret |= next2.0 >> (7 - bit_offset); } else { ret |= next1.0 >> (2 - bit_offset); if self.bit_offset == 0 { self.last_fe = self.iter.next(); } } Some(ret) } else { None } } #[inline] fn size_hint(&self) -> (usize, Option) { // If the total number of bits is not a multiple of 8, any trailing bits are dropped. let fes_len_to_bytes_len = |n| n * 5 / 8; let (fes_min, fes_max) = self.iter.size_hint(); // +1 because we set last_fe with call to `next`. let min = fes_len_to_bytes_len(fes_min + 1); let max = fes_max.map(|max| fes_len_to_bytes_len(max + 1)); (min, max) } } // If the total number of bits is not a multiple of 8, any trailing bits are dropped. fn fes_len_to_bytes_len(n: usize) -> usize { n * 5 / 8 } impl ExactSizeIterator for FesToBytes where I: Iterator + ExactSizeIterator, { #[inline] fn len(&self) -> usize { let len = match self.last_fe { Some(_) => self.iter.len() + 1, None => self.iter.len(), }; fes_len_to_bytes_len(len) } } /// Iterator adaptor for field-element-yielding iterator, which tacks a checksum onto the end of the /// yielded data. #[derive(Clone, PartialEq, Eq)] pub struct Checksummed where I: Iterator, Ck: Checksum, { iter: I, checksum_remaining: usize, checksum_engine: checksum::Engine, } impl Checksummed where I: Iterator, Ck: Checksum, { /// Creates a new checksummed iterator which adapts a data iterator of field elements by /// appending a checksum. #[inline] pub fn new(data: I) -> Checksummed { Checksummed { iter: data, checksum_remaining: Ck::CHECKSUM_LENGTH, checksum_engine: checksum::Engine::new(), } } /// Creates a new checksummed iterator which adapts a data iterator of field elements by /// first inputting the [`Hrp`] and then appending a checksum. #[inline] pub fn new_hrp(hrp: Hrp, data: I) -> Checksummed { let mut ret = Self::new(data); ret.checksum_engine.input_hrp(hrp); ret } } impl Iterator for Checksummed where I: Iterator, Ck: Checksum, { type Item = Fe32; #[inline] fn next(&mut self) -> Option { match self.iter.next() { Some(fe) => { self.checksum_engine.input_fe(fe); Some(fe) } None => if self.checksum_remaining == 0 { None } else { if self.checksum_remaining == Ck::CHECKSUM_LENGTH { self.checksum_engine.input_target_residue(); } self.checksum_remaining -= 1; Some(Fe32(self.checksum_engine.residue().unpack(self.checksum_remaining))) }, } } #[inline] fn size_hint(&self) -> (usize, Option) { let add = self.checksum_remaining; let (min, max) = self.iter.size_hint(); (min + add, max.map(|max| max + add)) } } #[cfg(test)] mod tests { use super::*; // Tests below using this data, are based on the test vector (from BIP-173): // BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4: 0014751e76e8199196d454941c45d1b3a323f1433bd6 #[rustfmt::skip] const DATA: [u8; 20] = [ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6, ]; #[test] fn byte_iter_ext() { assert!(DATA .iter() .copied() .bytes_to_fes() .map(Fe32::to_char) .eq("w508d6qejxtdg4y5r3zarvary0c5xw7k".chars())); } #[test] fn bytes_to_fes_size_hint() { let char_len = "w508d6qejxtdg4y5r3zarvary0c5xw7k".len(); assert_eq!(DATA.iter().copied().bytes_to_fes().size_hint(), (char_len, Some(char_len))); } #[test] fn fe32_iter_ext() { let fe_iter = "w508d6qejxtdg4y5r3zarvary0c5xw7k" .bytes() .map(|b| Fe32::from_char(char::from(b)).unwrap()); assert!(fe_iter.clone().fes_to_bytes().eq(DATA.iter().copied())); } #[test] fn fes_to_bytes_size_hint() { let fe_iter = "w508d6qejxtdg4y5r3zarvary0c5xw7k" .bytes() .map(|b| Fe32::from_char(char::from(b)).unwrap()); let got_hint = fe_iter.clone().fes_to_bytes().size_hint(); let want_hint = DATA.iter().size_hint(); assert_eq!(got_hint, want_hint) } #[test] fn padding_bytes_trailing_0_bits_roundtrips() { // 5 * 8 % 5 = 0 const BYTES: [u8; 5] = [0x75, 0x1e, 0x76, 0xe8, 0x19]; assert!(BYTES.iter().copied().bytes_to_fes().fes_to_bytes().eq(BYTES.iter().copied())) } #[test] fn padding_bytes_trailing_1_bit_roundtrips() { // 2 * 8 % 5 = 1 const BYTES: [u8; 2] = [0x75, 0x1e]; assert!(BYTES.iter().copied().bytes_to_fes().fes_to_bytes().eq(BYTES.iter().copied())) } #[test] fn padding_bytes_trailing_2_bits_roundtrips() { // 4 * 8 % 5 = 2 const BYTES: [u8; 4] = [0x75, 0x1e, 0x76, 0xe8]; assert!(BYTES.iter().copied().bytes_to_fes().fes_to_bytes().eq(BYTES.iter().copied())) } #[test] fn padding_bytes_trailing_3_bits_roundtrips() { // 6 * 8 % 5 = 3 const BYTES: [u8; 6] = [0x75, 0x1e, 0x76, 0xe8, 0x19, 0xab]; assert!(BYTES.iter().copied().bytes_to_fes().fes_to_bytes().eq(BYTES.iter().copied())) } #[test] fn padding_bytes_trailing_4_bits_roundtrips() { // 3 * 8 % 5 = 4 const BYTES: [u8; 3] = [0x75, 0x1e, 0x76]; assert!(BYTES.iter().copied().bytes_to_fes().fes_to_bytes().eq(BYTES.iter().copied())) } #[test] fn padding_fes_trailing_0_bits_roundtrips() { // 8 * 5 % 8 = 0 const FES: [Fe32; 8] = [Fe32::Q, Fe32::P, Fe32::Z, Fe32::R, Fe32::Y, Fe32::X, Fe32::G, Fe32::F]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] fn padding_fes_trailing_1_bit_zero_roundtrips() { // 5 * 5 % 8 = 1 const FES: [Fe32; 5] = [Fe32::Q, Fe32::P, Fe32::Z, Fe32::R, Fe32::Q]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] #[should_panic] fn padding_fes_trailing_1_bit_non_zero_does_not_roundtrip() { // 5 * 5 % 8 = 1 const FES: [Fe32; 5] = [Fe32::Q, Fe32::P, Fe32::Z, Fe32::R, Fe32::L]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] fn padding_fes_trailing_2_bits_zeros_roundtrips() { // 2 * 5 % 8 = 2 const FES: [Fe32; 2] = [Fe32::P, Fe32::Q]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] #[should_panic] fn padding_fes_trailing_2_bits_non_zero_does_not_roundtrip() { // 2 * 5 % 8 = 2 const FES: [Fe32; 2] = [Fe32::Q, Fe32::P]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] fn padding_fes_trailing_3_bits_zeros_roundtrips() { // 7 * 5 % 8 = 3 const FES: [Fe32; 7] = [Fe32::Q, Fe32::P, Fe32::Z, Fe32::R, Fe32::Y, Fe32::X, Fe32::Q]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] #[should_panic] fn padding_fes_trailing_3_bits_non_zero_does_not_roundtrip() { // 7 * 5 % 8 = 3 const FES: [Fe32; 7] = [Fe32::Q, Fe32::P, Fe32::Z, Fe32::R, Fe32::Y, Fe32::X, Fe32::P]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] fn padding_fes_trailing_4_bits_zeros_roundtrips() { // 4 * 5 % 8 = 4 const FES: [Fe32; 4] = [Fe32::Q, Fe32::P, Fe32::Z, Fe32::Q]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] #[should_panic] fn padding_fes_trailing_4_bits_non_zero_does_not_roundtrip() { // 4 * 5 % 8 = 4 const FES: [Fe32; 4] = [Fe32::Q, Fe32::P, Fe32::Z, Fe32::P]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } // Padding is never more than 4 bits so any additional bits will always fail to roundtrip. #[test] #[should_panic] fn padding_fes_trailing_5_bits_zeros_does_not_roundtrip() { // 1 * 5 % 8 = 5 const FES: [Fe32; 1] = [Fe32::Q]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] #[should_panic] fn padding_fes_trailing_5_bits_non_zero_does_not_roundtrip() { // 1 * 5 % 8 = 5 const FES: [Fe32; 1] = [Fe32::P]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] #[should_panic] fn padding_fes_trailing_6_bits_zeros_does_not_roundtrip() { // 6 * 5 % 8 = 6 const FES: [Fe32; 6] = [Fe32::Q, Fe32::P, Fe32::Z, Fe32::R, Fe32::Q, Fe32::Q]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] #[should_panic] fn padding_fes_trailing_6_bits_non_zero_does_not_roundtrip() { // 6 * 5 % 8 = 6 const FES: [Fe32; 6] = [Fe32::Q, Fe32::P, Fe32::Z, Fe32::R, Fe32::Y, Fe32::X]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] #[should_panic] fn padding_fes_trailing_7_bits_zeros_does_not_roundtrip() { // 3 * 5 % 8 = 7 const FES: [Fe32; 3] = [Fe32::P, Fe32::Q, Fe32::Q]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } #[test] #[should_panic] fn padding_fes_trailing_7_bits_non_zero_does_not_roundtrip() { // 3 * 5 % 8 = 7 const FES: [Fe32; 3] = [Fe32::Q, Fe32::P, Fe32::Q]; assert!(FES.iter().copied().fes_to_bytes().bytes_to_fes().eq(FES.iter().copied())) } } bech32-0.11.0/src/primitives/mod.rs000064400000000000000000000036571046102023000150730ustar 00000000000000// SPDX-License-Identifier: MIT //! Provides the internal nuts and bolts that enable bech32 encoding/decoding. pub mod checksum; pub mod decode; pub mod encode; pub mod gf32; pub mod hrp; pub mod iter; pub mod segwit; use checksum::{Checksum, PackedNull}; /// The "null checksum" used on bech32 strings for which we want to do no checksum checking. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum NoChecksum {} /// The bech32 checksum algorithm, defined in [BIP-173]. /// /// [BIP-173]: #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Bech32 {} /// The bech32m checksum algorithm, defined in [BIP-350]. /// /// [BIP-350]: #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Bech32m {} impl Checksum for NoChecksum { type MidstateRepr = PackedNull; const CODE_LENGTH: usize = usize::MAX; const CHECKSUM_LENGTH: usize = 0; const GENERATOR_SH: [PackedNull; 5] = [PackedNull; 5]; const TARGET_RESIDUE: PackedNull = PackedNull; } // Bech32[m] generator coefficients, copied from Bitcoin Core src/bech32.cpp const GEN: [u32; 5] = [0x3b6a_57b2, 0x2650_8e6d, 0x1ea1_19fa, 0x3d42_33dd, 0x2a14_62b3]; impl Checksum for Bech32 { type MidstateRepr = u32; const CODE_LENGTH: usize = 1023; const CHECKSUM_LENGTH: usize = 6; const GENERATOR_SH: [u32; 5] = GEN; const TARGET_RESIDUE: u32 = 1; } // Same as Bech32 except TARGET_RESIDUE is different impl Checksum for Bech32m { type MidstateRepr = u32; const CODE_LENGTH: usize = 1023; const CHECKSUM_LENGTH: usize = 6; const GENERATOR_SH: [u32; 5] = GEN; const TARGET_RESIDUE: u32 = 0x2bc830a3; } #[cfg(test)] mod tests { use super::*; #[test] fn bech32_sanity() { Bech32::sanity_check(); } #[test] fn bech32m_sanity() { Bech32m::sanity_check(); } } bech32-0.11.0/src/primitives/segwit.rs000064400000000000000000000073161046102023000156120ustar 00000000000000// SPDX-License-Identifier: MIT //! Segregated Witness functionality - useful for enforcing parts of [BIP-173] and [BIP-350]. //! //! [BIP-173]: //! [BIP-350]: use core::fmt; use crate::primitives::gf32::Fe32; /// The maximum enforced string length of a segwit address. /// /// The maximum length as specified in BIP-173, this is less than the 1023 character code length. /// This limit is based on empirical error-correcting properties. See ["Checksum design"] section. /// /// ["Checksum design"]: pub const MAX_STRING_LENGTH: usize = 90; /// The field element representing segwit version 0. pub const VERSION_0: Fe32 = Fe32::Q; /// The field element representing segwit version 1 (taproot). pub const VERSION_1: Fe32 = Fe32::P; /// Returns true if given field element represents a valid segwit version. pub fn is_valid_witness_version(witness_version: Fe32) -> bool { validate_witness_version(witness_version).is_ok() } /// Returns true if `length` represents a valid witness program length for `witness_version`. pub fn is_valid_witness_program_length(length: usize, witness_version: Fe32) -> bool { validate_witness_program_length(length, witness_version).is_ok() } /// Checks that the given field element represents a valid segwit witness version. pub fn validate_witness_version(witness_version: Fe32) -> Result<(), InvalidWitnessVersionError> { if witness_version.to_u8() > 16 { Err(InvalidWitnessVersionError(witness_version)) } else { Ok(()) } } /// Validates the segwit witness program `length` rules for witness `version`. pub fn validate_witness_program_length( length: usize, version: Fe32, ) -> Result<(), WitnessLengthError> { use WitnessLengthError::*; if length < 2 { return Err(TooShort); } if length > 40 { return Err(TooLong); } if version == VERSION_0 && length != 20 && length != 32 { return Err(InvalidSegwitV0); } Ok(()) } /// Field element does not represent a valid witness version. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub struct InvalidWitnessVersionError(pub Fe32); #[rustfmt::skip] impl fmt::Display for InvalidWitnessVersionError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "invalid segwit witness version: {} (bech32 character: '{}')", self.0.to_u8(), self.0) } } #[cfg(feature = "std")] impl std::error::Error for InvalidWitnessVersionError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None } } /// Witness program invalid because of incorrect length. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum WitnessLengthError { /// The witness data is too short. TooShort, /// The witness data is too long. TooLong, /// The segwit v0 witness is not 20 or 32 bytes long. InvalidSegwitV0, } impl fmt::Display for WitnessLengthError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use WitnessLengthError::*; match *self { TooShort => write!(f, "witness program is less than 2 bytes long"), TooLong => write!(f, "witness program is more than 40 bytes long"), InvalidSegwitV0 => write!(f, "the segwit v0 witness is not 20 or 32 bytes long"), } } } #[cfg(feature = "std")] impl std::error::Error for WitnessLengthError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use WitnessLengthError::*; match *self { TooShort | TooLong | InvalidSegwitV0 => None, } } } bech32-0.11.0/src/segwit.rs000064400000000000000000000475511046102023000134240ustar 00000000000000// SPDX-License-Identifier: MIT //! Segregated Witness API - enables typical usage for encoding and decoding segwit addresses. //! //! [BIP-173] and [BIP-350] contain some complexity. This module aims to allow you to create modern //! Bitcoin addresses correctly and easily without intimate knowledge of the BIPs. However, if you //! do posses such knowledge and are doing unusual things you may prefer to use the `primitives` //! submodules directly. //! //! # Examples //! //! ``` //! # #[cfg(feature = "alloc")] { //! use bech32::{hrp, segwit, Fe32, Hrp}; //! //! let witness_prog = [ //! 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, //! 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, //! 0xf1, 0x43, 0x3b, 0xd6, //! ]; //! //! // Encode a taproot address suitable for use on mainnet. //! let _ = segwit::encode_v1(hrp::BC, &witness_prog); //! //! // Encode a segwit v0 address suitable for use on testnet. //! let _ = segwit::encode_v0(hrp::TB, &witness_prog); //! //! // If you have the witness version already you can use: //! # let witness_version = segwit::VERSION_0; //! let _ = segwit::encode(hrp::BC, witness_version, &witness_prog); //! //! // Decode a Bitcoin bech32 segwit address. //! let address = "bc1q2s3rjwvam9dt2ftt4sqxqjf3twav0gdx0k0q2etxflx38c3x8tnssdmnjq"; //! let (hrp, witness_version, witness_program) = segwit::decode(address).expect("failed to decode address"); //! # } //! ``` //! //! [BIP-173]: //! [BIP-350]: //! [`bip_173_test_vectors.rs`]: //! [`bip_350_test_vectors.rs`]: #[cfg(all(feature = "alloc", not(feature = "std"), not(test)))] use alloc::{string::String, vec::Vec}; use core::fmt; use crate::error::write_err; use crate::primitives::decode::SegwitCodeLengthError; #[cfg(feature = "alloc")] use crate::primitives::decode::{SegwitHrpstring, SegwitHrpstringError}; use crate::primitives::gf32::Fe32; use crate::primitives::hrp::Hrp; use crate::primitives::iter::{ByteIterExt, Fe32IterExt}; #[cfg(feature = "alloc")] use crate::primitives::segwit; use crate::primitives::segwit::{ InvalidWitnessVersionError, WitnessLengthError, MAX_STRING_LENGTH, }; use crate::primitives::{Bech32, Bech32m}; #[rustfmt::skip] // Keep public re-exports separate. #[doc(inline)] pub use { crate::primitives::segwit::{VERSION_0, VERSION_1}, }; /// Decodes a segwit address. /// /// # Returns /// /// The HRP, the witness version, and a guaranteed valid length witness program. /// /// # Examples /// /// ``` /// use bech32::segwit; /// let address = "bc1py3m7vwnghyne9gnvcjw82j7gqt2rafgdmlmwmqnn3hvcmdm09rjqcgrtxs"; /// let (_hrp, _witness_version, _witness_program) = segwit::decode(address).expect("failed to decode address"); /// ``` #[cfg(feature = "alloc")] #[inline] pub fn decode(s: &str) -> Result<(Hrp, Fe32, Vec), DecodeError> { let segwit = SegwitHrpstring::new(s)?; Ok((segwit.hrp(), segwit.witness_version(), segwit.byte_iter().collect::>())) } /// Encodes a segwit address. /// /// Does validity checks on the `witness_version`, length checks on the `witness_program`, and /// checks the total encoded string length. /// /// As specified by [BIP-350] we use the [`Bech32m`] checksum algorithm for witness versions 1 and /// above, and for witness version 0 we use the original ([BIP-173]) [`Bech32`] checksum /// algorithm. /// /// See also [`encode_v0`] or [`encode_v1`]. /// /// [`Bech32`]: crate::primitives::Bech32 /// [`Bech32m`]: crate::primitives::Bech32m /// [BIP-173]: /// [BIP-350]: #[cfg(feature = "alloc")] #[inline] pub fn encode( hrp: Hrp, witness_version: Fe32, witness_program: &[u8], ) -> Result { segwit::validate_witness_version(witness_version)?; segwit::validate_witness_program_length(witness_program.len(), witness_version)?; let _ = encoded_length(hrp, witness_version, witness_program)?; let mut buf = String::new(); encode_to_fmt_unchecked(&mut buf, hrp, witness_version, witness_program)?; Ok(buf) } /// Encodes a segwit version 0 address. /// /// Does validity checks on the `witness_version`, length checks on the `witness_program`, and /// checks the total encoded string length. #[cfg(feature = "alloc")] #[inline] pub fn encode_v0(hrp: Hrp, witness_program: &[u8]) -> Result { encode(hrp, VERSION_0, witness_program) } /// Encodes a segwit version 1 address. /// /// Does validity checks on the `witness_version`, length checks on the `witness_program`, and /// checks the total encoded string length. #[cfg(feature = "alloc")] #[inline] pub fn encode_v1(hrp: Hrp, witness_program: &[u8]) -> Result { encode(hrp, VERSION_1, witness_program) } /// Encodes a segwit address to a writer ([`fmt::Write`]) using lowercase characters. /// /// There are no guarantees that the written string is a valid segwit address unless all the /// parameters are valid. See the body of `encode()` to see the validity checks required. #[inline] pub fn encode_to_fmt_unchecked( fmt: &mut W, hrp: Hrp, witness_version: Fe32, witness_program: &[u8], ) -> fmt::Result { encode_lower_to_fmt_unchecked(fmt, hrp, witness_version, witness_program) } /// Encodes a segwit address to a writer ([`fmt::Write`]) using lowercase characters. /// /// There are no guarantees that the written string is a valid segwit address unless all the /// parameters are valid. See the body of `encode()` to see the validity checks required. pub fn encode_lower_to_fmt_unchecked( fmt: &mut W, hrp: Hrp, witness_version: Fe32, witness_program: &[u8], ) -> fmt::Result { let mut buf = [0u8; MAX_STRING_LENGTH]; let mut pos = 0; let iter = witness_program.iter().copied().bytes_to_fes(); match witness_version { VERSION_0 => { let bytes = iter.with_checksum::(&hrp).with_witness_version(VERSION_0).bytes(); buf.iter_mut().zip(bytes).for_each(|(dst, src)| { *dst = src; pos += 1; }); } version => { let bytes = iter.with_checksum::(&hrp).with_witness_version(version).bytes(); buf.iter_mut().zip(bytes).for_each(|(dst, src)| { *dst = src; pos += 1; }); } } let s = core::str::from_utf8(&buf[..pos]).expect("we only write ASCII"); fmt.write_str(s)?; Ok(()) } /// Encodes a segwit address to a writer ([`fmt::Write`]) using uppercase characters. /// /// This is provided for use when creating QR codes. /// /// There are no guarantees that the written string is a valid segwit address unless all the /// parameters are valid. See the body of `encode()` to see the validity checks required. #[inline] pub fn encode_upper_to_fmt_unchecked( fmt: &mut W, hrp: Hrp, witness_version: Fe32, witness_program: &[u8], ) -> fmt::Result { let mut buf = [0u8; MAX_STRING_LENGTH]; let mut pos = 0; let iter = witness_program.iter().copied().bytes_to_fes(); match witness_version { VERSION_0 => { let bytes = iter.with_checksum::(&hrp).with_witness_version(VERSION_0).bytes(); buf.iter_mut().zip(bytes).for_each(|(dst, src)| { *dst = src.to_ascii_uppercase(); pos += 1; }); } version => { let bytes = iter.with_checksum::(&hrp).with_witness_version(version).bytes(); buf.iter_mut().zip(bytes).for_each(|(dst, src)| { *dst = src.to_ascii_uppercase(); pos += 1; }); } } let s = core::str::from_utf8(&buf[..pos]).expect("we only write ASCII"); fmt.write_str(s)?; Ok(()) } /// Encodes a segwit address to a writer ([`io::Write`]) using lowercase characters. /// /// There are no guarantees that the written string is a valid segwit address unless all the /// parameters are valid. See the body of `encode()` to see the validity checks required. /// /// [`io::Write`]: std::io::Write #[cfg(feature = "std")] #[inline] pub fn encode_to_writer_unchecked( w: &mut W, hrp: Hrp, witness_version: Fe32, witness_program: &[u8], ) -> std::io::Result<()> { encode_lower_to_writer_unchecked(w, hrp, witness_version, witness_program) } /// Encodes a segwit address to a writer ([`io::Write`]) using lowercase characters. /// /// There are no guarantees that the written string is a valid segwit address unless all the /// parameters are valid. See the body of `encode()` to see the validity checks required. /// /// [`io::Write`]: std::io::Write #[cfg(feature = "std")] #[inline] pub fn encode_lower_to_writer_unchecked( w: &mut W, hrp: Hrp, witness_version: Fe32, witness_program: &[u8], ) -> std::io::Result<()> { let mut buf = [0u8; MAX_STRING_LENGTH]; let mut pos = 0; let iter = witness_program.iter().copied().bytes_to_fes(); match witness_version { VERSION_0 => { let bytes = iter.with_checksum::(&hrp).with_witness_version(VERSION_0).bytes(); buf.iter_mut().zip(bytes).for_each(|(dst, src)| { *dst = src; pos += 1; }); } version => { let bytes = iter.with_checksum::(&hrp).with_witness_version(version).bytes(); buf.iter_mut().zip(bytes).for_each(|(dst, src)| { *dst = src; pos += 1; }); } } w.write_all(&buf[..pos])?; Ok(()) } /// Encodes a segwit address to a [`io::Write`] writer using uppercase characters. /// /// This is provided for use when creating QR codes. /// /// There are no guarantees that the written string is a valid segwit address unless all the /// parameters are valid. See the body of `encode()` to see the validity checks required. /// /// [`io::Write`]: std::io::Write #[cfg(feature = "std")] #[inline] pub fn encode_upper_to_writer_unchecked( w: &mut W, hrp: Hrp, witness_version: Fe32, witness_program: &[u8], ) -> std::io::Result<()> { let mut buf = [0u8; MAX_STRING_LENGTH]; let mut pos = 0; let iter = witness_program.iter().copied().bytes_to_fes(); match witness_version { VERSION_0 => { let bytes = iter.with_checksum::(&hrp).with_witness_version(VERSION_0).bytes(); buf.iter_mut().zip(bytes).for_each(|(dst, src)| { *dst = src.to_ascii_uppercase(); pos += 1; }); } version => { let bytes = iter.with_checksum::(&hrp).with_witness_version(version).bytes(); buf.iter_mut().zip(bytes).for_each(|(dst, src)| { *dst = src.to_ascii_uppercase(); pos += 1; }); } } w.write_all(&buf[..pos])?; Ok(()) } /// Returns the length of the address after encoding HRP, witness version and program. /// /// # Returns /// /// `Ok(address_length)` if the encoded address length is less than or equal to 90. Otherwise /// returns a [`SegwitCodeLengthError`] containing the encoded address length. pub fn encoded_length( hrp: Hrp, _witness_version: Fe32, // Emphasize that this is only for segwit. witness_program: &[u8], ) -> Result { // Ck is only for length and since they are both the same we can use either here. let len = crate::encoded_length::(hrp, witness_program).map(|len| len + 1)?; // +1 for witness version. if len > MAX_STRING_LENGTH { Err(SegwitCodeLengthError(len)) } else { Ok(len) } } /// An error while decoding a segwit address. #[cfg(feature = "alloc")] #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub struct DecodeError(pub SegwitHrpstringError); #[cfg(feature = "alloc")] impl fmt::Display for DecodeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write_err!(f, "decoding segwit address failed"; self.0) } } #[cfg(feature = "std")] impl std::error::Error for DecodeError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { Some(&self.0) } } #[cfg(feature = "alloc")] impl From for DecodeError { #[inline] fn from(e: SegwitHrpstringError) -> Self { Self(e) } } /// An error while constructing a [`SegwitHrpstring`] type. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] #[cfg(feature = "alloc")] pub enum EncodeError { /// Invalid witness version (must be 0-16 inclusive). WitnessVersion(InvalidWitnessVersionError), /// Invalid witness length. WitnessLength(WitnessLengthError), /// Encoding HRP, witver, and program into a bech32 string exceeds maximum allowed. TooLong(SegwitCodeLengthError), /// Writing to formatter failed. Fmt(fmt::Error), } #[cfg(feature = "alloc")] impl fmt::Display for EncodeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use EncodeError::*; match *self { WitnessVersion(ref e) => write_err!(f, "witness version"; e), WitnessLength(ref e) => write_err!(f, "witness length"; e), TooLong(ref e) => write_err!(f, "encode error"; e), Fmt(ref e) => write_err!(f, "writing to formatter failed"; e), } } } #[cfg(feature = "std")] #[cfg(feature = "alloc")] impl std::error::Error for EncodeError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use EncodeError::*; match *self { WitnessVersion(ref e) => Some(e), WitnessLength(ref e) => Some(e), TooLong(ref e) => Some(e), Fmt(ref e) => Some(e), } } } #[cfg(feature = "alloc")] impl From for EncodeError { #[inline] fn from(e: InvalidWitnessVersionError) -> Self { Self::WitnessVersion(e) } } #[cfg(feature = "alloc")] impl From for EncodeError { #[inline] fn from(e: WitnessLengthError) -> Self { Self::WitnessLength(e) } } #[cfg(feature = "alloc")] impl From for EncodeError { #[inline] fn from(e: SegwitCodeLengthError) -> Self { Self::TooLong(e) } } #[cfg(feature = "alloc")] impl From for EncodeError { #[inline] fn from(e: fmt::Error) -> Self { Self::Fmt(e) } } #[cfg(all(test, feature = "alloc"))] mod tests { use super::*; use crate::primitives::decode::{SegwitCodeLengthError, SegwitHrpstringError}; use crate::primitives::hrp; #[test] // Just shows we handle both v0 and v1 addresses, for complete test // coverage see primitives submodules and test vectors. fn roundtrip_valid_mainnet_addresses() { // A few recent addresses from mainnet (Block 801266). let addresses = vec![ "bc1q2s3rjwvam9dt2ftt4sqxqjf3twav0gdx0k0q2etxflx38c3x8tnssdmnjq", // Segwit v0 "bc1py3m7vwnghyne9gnvcjw82j7gqt2rafgdmlmwmqnn3hvcmdm09rjqcgrtxs", // Segwit v1 ]; for address in addresses { let (hrp, version, program) = decode(address).expect("failed to decode valid address"); let encoded = encode(hrp, version, &program).expect("failed to encode address"); assert_eq!(encoded, address); } } fn witness_program() -> [u8; 20] { [ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6, ] } #[test] fn encode_lower_to_fmt() { let program = witness_program(); let mut address = String::new(); encode_to_fmt_unchecked(&mut address, hrp::BC, VERSION_0, &program) .expect("failed to encode address to QR code"); let want = "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"; assert_eq!(address, want); } #[test] fn encode_upper_to_fmt() { let program = witness_program(); let mut address = String::new(); encode_upper_to_fmt_unchecked(&mut address, hrp::BC, VERSION_0, &program) .expect("failed to encode address to QR code"); let want = "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4"; assert_eq!(address, want); } #[test] #[cfg(feature = "std")] fn encode_lower_to_writer() { let program = witness_program(); let mut buf = Vec::new(); encode_lower_to_writer_unchecked(&mut buf, hrp::BC, VERSION_0, &program) .expect("failed to encode"); let address = std::str::from_utf8(&buf).expect("ascii is valid utf8"); let want = "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"; assert_eq!(address, want); } #[test] #[cfg(feature = "std")] fn encode_upper_to_writer() { let program = witness_program(); let mut buf = Vec::new(); encode_upper_to_writer_unchecked(&mut buf, hrp::BC, VERSION_0, &program) .expect("failed to encode"); let address = std::str::from_utf8(&buf).expect("ascii is valid utf8"); let want = "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4"; assert_eq!(address, want); } #[test] #[cfg(feature = "std")] fn encode_lower_to_writer_including_lowecaseing_hrp() { let program = witness_program(); let mut buf = Vec::new(); let hrp = Hrp::parse_unchecked("BC"); encode_lower_to_writer_unchecked(&mut buf, hrp, VERSION_0, &program) .expect("failed to encode"); let address = std::str::from_utf8(&buf).expect("ascii is valid utf8"); let want = "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"; assert_eq!(address, want); } #[test] fn encoded_length_works() { let addresses = vec![ "bc1q2s3rjwvam9dt2ftt4sqxqjf3twav0gdx0k0q2etxflx38c3x8tnssdmnjq", "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", ]; for address in addresses { let (hrp, version, program) = decode(address).expect("valid address"); let encoded = encode(hrp, version, &program).expect("valid data"); let want = encoded.len(); let got = encoded_length(hrp, version, &program).expect("encoded length"); assert_eq!(got, want); } } #[test] fn can_encode_maximum_length_address() { let program = [0_u8; 40]; // Maximum witness program length. let hrp = Hrp::parse_unchecked("anhrpthatis18chars"); let addr = encode(hrp, VERSION_1, &program).expect("valid data"); assert_eq!(addr.len(), MAX_STRING_LENGTH); } #[test] fn can_not_encode_address_too_long() { let tcs = vec![ ("anhrpthatis19charsx", 91), ("anhrpthatisthemaximumallowedlengthofeightythreebytesxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 155) ]; for (hrp, len) in tcs { let program = [0_u8; 40]; // Maximum witness program length. let hrp = Hrp::parse_unchecked(hrp); let err = encode(hrp, VERSION_1, &program).unwrap_err(); assert_eq!(err, EncodeError::TooLong(SegwitCodeLengthError(len))); } } #[test] fn can_decode_maximum_length_address() { let address = "anhrpthatisnineteen1pqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqghfyyfz"; assert_eq!(address.len(), MAX_STRING_LENGTH); assert!(decode(address).is_ok()); } #[test] fn can_not_decode_address_too_long() { let address = "anhrpthatistwentycha1pqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgqfrwjz"; assert_eq!(address.len(), MAX_STRING_LENGTH + 1); assert_eq!(decode(address).unwrap_err(), DecodeError(SegwitHrpstringError::TooLong(91))); } } bech32-0.11.0/tests/bip_173_test_vectors.rs000064400000000000000000000137171046102023000164420ustar 00000000000000// BIP-173 test vectors. #![cfg(feature = "alloc")] use bech32::primitives::decode::{ CheckedHrpstring, ChecksumError, SegwitHrpstring, UncheckedHrpstring, }; use bech32::{Bech32, Bech32m, ByteIterExt, Fe32IterExt}; // This is a separate test because we correctly identify this string as invalid but not for the // reason given in the bip. #[test] fn bip_173_checksum_calculated_with_uppercase_form() { use bech32::primitives::decode::{CheckedHrpstringError, ChecksumError, SegwitHrpstringError}; // BIP-173 states reason for error should be: "checksum calculated with uppercase form of HRP". let s = "A1G7SGD8"; assert_eq!( CheckedHrpstring::new::(s).unwrap_err(), CheckedHrpstringError::Checksum(ChecksumError::InvalidResidue) ); assert_eq!( SegwitHrpstring::new(s).unwrap_err(), SegwitHrpstringError::Checksum(ChecksumError::InvalidResidue) ); } macro_rules! check_valid_bech32 { ($($test_name:ident, $valid_bech32:literal);* $(;)?) => { $( #[test] fn $test_name() { let p = UncheckedHrpstring::new($valid_bech32).unwrap(); p.validate_checksum::().expect("valid bech32"); // Valid bech32 strings are by definition invalid bech32m. assert_eq!(p.validate_checksum::().unwrap_err(), ChecksumError::InvalidResidue); } )* } } check_valid_bech32! { valid_bech32_hrp_string_0, "A12UEL5L"; valid_bech32_hrp_string_a, "a12uel5l"; valid_bech32_hrp_string_1, "an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1tt5tgs"; valid_bech32_hrp_string_2, "abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw"; valid_bech32_hrp_string_3, "11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j"; valid_bech32_hrp_string_4, "split1checkupstagehandshakeupstreamerranterredcaperred2y9e3w"; valid_bech32_hrp_string_b, "?1ezyfcl"; } macro_rules! check_valid_address_roundtrip { ($($test_name:ident, $addr:literal);* $(;)?) => { $( #[test] fn $test_name() { // We cannot use encode/decode for all test vectors because according to BIP-173 the // bech32 checksum algorithm can be used with any witness version, and this is // tested by the test vectors. However when BIP-350 came into effect only witness // version 0 uses bech32 (and this is enforced by encode/decode). if let Ok((hrp, bech32::Fe32::Q, program)) = bech32::segwit::decode($addr) { let encoded = bech32::segwit::encode_v0(hrp, &program).expect("failed to encode address"); // The bips specifically say that encoder should output lowercase characters so we uppercase manually. if encoded != $addr { let got = encoded.to_uppercase(); assert_eq!(got, $addr) } } let hrpstring = SegwitHrpstring::new_bech32($addr).expect("valid address"); let hrp = hrpstring.hrp(); let witness_version = hrpstring.witness_version(); let encoded = hrpstring.byte_iter().bytes_to_fes().with_checksum::(&hrp.into()).with_witness_version(witness_version).chars().collect::(); // The bips specifically say that encoder should output lowercase characters so we uppercase manually. if encoded != $addr { let got = encoded.to_uppercase(); assert_eq!(got, $addr) } } )* } } // Note these test vectors include various witness versions. check_valid_address_roundtrip! { bip_173_valid_address_roundtrip_0, "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4"; bip_173_valid_address_roundtrip_1, "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7"; bip_173_valid_address_roundtrip_2, "bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx"; bip_173_valid_address_roundtrip_3, "BC1SW50QA3JX3S"; bip_173_valid_address_roundtrip_4, "bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj"; bip_173_valid_address_roundtrip_5, "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy"; } macro_rules! check_invalid_address { ($($test_name:ident, $addr:literal);* $(;)?) => { $( #[test] #[cfg(feature = "alloc")] fn $test_name() { match SegwitHrpstring::new($addr) { Err(_) => {}, // We do not enforce the bip specified restrictions when constructing // SegwitHrpstring so must explicitly do check. Ok(segwit) => assert!(!segwit.has_valid_hrp()), } } )* } } check_invalid_address! { // Invalid human-readable part bip_173_invalid_address_0, "tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty"; // Invalid checksum bip_173_invalid_address_1, "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5"; // Invalid witness version bip_173_invalid_address_2, "BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2"; // Invalid program length bip_173_invalid_address_3, "bc1rw5uspcuh"; // Invalid program length bip_173_invalid_address_4, "bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90"; // Invalid program length for witness version 0 (per BIP-141) bip_173_invalid_address_5, "BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P"; // Mixed case bip_173_invalid_address_6, "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7"; // zero padding of more than 4 bits bip_173_invalid_address_7, "bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du"; // Non-zero padding in 8-to-5 conversion bip_173_invalid_address_8, "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv"; // Empty data section bip_173_invalid_address_14, "bc1gmk9yu"; } bech32-0.11.0/tests/bip_350_test_vectors.rs000064400000000000000000000134011046102023000164250ustar 00000000000000// BIP-350 test vectors. #![cfg(feature = "alloc")] use bech32::primitives::decode::{ CheckedHrpstring, CheckedHrpstringError, ChecksumError, SegwitHrpstring, SegwitHrpstringError, UncheckedHrpstring, }; use bech32::{Bech32, Bech32m}; // This is a separate test because we correctly identify this string as invalid but not for the // reason given in the bip. #[test] fn bip_350_checksum_calculated_with_uppercase_form() { // BIP-350 states reason for error should be: "checksum calculated with uppercase form of HRP". let s = "M1VUXWEZ"; assert_eq!( CheckedHrpstring::new::(s).unwrap_err(), CheckedHrpstringError::Checksum(ChecksumError::InvalidResidue) ); assert_eq!( SegwitHrpstring::new(s).unwrap_err(), SegwitHrpstringError::Checksum(ChecksumError::InvalidResidue) ); } macro_rules! check_valid_bech32m { ($($test_name:ident, $valid_bech32m:literal);* $(;)?) => { $( #[test] fn $test_name() { let p = UncheckedHrpstring::new($valid_bech32m).unwrap(); p.validate_checksum::().expect("valid bech32m"); // Valid bech32m strings are by definition invalid bech32. assert_eq!(p.validate_checksum::().unwrap_err(), ChecksumError::InvalidResidue); } )* } } check_valid_bech32m! { valid_bech32m_hrp_string_0, "A1LQFN3A"; valid_bech32m_hrp_string_1, "a1lqfn3a"; valid_bech32m_hrp_string_2, "an83characterlonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11sg7hg6"; valid_bech32m_hrp_string_3, "abcdef1l7aum6echk45nj3s0wdvt2fg8x9yrzpqzd3ryx"; valid_bech32m_hrp_string_4, "11llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllludsr8"; valid_bech32m_hrp_string_5, "split1checkupstagehandshakeupstreamerranterredcaperredlc445v"; valid_bech32m_hrp_string_6, "?1v759aa"; } macro_rules! check_valid_address_roundtrip { ($($test_name:ident, $addr:literal);* $(;)?) => { $( #[test] #[cfg(feature = "alloc")] fn $test_name() { let (hrp, version, program) = bech32::segwit::decode($addr).expect("failed to decode valid address"); let encoded = bech32::segwit::encode(hrp, version, &program).expect("failed to encode address"); // The bips specifically say that encoder should output lowercase characters so we uppercase manually. if encoded != $addr { let got = encoded.to_uppercase(); assert_eq!(got, $addr) } } )* } } // Note these test vectors include various witness versions. check_valid_address_roundtrip! { bip_350_valid_address_roundtrip_0, "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4"; bip_350_valid_address_roundtrip_1, "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7"; bip_350_valid_address_roundtrip_2, "bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kt5nd6y"; bip_350_valid_address_roundtrip_3, "BC1SW50QGDZ25J"; bip_350_valid_address_roundtrip_4, "bc1zw508d6qejxtdg4y5r3zarvaryvaxxpcs"; bip_350_valid_address_roundtrip_5, "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy"; bip_350_valid_address_roundtrip_6, "tb1pqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesf3hn0c"; bip_350_valid_address_roundtrip_7, "bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqzk5jj0"; } macro_rules! check_invalid_address { ($($test_name:ident, $addr:literal);* $(;)?) => { $( #[test] #[cfg(feature = "alloc")] fn $test_name() { match SegwitHrpstring::new($addr) { Err(_) => {}, // We do not enforce the bip specified restrictions when constructing // SegwitHrpstring so must explicitly do check. Ok(segwit) => assert!(!segwit.has_valid_hrp()), } } )* } } check_invalid_address! { // Invalid human-readable part bip_350_invalid_address_0, "tc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vq5zuyut"; // Invalid checksums (Bech32 instead of Bech32m): bip_350_invalid_address_1, "bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqh2y7hd"; bip_350_invalid_address_2, "tb1z0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqglt7rf"; bip_350_invalid_address_3, "BC1S0XLXVLHEMJA6C4DQV22UAPCTQUPFHLXM9H8Z3K2E72Q4K9HCZ7VQ54WELL"; bip_350_invalid_address_4, "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kemeawh"; bip_350_invalid_address_5, "tb1q0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vq24jc47"; // Invalid character in checksum bip_350_invalid_address_6, "bc1p38j9r5y49hruaue7wxjce0updqjuyyx0kh56v8s25huc6995vvpql3jow4"; // Invalid witness version bip_350_invalid_address_7, "BC130XLXVLHEMJA6C4DQV22UAPCTQUPFHLXM9H8Z3K2E72Q4K9HCZ7VQ7ZWS8R"; // Invalid program length (1 byte) bip_350_invalid_address_8, "bc1pw5dgrnzv"; // Invalid program length (41 bytes) bip_350_invalid_address_9, "bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7v8n0nx0muaewav253zgeav"; // Invalid program length for witness version 0 (per BIP-141) bip_350_invalid_address_10, "BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P"; // Mixed case bip_350_invalid_address_11, "tb1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vq47Zagq"; // zero padding of more than 4 bits bip_350_invalid_address_12, "bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7v07qwwzcrf"; // Non-zero padding in 8-to-5 conversion bip_350_invalid_address_13, "tb1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vpggkg4j"; // Empty data section bip_350_invalid_address_14, "bc1gmk9yu"; }