• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • C
      • Proof-checker-array
      • Soft
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Ethereum
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • 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
        • Des
        • X86isa
        • Sha-2
        • Yul
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Axe
        • Poseidon
        • Where-do-i-place-my-book
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • 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)