Skip to content

feat(near): NEAR Protocol native support#245

Open
BitHighlander wants to merge 1 commit into
alphafrom
near-spike
Open

feat(near): NEAR Protocol native support#245
BitHighlander wants to merge 1 commit into
alphafrom
near-spike

Conversation

@BitHighlander
Copy link
Copy Markdown
Owner

Summary

  • Add Ed25519 key derivation and address generation for NEAR Protocol (m/44'/397'/0', SLIP-0010 hardened)
  • Add NearGetAddress and NearSignTx FSM handlers with on-device confirmation screen
  • Address format: lowercase hex of 32-byte Ed25519 public key (NEAR implicit account standard)
  • Signing: Ed25519(SHA256(borsh_serialized_tx)) — host Borsh-serializes, firmware signs
  • Wire messagemap.def, coins.def (coin type 397, 24 decimals), transport CMakeLists nanopb compile step
  • No Borsh parser in firmware: host sends raw_tx bytes + receiver_id/action_display strings for confirmation display

Files changed

File Purpose
lib/firmware/near.c Address encoding + signing implementation
include/keepkey/firmware/near.h Public API
lib/firmware/fsm_msg_near.h FSM handlers
lib/firmware/fsm.c Include wiring
include/keepkey/firmware/fsm.h Forward declarations
lib/firmware/messagemap.def Message dispatch
lib/firmware/CMakeLists.txt Source list
lib/transport/CMakeLists.txt nanopb proto compile
include/keepkey/transport/messages-near.options nanopb size constraints
include/keepkey/firmware/coins.def NEAR coin entry

Proto dependency

messages-near.proto with NearGetAddress / NearAddress / NearSignTx / NearSignedTx at MessageType 1600–1603 is on feature/near-proto in device-protocol — that should land first so the nanopb step resolves at build time.

Test plan

  • NearGetAddress at m/44'/397'/0' returns 64-char lowercase hex pubkey
  • Same path returns deterministic address across sessions
  • NearSignTx shows receiver_id + action_display on OLED before signing
  • Button cancel returns ActionCancelled failure
  • Returned 64-byte signature verifies against pubkey with ed25519_sign_open
  • Test vector: sign known Borsh-serialized tx, compare to NEAR reference SDK output

…+sign)

- messages-near.proto MessageTypes 1600-1603 (via device-protocol feature/near-proto)
- near.c: Ed25519 key derivation (SLIP-0010 coin type 397), hex implicit address, SHA256+Ed25519 signing
- fsm_msg_near.h: NearGetAddress + NearSignTx handlers wired into FSM
- messagemap.def, fsm.h, fsm.c: registration + forward decls
- lib/transport/CMakeLists.txt: nanopb compile step for messages-near.proto
- coins.def: NEAR entry (ed25519, decimals=24, BIP44 0x8000018D)
- coins.c: isNear() added to isAccountBased()
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