Check if all the derived keys in a (tree's) set of paths are valid.
Given a root key, every path in a tree must correspond to a valid key. That is, all the key derivations along the path must be valid.
This function checks this condition. This function is used to define key trees later.
Even though this function is applied to index trees, it can be defined on general sets of paths.
We introduce this function as a constrained function,
so that we can make an executable attachment for it
(in
The singleton tree consisting of just the root (represented as the singleton set consisting of the empty path) trivially satisfies this key validity condition.
Extending a path of an index tree preserves the validity of the keys, provided that the key at the end of the new extended path is valid.
The tail of a set of paths with valid keys also has all valid keys.
Theorem:
(defthm bip32-valid-keys-p-definition (equal (bip32-valid-keys-p root paths) (let ((path (bip32-valid-keys-p-witness root paths))) (implies (in path (bip32-path-sfix paths)) (not (mv-nth 0 (bip32-ckd* root path)))))) :rule-classes :definition)
Theorem:
(defthm booleanp-of-bip32-valid-keys-p (booleanp (bip32-valid-keys-p root paths)) :rule-classes (:rewrite :type-prescription))
Theorem:
(defthm bip32-valid-keys-p-necc (implies (bip32-valid-keys-p root paths) (implies (in path (bip32-path-sfix paths)) (not (mv-nth 0 (bip32-ckd* root path))))))
Theorem:
(defthm bip32-valid-keys-p-of-bip32-ext-key-fix-root (equal (bip32-valid-keys-p (bip32-ext-key-fix root) paths) (bip32-valid-keys-p root paths)))
Theorem:
(defthm bip32-valid-keys-p-bip32-ext-key-equiv-congruence-on-root (implies (bip32-ext-key-equiv root root-equiv) (equal (bip32-valid-keys-p root paths) (bip32-valid-keys-p root-equiv paths))) :rule-classes :congruence)
Theorem:
(defthm bip32-valid-keys-p-of-bip32-path-sfix-paths (equal (bip32-valid-keys-p root (bip32-path-sfix paths)) (bip32-valid-keys-p root paths)))
Theorem:
(defthm bip32-valid-keys-p-bip32-path-set-equiv-congruence-on-paths (implies (bip32-path-set-equiv paths paths-equiv) (equal (bip32-valid-keys-p root paths) (bip32-valid-keys-p root paths-equiv))) :rule-classes :congruence)
Theorem:
(defthm bip32-valid-keys-p-of-singleton-empty-path (bip32-valid-keys-p root '(nil)))
Theorem:
(defthm bip32-valid-keys-p-of-insert-of-rcons (implies (and (bip32-path-setp paths) (bip32-valid-keys-p root paths) (in path paths) (ubyte32p index) (not (mv-nth 0 (bip32-ckd* root (rcons index path))))) (bip32-valid-keys-p root (insert (rcons index path) paths))))
Theorem:
(defthm bip32-valid-keys-p-of-tail (implies (and (bip32-path-setp paths) (bip32-valid-keys-p root paths)) (bip32-valid-keys-p root (tail paths))))