Chain codes.
A chain code consists of 32 bytes. Chain codes are used in both extended private and public keys.
Function:
(defun bip32-chain-code-p (x) (declare (xargs :guard t)) (and (byte-listp x) (equal (len x) 32)))
Theorem:
(defthm booleanp-of-bip32-chain-code-p (b* ((yes/no (bip32-chain-code-p x))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm byte-listp-when-bip32-chain-code-p (implies (bip32-chain-code-p cc) (byte-listp cc)))
Theorem:
(defthm len-when-bip32-chain-code-p (implies (bip32-chain-code-p x) (equal (len x) 32)) :rule-classes :tau-system)
Function:
(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:
(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:
(defthm bip32-chain-code-fix-when-bip32-chain-code-p (implies (bip32-chain-code-p x) (equal (bip32-chain-code-fix x) x)))
Function:
(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:
(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:
(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:
(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:
(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:
(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:
(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:
(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)