• 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

    Valid-bech32

    Check if address is valid Bech32.

    Signature
    (valid-bech32 address) → y/n
    Arguments
    address — Guard (stringp address).
    Returns
    y/n — Type (booleanp y/n).

    Verifies that address is a valid Bech32 string.

    Disallows a mixed-case string; then downcases the string before converting the data characters to bytes and verifying the checksum.

    Definitions and Theorems

    Function: valid-bech32

    (defun valid-bech32 (address)
      (declare (xargs :guard (stringp address)))
      (let ((__function__ 'valid-bech32))
        (declare (ignorable __function__))
        (b* (((when (mixed-case-stringp address))
              nil)
             (address (str::downcase-string address))
             ((mv erp hrp data)
              (bech32-split-address address))
             ((when erp) nil))
          (bech32-verify-checksum hrp data))))

    Theorem: booleanp-of-valid-bech32

    (defthm booleanp-of-valid-bech32
      (b* ((y/n (valid-bech32 address)))
        (booleanp y/n))
      :rule-classes :rewrite)