CKB-Mobile-Core: Lightweight Native SDK for iOS & Android
1. Objective
To eliminate developer friction when building native mobile applications on the Nervos Network. This lightweight SDK will handle local cryptographic signing, Molecule data serialization, and automated cell selection natively on iOS and Android without relying on heavy webview wrappers or outdated JavaScript libraries.
2. Motivation & Target Audience
While CKB tooling on the web (e.g., CCC) and backend (Rust, Go) has matured, the native mobile developer experience remains a major bottleneck. Teams attempting to build native mobile wallets, Bitcoin L2 tools, or mobile games currently must write custom FFI bridges from scratch.
Target Beneficiaries:
- RGB++ & Bitcoin L2 Teams: Enabling mobile companion apps and DEX interfaces (e.g., UTXOSwap, HueHub).
- Mobile Wallet Developers: Clean cryptographic abstractions for biometric authentication (JoyID native bridges, multi-chain wallets).
- On-Chain Mobile Gaming: High-performance transaction submission for mobile engines (e.g., Cellula).
3. Core Architecture & Technical Scope
Component A: Native Cryptographic Module
- Hashing: Native implementation of
Blake2b(using CKB’sckb-blake2bpersonalization setting). - Signing: Direct bindings to
secp256k1for standard CKB Lock Scripts (such as SECP256K1/blake160). - Key Management: Secure integration with iOS Keychain and Android Keystore for hardware-backed key protection.
Component B: Molecule Binary Serializer
- Goal: High-performance Molecule serialization engine using a lightweight, native/Rust-backed bridge.
- Functionality: Converts high-level mobile data models (
Transaction,CellInput,CellOutput,Script) directly into compliant CKB byte streams.
Component C: Automated Cell Collector & Fee Estimator
- Workflow:
- Fetch live cells for an address via JSON-RPC (
get_cells). - Filter out occupied/locked cells.
- Calculate required capacity (Occupied bytes + Fee).
- Automatically construct change cells and balance inputs/outputs.
- Fetch live cells for an address via JSON-RPC (
4. Proposed Developer API (Example)
import CKBMobileCore
// 1. Initialize Client & Wallet
let client = CKBClient(rpcUrl: "https://testnet.ckb.dev")
let wallet = CKBWallet(privateKeyFromKeychain: "user_key_id")
// 2. Compose and send a capacity transfer
do {
let txHash = try await client.transferCapacity(
from: wallet,
toAddress: "ckt1qzda0cr08...",
amountInBytes: 100 // 100 CKB capacity
)
print("Transaction broadcasted! Hash: $txHash)")
} catch {
print("Transaction failed: $error)")
}
