• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
        • Bip32
        • Bech32
          • Bech32-split-address
          • Bech32-hrp-expand
            • Valid-bech32-or-bech32m
            • Bech32-polymod-aux
            • Bech32-or-bech32m-verify-checksum
            • Bech32m-verify-checksum
            • Valid-bech32m
            • Valid-bech32
            • Bech32-verify-checksum
            • Bech32-collect-low-5-bits
            • Bech32-collect-high-3-bits
            • Bech32-polymod
            • Bech32-chars-to-octets
            • Hrp-valid-p
            • Mixed-case-stringp
            • Hrp-valid-string-length-p
            • Hrp-valid-char-code-p
            • *bech32-char-vals*
            • Bech32-index-of-last-1
            • *bech32m-const*
          • Bip39
          • Bip44
          • Base58
          • Bip43
          • Bytes
          • Base58check
          • Cryptography
          • Bip-350
          • Bip-173
        • Riscv
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Bech32

    Bech32-hrp-expand

    The stretching of the human-readable portion.

    Signature
    (bech32-hrp-expand s) → expanded-hrp
    Arguments
    s — Guard (stringp s).
    Returns
    expanded-hrp — Type (unsigned-byte-listp 8 expanded-hrp), given (and (warrant bvshr) (warrant bvand)).

    The hrp is converted to a list of ascii codes (octets) and then copied to make two lists. The first list shifts out all 5 low bits, leaving the 3 high bits of each code. The second list masks out the 3 high bits, leaving the low five bits of each code. Then the two lists are appended with a zero byte in between.

    Definitions and Theorems

    Function: bech32-hrp-expand

    (defun bech32-hrp-expand (s)
      (declare (xargs :guard (stringp s)))
      (let ((__function__ 'bech32-hrp-expand))
        (declare (ignorable __function__))
        (b* ((char-codes (string=>nats s))
             (high-bit-codes (bech32-collect-high-3-bits char-codes))
             (low-bit-codes (bech32-collect-low-5-bits char-codes)))
          (append high-bit-codes '(0)
                  low-bit-codes))))

    Theorem: return-type-of-bech32-hrp-expand

    (defthm return-type-of-bech32-hrp-expand
      (implies (and (warrant bvshr) (warrant bvand))
               (b* ((expanded-hrp (bech32-hrp-expand s)))
                 (unsigned-byte-listp 8 expanded-hrp)))
      :rule-classes :rewrite)