Build a message that describes a (signed) transaction.
(transaction-message transaction) → msg
When signing a transaction, the signed transaction (a list of bytes) must be submitted to the Ethereum network. Since this wallet is meant to run on an air-gapped machine, the transaction must be copied to a connected machine for submission. Thus, the command to sign the transaction must show it on the screen.
This function builds a message that consists of all the bytes, each in hex form, separated by single spaces, 16 bytes per line, each line indented by two spaces. In fact, this function handles any list of bytes, not just specifically signed transactions.
Function:
(defun transaction-message-line-aux (bytes) (declare (xargs :guard (byte-listp bytes))) (cond ((endp bytes) "") (t (cat " " (ubyte8s=>hexstring (list (car bytes))) (transaction-message-line-aux (cdr bytes))))))
Theorem:
(defthm stringp-of-transaction-message-line-aux (b* ((string (transaction-message-line-aux bytes))) (stringp string)) :rule-classes :rewrite)
Function:
(defun transaction-message-line (bytes) (declare (xargs :guard (byte-listp bytes))) (declare (xargs :guard (consp bytes))) (msg " ~@0~%" (transaction-message-line-aux bytes)))
Theorem:
(defthm msgp-of-transaction-message-line (b* ((msg (transaction-message-line bytes))) (msgp msg)) :rule-classes :rewrite)
Function:
(defun transaction-message (transaction) (declare (xargs :guard (byte-listp transaction))) (cond ((endp transaction) "") ((< (len transaction) 16) (transaction-message-line transaction)) (t (msg "~@0~@1" (transaction-message-line (take 16 transaction)) (transaction-message (nthcdr 16 transaction))))))
Theorem:
(defthm msgp-of-transaction-message (b* ((msg (transaction-message transaction))) (msgp msg)) :rule-classes :rewrite)