- V2 Transaction Format: Analyzed current Sia V2 transaction specifications post-hardfork
- Cryptographic Requirements: Ed25519 signatures, Blake2b hashing, BIP44 derivation with coin type 1991
- API Integration: Studied current Sia protocol specifications
- Firmware: Selected
trezor-cryptofor Ed25519/Blake2b operations (audited, embedded-optimized) - Protocol: Identified need for custom V2 transaction parsing due to memory constraints
Initial Challenge: During research phase, we discovered that official walletd infrastructure recommended in Sia documentation was not publicly accessible for development and testing purposes.
Research Response: Conducted comprehensive API analysis to identify alternative blockchain interaction methods. Collaborated with Sia Foundation team who provided access to Siascan's production APIs as a viable integration target.
API Requirements Analysis & Validation:
Researched and tested all blockchain operations required for full wallet functionality:
| Operation | Endpoint | Validation Status | Purpose |
|---|---|---|---|
| Balance Check | GET /addresses/{addr}/balance |
✓ Tested | Portfolio display |
| UTXO Retrieval | GET /addresses/{addr}/outputs/siacoin |
✓ Tested | Transaction construction |
| Transaction History | GET /addresses/{addr}/events |
✓ Tested | Transaction list |
| Pending Transactions | GET /addresses/{addr}/events/unconfirmed |
✓ Tested | Mempool status |
| Transaction Details | GET /events/{txid} |
✓ Tested | Detailed transaction view |
| Fee Estimation | GET /txpool/fee |
✓ Tested | Dynamic fee calculation |
| Network Status | GET /consensus/network |
✓ Tested | Network connectivity |
| Blockchain Tip | GET /consensus/tip |
✓ Tested | Confirmation tracking |
| Transaction Broadcasting | POST /txpool/broadcast |
✓ Tested | Post-signing submission |
Key Research Findings:
- All APIs confirmed compatible with V2 transaction format
- Response formats provide necessary data fields for wallet implementation
- Broadcasting endpoint accepts V2 transaction structure as documented
- Fee estimation API provides real-time network fee data for optimal user experience
Integration Decision: Siascan APIs provide complete coverage for all required wallet operations, enabling full Sia integration without dependency on self-hosted walletd infrastructure.
1. Firmware Integration: x1_wallet_firmware
Following the existing XRP app pattern:
apps/sia_app/
├── sia_api.c
├── sia_api.h
├── sia_context.h
├── sia_helpers.c
├── sia_helpers.h
├── sia_main.c
├── sia_main.h
├── sia_priv.h
├── sia_pub_key.c
├── sia_txn_helpers.c
├── sia_txn_helpers.h
└── sia_txn.c
common/proto-options/sia/
├── core.options
├── error.options
├── get_public_key.options
└── sign_txn.options
2. Protocol Definitions: cypherock-common
proto/sia/
├── core.proto
├── get_public_keys.proto
└── sign_txn.proto
Firmware Application Files (apps/sia_app/):
- API Layer (
sia_api.c/h): Device communication handlers for host requests - Context Management (
sia_context.h): State management and transaction context storage - Cryptographic Operations (
sia_helpers.c/h): Ed25519 key derivation, address generation using trezor-crypto - Main Logic (
sia_main.c/h): Application entry points and command routing - Private Definitions (
sia_priv.h): Internal constants and private function declarations - Public Key Operations (
sia_pub_key.c): BIP44 key derivation and address generation - Transaction Processing (
sia_txn.c,sia_txn_helpers.c/h): UTXO-based transaction parsing and signing
Protocol Buffer Files:
- Core Definitions (
core.proto): Basic data structures and error handling - Address Generation (
get_public_keys.proto): Public key derivation and address requests - Transaction Signing (
sign_txn.proto): Transaction data structures and signing requests - Options Files (
.options): Protocol buffer compilation settings for embedded constraints
Technical Challenge: The firmware implementation represents the most complex aspect of Sia integration. Unlike host-side software that can leverage existing libraries and APIs, the hardware wallet operates in an extremely constrained environment:
- No External Libraries: Cannot utilize high-level Sia protocol libraries available for desktop applications
- Manual Transaction Parsing: Must parse and validate complex V2 transaction structures byte-by-byte
- Memory Constraints: Limited RAM requires meticulous implementations of all required buffers and data structures to hold relevant data.
- Cryptographic Isolation: All operations must occur within secure element boundaries
UTXO Model Complexity: Sia's UTXO-based architecture adds additional complexity compared to account-based cryptocurrencies, requiring careful tracking of input-output relationships and change calculations.
Cypherock X1 implements a secure signing process specifically designed for UTXO-based ledgers like Sia:
- Host application constructs unsigned transaction with selected UTXOs as inputs
- Transaction includes recipient addresses, amounts, and calculated fees
- Raw transaction data is serialized and sent to hardware wallet via USB
- Custom Parser: Firmware implements custom parser for V2 transaction format without external dependencies
- Bit-Level Validation: Every transaction field validated manually according to Sia protocol specifications
- UTXO Verification: Referenced UTXOs validated against expected format and spending conditions
- Memory Management: Firmware needs to be implemented in a memory optimized way, as the hardware has limited memory of 98kb.
- Output Display: Each transaction output is displayed with recipient address and amount
- Fee Confirmation: Total transaction fee is calculated and displayed for user approval
- Input Summary: Total input amount and change calculations are shown
- Sequential Approval: User must physically confirm each element using device buttons
- Key Derivation: Private key derived from master seed using BIP44 path
m/44'/1991'/i'/0/j - Manual Hash Generation: V2 transaction hash calculated manually using Blake2b-256 algorithm
- Signature Creation: Ed25519 signature generated using secure element with trezor-crypto primitives
- Air-Gap Maintained: Private key never leaves secure hardware boundary
- Signed transaction returned to host for network broadcasting
- Device clears all transaction context and sensitive data from memory
- Host broadcasts completed transaction to Sia network via established APIs
- Basic transfers: Siacoin send/receive operations
- Portfolio features: Balance tracking, transaction history, price integration
- Future extensibility: Architecture supports Siafund transactions
- Hardware isolation: All private key operations in secure element
- On-device verification: Transaction confirmation on hardware wallet
- Air-gapped signing: Host constructs, device signs after user approval
- V2 transactions: Full support for current Sia protocol post-hardfork
- Standard derivation: BIP44 path
m/44'/1991'/i'/0/j - Address compatibility: SpendPolicy-based address generation
- Milestone 1 completion report with technical specifications
- Cryptographic library evaluation (trezor-crypto selection)
- Repository integration planning for existing Cypherock architecture
- API research and validation for blockchain interaction