• 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
          • Bip32-wallet-structure
          • Bip32-key-trees
          • Bip32-key-serialization
          • Bip32-key-derivation
          • Bip32-executable-attachments
          • Bip32-extended-keys
            • Bip32-chain-code
              • Bip32-chain-code-p
              • Bip32-chain-code-fix
            • Bip32-ext-pub-key
            • Bip32-ext-priv-key
            • Bip32-ext-key
          • Bip32-master-key-generation
        • Bech32
        • 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
  • Bip32-extended-keys

Bip32-chain-code

Chain codes.

A chain code consists of 32 bytes. Chain codes are used in both extended private and public keys.

Definitions and Theorems

Function: bip32-chain-code-p

(defun bip32-chain-code-p (x)
  (declare (xargs :guard t))
  (and (byte-listp x) (equal (len x) 32)))

Theorem: booleanp-of-bip32-chain-code-p

(defthm booleanp-of-bip32-chain-code-p
  (b* ((yes/no (bip32-chain-code-p x)))
    (booleanp yes/no))
  :rule-classes :rewrite)

Theorem: byte-listp-when-bip32-chain-code-p

(defthm byte-listp-when-bip32-chain-code-p
  (implies (bip32-chain-code-p cc)
           (byte-listp cc)))

Theorem: len-when-bip32-chain-code-p

(defthm len-when-bip32-chain-code-p
  (implies (bip32-chain-code-p x)
           (equal (len x) 32))
  :rule-classes :tau-system)

Function: bip32-chain-code-fix

(defun bip32-chain-code-fix (x)
  (declare (xargs :guard (bip32-chain-code-p x)))
  (mbe :logic
       (if (bip32-chain-code-p x)
           x
         (repeat 32 0))
       :exec x))

Theorem: bip32-chain-code-p-of-bip32-chain-code-fix

(defthm bip32-chain-code-p-of-bip32-chain-code-fix
  (b* ((fixed-x (bip32-chain-code-fix x)))
    (bip32-chain-code-p fixed-x))
  :rule-classes :rewrite)

Theorem: bip32-chain-code-fix-when-bip32-chain-code-p

(defthm bip32-chain-code-fix-when-bip32-chain-code-p
  (implies (bip32-chain-code-p x)
           (equal (bip32-chain-code-fix x) x)))

Function: bip32-chain-code-equiv$inline

(defun bip32-chain-code-equiv$inline (acl2::x acl2::y)
  (declare (xargs :guard (and (bip32-chain-code-p acl2::x)
                              (bip32-chain-code-p acl2::y))))
  (equal (bip32-chain-code-fix acl2::x)
         (bip32-chain-code-fix acl2::y)))

Theorem: bip32-chain-code-equiv-is-an-equivalence

(defthm bip32-chain-code-equiv-is-an-equivalence
  (and (booleanp (bip32-chain-code-equiv x y))
       (bip32-chain-code-equiv x x)
       (implies (bip32-chain-code-equiv x y)
                (bip32-chain-code-equiv y x))
       (implies (and (bip32-chain-code-equiv x y)
                     (bip32-chain-code-equiv y z))
                (bip32-chain-code-equiv x z)))
  :rule-classes (:equivalence))

Theorem: bip32-chain-code-equiv-implies-equal-bip32-chain-code-fix-1

(defthm bip32-chain-code-equiv-implies-equal-bip32-chain-code-fix-1
  (implies (bip32-chain-code-equiv acl2::x x-equiv)
           (equal (bip32-chain-code-fix acl2::x)
                  (bip32-chain-code-fix x-equiv)))
  :rule-classes (:congruence))

Theorem: bip32-chain-code-fix-under-bip32-chain-code-equiv

(defthm bip32-chain-code-fix-under-bip32-chain-code-equiv
  (bip32-chain-code-equiv (bip32-chain-code-fix acl2::x)
                          acl2::x)
  :rule-classes (:rewrite :rewrite-quoted-constant))

Theorem: equal-of-bip32-chain-code-fix-1-forward-to-bip32-chain-code-equiv

(defthm
  equal-of-bip32-chain-code-fix-1-forward-to-bip32-chain-code-equiv
  (implies (equal (bip32-chain-code-fix acl2::x)
                  acl2::y)
           (bip32-chain-code-equiv acl2::x acl2::y))
  :rule-classes :forward-chaining)

Theorem: equal-of-bip32-chain-code-fix-2-forward-to-bip32-chain-code-equiv

(defthm
  equal-of-bip32-chain-code-fix-2-forward-to-bip32-chain-code-equiv
  (implies (equal acl2::x (bip32-chain-code-fix acl2::y))
           (bip32-chain-code-equiv acl2::x acl2::y))
  :rule-classes :forward-chaining)

Theorem: bip32-chain-code-equiv-of-bip32-chain-code-fix-1-forward

(defthm bip32-chain-code-equiv-of-bip32-chain-code-fix-1-forward
  (implies (bip32-chain-code-equiv (bip32-chain-code-fix acl2::x)
                                   acl2::y)
           (bip32-chain-code-equiv acl2::x acl2::y))
  :rule-classes :forward-chaining)

Theorem: bip32-chain-code-equiv-of-bip32-chain-code-fix-2-forward

(defthm bip32-chain-code-equiv-of-bip32-chain-code-fix-2-forward
 (implies
     (bip32-chain-code-equiv acl2::x (bip32-chain-code-fix acl2::y))
     (bip32-chain-code-equiv acl2::x acl2::y))
 :rule-classes :forward-chaining)

Subtopics

Bip32-chain-code-p
Recognizer for bip32-chain-code.
Bip32-chain-code-fix
Fixer for bip32-chain-code.