Check if a sequence of bytes is a serialized extended key.
This is a declarative, non-executable definition, which essentially characterizes the image of bip32-serialize-key over arguments that satisfy that function's guard.
By definition, the witness function is the right inverse of bip32-serialize-key, over valid serialized keys.
Theorem:
(defthm bip32-serialized-key-p-suff (implies (and (bip32-ext-key-p key) (bytep depth) (ubyte32p index) (byte-listp parent) (equal (len parent) 4) (booleanp mainnet?) (if (equal depth 0) (if (and (equal index 0) (equal parent (list 0 0 0 0))) t nil) t) (equal (bip32-serialize-key key depth index parent mainnet?) (byte-list-fix bytes))) (bip32-serialized-key-p bytes)))
Theorem:
(defthm booleanp-of-bip32-serialized-key-p (b* ((yes/no (bip32-serialized-key-p bytes))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm bip32-serialized-key-p-of-byte-list-fix-bytes (equal (bip32-serialized-key-p (byte-list-fix bytes)) (bip32-serialized-key-p bytes)))
Theorem:
(defthm bip32-serialized-key-p-byte-list-equiv-congruence-on-bytes (implies (byte-list-equiv bytes bytes-equiv) (equal (bip32-serialized-key-p bytes) (bip32-serialized-key-p bytes-equiv))) :rule-classes :congruence)
Theorem:
(defthm bip32-ext-key-p-of-mv-nth-0-of-bip32-serialized-key-witness (implies (bip32-serialized-key-p bytes) (bip32-ext-key-p (mv-nth 0 (bip32-serialized-key-witness bytes)))))
Theorem:
(defthm bytep-of-mv-nth-1-of-bip32-serialized-key-witness (implies (bip32-serialized-key-p bytes) (bytep (mv-nth 1 (bip32-serialized-key-witness bytes)))))
Theorem:
(defthm ubyte32p-of-mv-nth-2-of-bip32-serialized-key-witness (implies (bip32-serialized-key-p bytes) (ubyte32p (mv-nth 2 (bip32-serialized-key-witness bytes)))))
Theorem:
(defthm byte-listp-of-mv-nth-3-of-bip32-serialized-key-witness (implies (bip32-serialized-key-p bytes) (byte-listp (mv-nth 3 (bip32-serialized-key-witness bytes)))))
Theorem:
(defthm len-of-mv-nth-3-of-bip32-serialize-key-witness (implies (bip32-serialized-key-p bytes) (equal (len (mv-nth 3 (bip32-serialized-key-witness bytes))) 4)))
Theorem:
(defthm booleanp-of-mv-nth-4-of-bip32-serialized-key-witness (implies (bip32-serialized-key-p bytes) (booleanp (mv-nth 4 (bip32-serialized-key-witness bytes)))))
Theorem:
(defthm depth-index-parent-constraint-of-bip32-serialized-key-witness (implies (and (bip32-serialized-key-p bytes) (equal (mv-nth 1 (bip32-serialized-key-witness bytes)) 0)) (and (equal (mv-nth 2 (bip32-serialized-key-witness bytes)) 0) (equal (mv-nth 3 (bip32-serialized-key-witness bytes)) (list 0 0 0 0)))))
Theorem:
(defthm bip32-serialize-key-of-bip32-serialized-key-witness (implies (bip32-serialized-key-p bytes) (b* (((mv key depth index parent mainnet?) (bip32-serialized-key-witness bytes))) (equal (bip32-serialize-key key depth index parent mainnet?) (byte-list-fix bytes)))))
Theorem:
(defthm bip32-serialized-key-p-of-bip32-serialize-key (implies (and (bip32-ext-key-p key) (bytep depth) (ubyte32p index) (byte-listp parent) (equal (len parent) 4) (booleanp mainnet?) (implies (equal depth 0) (and (equal index 0) (equal parent (list 0 0 0 0))))) (bip32-serialized-key-p (bip32-serialize-key key depth index parent mainnet?))))