Import a key into a tree.
(bip32-import-key bytes) → (mv error? tree mainnet?)
We deserialize the key into its components, which we use to construct a singleton key tree that contains just that key.
The boolean flag that distinguishes mainnet from testnet, returned by serialization, is not used to construct the tree. We return this flag as an additional result.
If deserialization fails,
the first result is
Function:
(defun bip32-import-key (bytes) (declare (xargs :guard (byte-listp bytes))) (b* (((mv error? key depth index parent mainnet?) (bip32-deserialize-key bytes)) (tree (bip32-key-tree key depth index parent '(nil)))) (mv error? tree mainnet?)))
Theorem:
(defthm booleanp-of-bip32-import-key.error? (b* (((mv ?error? ?tree ?mainnet?) (bip32-import-key bytes))) (booleanp error?)) :rule-classes :rewrite)
Theorem:
(defthm bip32-key-treep-of-bip32-import-key.tree (b* (((mv ?error? ?tree ?mainnet?) (bip32-import-key bytes))) (bip32-key-treep tree)) :rule-classes :rewrite)
Theorem:
(defthm booleanp-of-bip32-import-key.mainnet? (b* (((mv ?error? ?tree ?mainnet?) (bip32-import-key bytes))) (booleanp mainnet?)) :rule-classes :rewrite)
Theorem:
(defthm bip32-import-key-of-byte-list-fix-bytes (equal (bip32-import-key (byte-list-fix bytes)) (bip32-import-key bytes)))
Theorem:
(defthm bip32-import-key-byte-list-equiv-congruence-on-bytes (implies (byte-list-equiv bytes bytes-equiv) (equal (bip32-import-key bytes) (bip32-import-key bytes-equiv))) :rule-classes :congruence)