Check if a key path is valid for the wallet.
(valid-key-path-p path addresses) → yes/no
All the key paths in the wallet must have the form
m / 44' / 60' / 0' / 0 / address_index
where
This predicate checks if a path has one of these forms.
Function:
(defun valid-key-path-p (path addresses) (declare (xargs :guard (and (ubyte32-listp path) (natp addresses)))) (b* (((when (atom path)) t) ((unless (= (car path) *purpose-index*)) nil) (path (cdr path)) ((when (atom path)) t) ((unless (= (car path) *coin-type-index*)) nil) (path (cdr path)) ((when (atom path)) t) ((unless (= (car path) *account-index*)) nil) (path (cdr path)) ((when (atom path)) t) ((unless (= (car path) *external-chain-index*)) nil) (path (cdr path)) ((when (atom path)) t) ((unless (< (car path) addresses)) nil) (path (cdr path))) (atom path)))
Theorem:
(defthm booleanp-of-valid-key-path-p (b* ((yes/no (valid-key-path-p path addresses))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm valid-key-path-p-of-next-key-path-under-1+-addresses (valid-key-path-p (rcons addresses *key-path-prefix*) (1+ addresses)))
Theorem:
(defthm valid-key-path-p-of-1+-addresses (implies (valid-key-path-p path addresses) (valid-key-path-p path (1+ addresses))))