• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • C
        • Soft
        • Bv
        • Imp-language
        • Ethereum
        • Event-macros
        • Java
        • Riscv
        • Bitcoin
          • Bip32
          • Bech32
          • Bip39
          • Bip44
          • Base58
          • Bip43
            • Bip43-purpose
            • Bip43-export-key
            • Bip43-key-tree-has-purpose-p
              • Bip43-import-key
            • Bytes
            • Base58check
            • Cryptography
            • Bip-350
            • Bip-173
          • Zcash
          • Yul
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Axe
          • Lists-light
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Bip43

    Bip43-key-tree-has-purpose-p

    Check if a key tree includes a subtree for a given purpose.

    Signature
    (bip43-key-tree-has-purpose-p tree purpose) → yes/no
    Arguments
    tree — Guard (bip32-key-treep tree).
    purpose — Guard (bip43-purposep purpose).
    Returns
    yes/no — Type (booleanp yes/no).

    We check if the tree is rooted at the private master key and includes the singleton path with the (hardened) purpose number.

    Definitions and Theorems

    Function: bip43-key-tree-has-purpose-p

    (defun bip43-key-tree-has-purpose-p (tree purpose)
      (declare (xargs :guard (and (bip32-key-treep tree)
                                  (bip43-purposep purpose))))
      (and (bip32-key-tree-priv-p tree)
           (equal (bip32-key-tree->root-depth tree)
                  0)
           (b* ((purpose-hardened (+ (bip43-purpose-fix purpose)
                                     (expt 2 31))))
             (bip32-path-in-tree-p (list purpose-hardened)
                                   tree))))

    Theorem: booleanp-of-bip43-key-tree-has-purpose-p

    (defthm booleanp-of-bip43-key-tree-has-purpose-p
      (b* ((yes/no (bip43-key-tree-has-purpose-p tree purpose)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: bip43-key-tree-has-purpose-p-of-bip32-key-tree-fix-tree

    (defthm bip43-key-tree-has-purpose-p-of-bip32-key-tree-fix-tree
      (equal (bip43-key-tree-has-purpose-p (bip32-key-tree-fix tree)
                                           purpose)
             (bip43-key-tree-has-purpose-p tree purpose)))

    Theorem: bip43-key-tree-has-purpose-p-bip32-key-tree-equiv-congruence-on-tree

    (defthm
     bip43-key-tree-has-purpose-p-bip32-key-tree-equiv-congruence-on-tree
     (implies (bip32-key-tree-equiv tree tree-equiv)
              (equal (bip43-key-tree-has-purpose-p tree purpose)
                     (bip43-key-tree-has-purpose-p tree-equiv purpose)))
     :rule-classes :congruence)

    Theorem: bip43-key-tree-has-purpose-p-of-bip43-purpose-fix-purpose

    (defthm bip43-key-tree-has-purpose-p-of-bip43-purpose-fix-purpose
     (equal
         (bip43-key-tree-has-purpose-p tree (bip43-purpose-fix purpose))
         (bip43-key-tree-has-purpose-p tree purpose)))

    Theorem: bip43-key-tree-has-purpose-p-bip43-purpose-equiv-congruence-on-purpose

    (defthm
     bip43-key-tree-has-purpose-p-bip43-purpose-equiv-congruence-on-purpose
     (implies (bip43-purpose-equiv purpose purpose-equiv)
              (equal (bip43-key-tree-has-purpose-p tree purpose)
                     (bip43-key-tree-has-purpose-p tree purpose-equiv)))
     :rule-classes :congruence)