• 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
        • Bip39
        • Bip44
        • Base58
        • Bip43
          • Bip43-purpose
            • Bip43-purpose-fix
            • Bip43-purposep
          • Bip43-export-key
          • Bip43-key-tree-has-purpose-p
          • Bip43-import-key
        • 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
  • Bip43

Bip43-purpose

Purposes.

[BIP43] recommends to index of the first level of a BIP 32 key tree as an indication of ``purpose''. We introduce a fixtype for the possible values of this index.

[BIP43] uses an apostrophe to indicate that the purpose key should be hardened. Therefore, the purpose number should be below 2^{31}, so that it can be increased by that amount to indicate a hardened key.

[BIP43] also states that number 0 is already taken by BIP 32 to indicate a default account. Thus, it seems reasonable to exclude 0 from the set of acceptable purpose numbers.

Definitions and Theorems

Function: bip43-purposep

(defun bip43-purposep (x)
  (declare (xargs :guard t))
  (integer-range-p 1 (expt 2 31) x))

Theorem: booleanp-of-bip43-purposep

(defthm booleanp-of-bip43-purposep
  (b* ((yes/no (bip43-purposep x)))
    (booleanp yes/no))
  :rule-classes :rewrite)

Function: bip43-purpose-fix

(defun bip43-purpose-fix (x)
  (declare (xargs :guard (bip43-purposep x)))
  (mbe :logic (if (bip43-purposep x) x 1)
       :exec x))

Theorem: bip43-purposep-of-bip43-purpose-fix

(defthm bip43-purposep-of-bip43-purpose-fix
  (b* ((fixed-x (bip43-purpose-fix x)))
    (bip43-purposep fixed-x))
  :rule-classes :rewrite)

Theorem: bip43-purpose-fix-when-bip43-purposep

(defthm bip43-purpose-fix-when-bip43-purposep
  (implies (bip43-purposep x)
           (equal (bip43-purpose-fix x) x)))

Function: bip43-purpose-equiv$inline

(defun bip43-purpose-equiv$inline (acl2::x acl2::y)
  (declare (xargs :guard (and (bip43-purposep acl2::x)
                              (bip43-purposep acl2::y))))
  (equal (bip43-purpose-fix acl2::x)
         (bip43-purpose-fix acl2::y)))

Theorem: bip43-purpose-equiv-is-an-equivalence

(defthm bip43-purpose-equiv-is-an-equivalence
  (and (booleanp (bip43-purpose-equiv x y))
       (bip43-purpose-equiv x x)
       (implies (bip43-purpose-equiv x y)
                (bip43-purpose-equiv y x))
       (implies (and (bip43-purpose-equiv x y)
                     (bip43-purpose-equiv y z))
                (bip43-purpose-equiv x z)))
  :rule-classes (:equivalence))

Theorem: bip43-purpose-equiv-implies-equal-bip43-purpose-fix-1

(defthm bip43-purpose-equiv-implies-equal-bip43-purpose-fix-1
  (implies (bip43-purpose-equiv acl2::x x-equiv)
           (equal (bip43-purpose-fix acl2::x)
                  (bip43-purpose-fix x-equiv)))
  :rule-classes (:congruence))

Theorem: bip43-purpose-fix-under-bip43-purpose-equiv

(defthm bip43-purpose-fix-under-bip43-purpose-equiv
  (bip43-purpose-equiv (bip43-purpose-fix acl2::x)
                       acl2::x)
  :rule-classes (:rewrite :rewrite-quoted-constant))

Theorem: equal-of-bip43-purpose-fix-1-forward-to-bip43-purpose-equiv

(defthm equal-of-bip43-purpose-fix-1-forward-to-bip43-purpose-equiv
  (implies (equal (bip43-purpose-fix acl2::x)
                  acl2::y)
           (bip43-purpose-equiv acl2::x acl2::y))
  :rule-classes :forward-chaining)

Theorem: equal-of-bip43-purpose-fix-2-forward-to-bip43-purpose-equiv

(defthm equal-of-bip43-purpose-fix-2-forward-to-bip43-purpose-equiv
  (implies (equal acl2::x (bip43-purpose-fix acl2::y))
           (bip43-purpose-equiv acl2::x acl2::y))
  :rule-classes :forward-chaining)

Theorem: bip43-purpose-equiv-of-bip43-purpose-fix-1-forward

(defthm bip43-purpose-equiv-of-bip43-purpose-fix-1-forward
  (implies (bip43-purpose-equiv (bip43-purpose-fix acl2::x)
                                acl2::y)
           (bip43-purpose-equiv acl2::x acl2::y))
  :rule-classes :forward-chaining)

Theorem: bip43-purpose-equiv-of-bip43-purpose-fix-2-forward

(defthm bip43-purpose-equiv-of-bip43-purpose-fix-2-forward
  (implies (bip43-purpose-equiv acl2::x (bip43-purpose-fix acl2::y))
           (bip43-purpose-equiv acl2::x acl2::y))
  :rule-classes :forward-chaining)

Subtopics

Bip43-purpose-fix
Fixer for bip43-purpose.
Bip43-purposep
Recognizer for bip43-purpose.