Skip to content

test(hive): vendored SLIP-0048 multi-key + account-op device tests#21

Merged
BitHighlander merged 2 commits into
masterfrom
feat/hive-tests
Jun 26, 2026
Merged

test(hive): vendored SLIP-0048 multi-key + account-op device tests#21
BitHighlander merged 2 commits into
masterfrom
feat/hive-tests

Conversation

@BitHighlander

Copy link
Copy Markdown
Owner

Summary

Adds the missing Hive device-test coverage. Hive was the one alpha-firmware feature with full firmware + proto + python-client support and zero tests (90-file suite, none for Hive).

tests/test_msg_hive.py covers all 5 firmware Hive handlers using the standard 12-word seed (mnemonic12, "alcohol … aisle") via setup_mnemonic_nopin_nopassphrase():

Test Message Assertion
get_public_key (active) HiveGetPublicKey STM format + 33-byte compressed raw
get_public_keys HiveGetPublicKeys 4 distinct STM keys; single/bulk agreement
sign_transfer HiveSignTx (op 2) sig recovers to active key
sign_account_create HiveSignAccountCreate (op 9) sig recovers to owner key; 4 keys + name bound into bytes
sign_account_update HiveSignAccountUpdate (op 10) sig recovers to owner key

Why recovery-based

The account-op tests are self-validating and non-circular: they recompute SHA256(chain_id ‖ serialized_tx), recover the signer from the 65-byte device signature (recid = sig[0]-31), and assert it equals the device-derived key. This exercises the device and validates the sponsor-side attestation contract (keepkey-vault docs/HIVE-ATTESTATION-DIGEST-SPEC.md) — no precomputed golden vector needed.

The recovery helper was validated offline against a self-generated firmware-format signature (header byte 27+recid+4) before use.

Notes

  • Requires a device/emulator to run (loads the test seed) — for CI emulator / firmware test runs.
  • Targets the fork (BitHighlander/python-keepkey) master, which firmware pins.
  • A captured golden {signature, serialized_tx} vector can be pinned later from an emulator run (spec §8); the recovery assertions already validate correctness without it.

Covers the full Hive message surface (all 5 firmware handlers) using the
standard 12-word seed (mnemonic12, "alcohol ... aisle"):
- HiveGetPublicKey   — active-role key format + 33-byte raw
- HiveGetPublicKeys  — 4 distinct STM role keys; single/bulk agreement
- HiveSignTx         — transfer (op 2), signature recovers to active key
- HiveSignAccountCreate — account_create (op 9), recovers to owner key + binds
  the 4 device keys and account name into the signed bytes
- HiveSignAccountUpdate — account_update (op 10), recovers to owner key

Account-op tests are self-validating: they recover the signer from the 65-byte
device signature over SHA256(chain_id || serialized_tx) and assert it equals
the device-derived key — exercising the device and validating the attestation
digest (keepkey-vault docs/HIVE-ATTESTATION-DIGEST-SPEC.md). No golden vector
required; recovery is an independent check. Hive was the one alpha-firmware
feature with full firmware+client support and zero test coverage.
Addresses review: substring-presence was too weak — a role swap (both keys
present), a creator rewrite, or an amount change could still pass.

Add a cursor-based Graphene reader matching the firmware append_* layout exactly
(incl. account_update's 0x01 optional-present flags, asset symbol padding, and
the no-wrapper memo_key) and rewrite all three signing tests to parse and assert
each field at its expected position + assert_end() for no trailing bytes:
- transfer: from / to / amount / precision / symbol / memo
- account_create: fee / creator / name / owner|active|posting authority slots / memo_key
- account_update: account / each replacement key in its slot / memo_key

Recovery assertions retained. Parser validated offline against hand-built
firmware-format bytes.
@BitHighlander
BitHighlander merged commit 7388ae2 into master Jun 26, 2026
3 of 4 checks passed
@BitHighlander
BitHighlander deleted the feat/hive-tests branch June 26, 2026 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant