A production-ready private key management system built on Trusted Execution Environment (TEE) using the eth_wallet sample from Teaclave TrustZone SDK. Provides enterprise-grade security with AWS KMS API compatibility.
AirAccount(KMS)ไธ DVT(aNode BLS ้จ้ๅ ฑ็ญพ)ๅฏ็ฌ็ซๆๅๅนถ้จ็ฝฒ โโ ไธไธชๆนๆกใ้ ็ฝฎๅๆข,ๆนๅจๅพๅฐใ
| ๅบๆฏ | ้จ็ฝฒไปไน | BLS/็ง้ฅๆ็ฎก | ๅ ณ้ฎ้ ็ฝฎ |
|---|---|---|---|
| โ ็ฌ็ซ KMS | ๅช KMS | ็จๆท็ง้ฅๅจ TEE,ๆฏๆฌก passkey/WebAuthn ็ญพใๆฐธไธๅฏผๅบ | โ |
| โก ็ฌ็ซ DVT | ๅช DVT | DVT ็ BLS ็ง้ฅๅจ EIP-2335 keystore(็ไธๅ ๅฏ + ๆๅจๅฏ็ ) | RUST_SIGNER_URL ไธ่ฎพ |
| โข KMS + DVT ๅๅนถ | ๅๆฟ co-located | DVT ็ BLS ็ง้ฅๆ็ฎก่ฟ KMS TEE(ๆฐธไธๅบใ่ชๅฏๆ ้ๅฏ็ ) | RUST_SIGNER_URL=http://127.0.0.1:3100 |
- ๅชๆณ่ทๅฏ้ฅ/็ญพๅๆๅก(SuperPaymaster/SuperRelay ็ญๆถ่ดนๆน็ดๆฅ่ฐ AWS-KMS ๅ ผๅฎน API)โ โ ใ
- ๅชๆณ่ท DVT ้จ้่็นใไธ่ท KMS โ โก(ๆ ๅ DVT ้จ็ฝฒ,ๅฏ้ฅ่ช็ฎก)ใ
- ่ทๅฎๆด่็นใ่ฆๆๅผบๅฎๅ จ โ โข(BLS ๅฏ้ฅๆๆๅๆๅฐ KMS ็บง,ๆญ็ต่ชๅฏไธ็จ้่พๅฏ็ )ใ
โข ๆฏ โก ็ๅฏ้ๅขๅผบ,ไธๅผบ็ปๅฎ:ๅไธไธช DVT ไบ่ฟๅถ,RUST_SIGNER_URL ไธไธช env ๅๆขๆจกๅผใ่ฎพ่ฎกไธๅฎๅ
จๅๆ่ง kms/docs/dvt-tee-bls-custody-design.mdใ
Production URL: https://kms.aastar.io
# Quick health check
curl -s https://kms.aastar.io/health | jq
# Create a key
curl -X POST https://kms.aastar.io/ \
-H "Content-Type: application/json" \
-H "X-Amz-Target: TrentService.CreateKey" \
-d '{"KeyUsage":"SIGN_VERIFY","KeySpec":"ECC_SECG_P256K1","Origin":"AWS_KMS"}'Interactive API docs (Swagger UI) โ served live by the KMS itself, always matching the deployed build:
| Resource | Link |
|---|---|
| Live Swagger UI | https://kms.aastar.io/docs |
| OpenAPI 3.1 spec | https://kms.aastar.io/openapi.yaml ยท in-repo |
| Test coverage matrix | kms/docs/API-TEST-MATRIX.md |
38 endpoints โ wallet lifecycle ยท signing (hash / message / transaction / EIP-712) ยท WebAuthn
ceremony ยท agent keys ยท grant sessions ยท P256 sessions ยท SuperPaymaster gasless signers ยท
DVT out-of-band confirm verify (/verify-confirm-assertion, #124) ยท contact binding
(/contact/*, #129). Every operation carries its test-coverage status (x-tested).
Real-device E2E: 39/39 ยท unit: proto 39 + host 58.
ๆๆ่ทฏ็ฑ๏ผCreateKey / Sign / SignHash / DeleteKey / ChangePasskey / UnfreezeKey / ListKeys / DescribeKey / GetPublicKey / DeriveAddress / WebAuthn Begin*ยทComplete* / agent ็ซฏ็น / verify-confirm-assertion (#124) / contact/* (#129)๏ผ้ๅธฆ HTTP header x-api-key: <key>๏ผๅฆๅ 401ใๅผๆพๅช่ฏป็ซฏ็น๏ผ/health /version /stats /QueueStatus /RollbackCounter /attestation?nonce= /.well-known/* /docs /openapi.yaml๏ผๆ ้ keyใ
curl -X POST https://kms.aastar.io/Sign \
-H "x-amz-target: TrentService.Sign" \
-H "x-api-key: kms_xxxxxxxx" -d '{ โฆ }'ๅผบๅถ่งๅ๏ผDB ไธญๅญๅจ โฅ1 ไธช key๏ผๆ่ฎพ KMS_API_KEY / KMS_REQUIRE_API_KEY=1๏ผๅณๅผๅฏๅผบๅถใ็ไบง kms.aastar.io ๅทฒๅผๅฏใ
ๅฏ้ฅ็ฎก็ๅฝไปค๏ผๅจ KMS ไธปๆบไธ่ฟ่ก๏ผCLI ็ดๆฅ่ฏปๅ SQLite๏ผๆฏๆด้ฒ็ฝ็ป็ซฏ็นๆดๅฎๅ จ๏ผ๏ผ
# ๆฐๅปบ๏ผ่ชๅจ insert ๅนถๆๅฐ key๏ผv0.23.2 ่ตท่ฏๆญ่ตฐ stderr๏ผๅฏ่ๆฌๆ่ท๏ผ
KMS_DB_PATH=/data/kms/kms.db /path/to/api-key generate --label "service-name"
KEY=$(KMS_DB_PATH=/data/kms/kms.db /path/to/api-key generate --label svc) # ๅนฒๅๆ่ท
# ๅๅบ๏ผkey ไธญๆฎตๆ็ ๏ผ
/path/to/api-key list
# ๅ้
/path/to/api-key revoke kms_xxxxxxxx- ๆฐๅปบ/ๅ้ๅณๆถ็ๆ๏ผๆ ้้ๅฏ๏ผ
validate_api_keyๆฏ่ฏทๆฑๆฅ DB๏ผใ - key ๆๆไป
ๅญ DBใๅชๅจ
generateๆถๆๅฐไธๆฌก๏ผไธขๅคฑๅช่ฝrevoke้ๅใ โ ๏ธ ๆต่งๅจไพงๅๅฟๆ key ๆ่ฟๅ็ซฏ bundle๏ผ็จๆต่งๅจ โ ๅบ็จๅ็ซฏ(ๆ key) โ KMS็ไปฃ็ๆจกๅผใ- ้ป่ฎค DB ่ทฏๅพ๏ผ
/data/kms/kms.db๏ผๅญๅจๆถ๏ผๅฆๅๅทฅไฝ็ฎๅฝ./kms.db๏ผๅฏ็จKMS_DB_PATH่ฆ็ใ
ๆฅๅฟๅไธคๅฑ๏ผCA๏ผhost๏ผ= ๅบ็กๆฅๅฟ๏ผTA๏ผTEE๏ผ= ๆทฑๅบฆๆฅๅฟใ
CA ๆฅๅฟ โโ /var/log/kms-api.log๏ผ่ฟ่ก KMS ็ไธปๆบไธ๏ผๅฆ i.MX93 ๆฟ๏ผ
systemd ๆ stdout+stderr ้ฝ append ๅฐ่ฟ้ใๅ
ๅซไธ็ฑป๏ผ
- Access log๏ผv0.24.1+๏ผ๏ผๆฏ่ฏทๆฑไธ่ก โโ
[<ๆถ้ด> INFO kms::access] <ip> "<method> <path>" <็ถๆ็ > "-" "<ua>" <่ๆถ>ใไธๅซ่ฏทๆฑๅคด๏ผx-api-keyไธไผๆณๆผใ - Operation ๆฅๅฟ๏ผ
โ SignHash OK addr=0xโฆ webauthn=true 81msใ๐ WebAuthn rpId resolved: localhost็ญใ - ้่ฏฏ๏ผ
SignHash error: <TA ๅๅง้่ฏฏ> โฆ๏ผๅธฆ TEE ้่ฏฏ็ ๏ผๅฆ0xffff0006๏ผใ
# ไธปๆบ IP ไผๅ๏ผWiFi/DHCP๏ผโ ๅ
ๆซ 192.168.2.0/24:22 ๆพๆฟๅญ
ssh root@<host> 'tail -f /var/log/kms-api.log' # ๅฎๆถ
ssh root@<host> 'grep -iE "access|error|mismatch|fail|0xffff" /var/log/kms-api.log | tail -50' # ่ฏทๆฑ + ้่ฏฏ
ssh root@<host> 'journalctl -u kms-api.service -n 100 --no-pager' # systemd journal่ฐๆฅๅฟ็บงๅซ๏ผๆๅก่ฏป RUST_LOG๏ผ้ป่ฎค info๏ผaccess log ๅจ info ๅณๆพ็คบ๏ผใ่ฆๆด็ป๏ผ
# ๅจ /etc/airaccount/kms.env ๅ ไธ่กๅ systemctl restart kms-api๏ผ
RUST_LOG=debug # ๅ
จ้จ debug๏ผๅซ warp/hyper ๅ
้จ๏ผ
RUST_LOG=kms=debug,warp=info # ๅชๆ KMS ่ชๅทฑ่ฐๅฐ debugTA ๆทฑๅบฆๆฅๅฟ๏ผๅจ TEE ๅ
๏ผSSH/dmesg ็ไธๅฐ๏ผ
TA ็ trace_println!๏ผๅฆ [+] rpId hash verified in TA๏ผ่ตฐ OP-TEE ๅฎๅ
จไธฒๅฃ๏ผ้็ฉ็ไธฒๅฃ็บฟ๏ผ
screen /dev/cu.usbmodem<XXXX> 115200 # macOS๏ผ่ง screen-93.sh
/version็profileๅญๆฎตๅบๅๆฟๅญ๏ผprod๏ผrpId ไป aastar.io๏ผ/dev๏ผ้ขๅคๆฅๅ localhost๏ผใ
ไฝ ไธ็จ"็ธไฟก AAStar ไธไฝๆถ"ใ AirAccount ๆ"ๆๅจ่ทๅชไธช TEE ็จๅบ"ๅ ฌๅผ้ๆญปๅจไธไธช่ฐ้ฝๆนไธไบใ่ฐ้ฝ่ฝๆฅ็ๅ ฌๅ ฑ้ๆๆฅๅฟ้โโๆณๅทๅทๆขๆๅ้จ็ๆฌๅไธๅฐใไธไผ่ขซ็ซๅปๅ็ฐใไธ้ๅ ๅ ๆ"ไฟกไปปไธๅฎถๅ ฌๅธ"้็บงๆ"ไฟกไปปๅ ฌๅผ็ๆฐๅญฆๅ่ฎฐๅฝ"๏ผ
- ๅฏๅค็ฐๆๅปบ โ ไปปไฝไบบ็จๅผๆบๆบ็ ้็ฎ TA ็ measurement๏ผๆฏๅฏน็บฟไธๅผ๏ผ
scripts/ta-measurement.sh๏ผใ - ้ๆๆฅๅฟ๏ผSigsum๏ผ โ ๆฏไปฝ measurement ๆธ
ๅ้ฝ่ฟๅ
ฌๅผ append-only ๆฅๅฟใๅค่ง่ฏไบบๅ
ฑ็ญพ๏ผๅฎขๆท็ซฏ็ป
@aastar/attestation-verifier้ช"่ฟไปฝๆธ ๅ็กฎๅฎ่ขซๅ ฌๅผ็ป่ฎฐ่ฟ"ใๅทฒไธ็บฟ๏ผ/.well-known/attestation-measurements.json+โฆ-proof.jsonใ - DVT ็ฌ็ซ้จ้ๅ ฑ็ญพ โ ๅคง้ขๆไฝ่ฆ็ฌ็ซ็ฌฌไธๆน่็นๅ ฑ็ญพ๏ผไธไพ่ตๅ็น๏ผไนไธไพ่ตไฟกไปป AAStar๏ผใ
่ฏๅฎ่พน็๏ผๅฝๅๆฏๅๅปไธญๅฟๅใๅฏ็ฌ็ซ้ช่ฏ็ไฟกไปปๆจกๅ๏ผTOFU/ๅฏๅค็ฐ + ้ๆ + DVT๏ผ๏ผๅฐๆช้ๅฎ NXP ็กฌไปถๆ น๏ผๅ NDA ้ปๅก๏ผใๅฎๆดๅๆใๅคๆญใ้ช่ฏๆนๆณใ่ฟ็ปดๆนๆก่ง docs/TRUST.mdใ
graph TB
subgraph "Client Layer"
CLI[CLI Tools]
WebApp[Web Applications]
SDK[Language SDKs]
end
subgraph "API Gateway"
CF[Cloudflare Tunnel<br/>HTTPS Proxy]
LB[Load Balancer<br/>Rate Limiting]
end
subgraph "KMS Service Layer"
API[KMS API Server<br/>:8080<br/>AWS Compatible]
Health[Health Monitor<br/>Service Status]
end
subgraph "Core Logic Layer"
Core[KMS Core<br/>Cryptographic Logic]
Proto[Protocol Definitions<br/>TEE Communication]
end
subgraph "TEE Layer (Secure)"
Host[KMS Host<br/>TEE Interface]
TA[Trusted Application<br/>Key Operations]
Storage[Secure Storage<br/>Private Keys]
end
subgraph "Testing & Tools"
MockTEE[Mock TEE<br/>Development]
Tests[Test Suite<br/>API Validation]
Scripts[Deployment Scripts<br/>Automation]
end
%% Connections
CLI --> CF
WebApp --> CF
SDK --> CF
CF --> LB
LB --> API
API --> Health
API --> Core
Core --> Proto
Proto --> Host
Host --> TA
TA --> Storage
%% Development connections
Core -.-> MockTEE
Tests -.-> API
Scripts -.-> API
%% Styling
classDef secure fill:#ff6b6b,stroke:#333,stroke-width:3px
classDef api fill:#4ecdc4,stroke:#333,stroke-width:2px
classDef tool fill:#45b7d1,stroke:#333,stroke-width:1px
class TA,Storage,Host secure
class API,CF,LB api
class Tests,Scripts,MockTEE tool
โโโ README.md # Project overview and quick start
โโโ docs/ # ๐ Documentation
โ โโโ CLAUDE.md # AI assistant instructions
โ โโโ Changes.md # Development changelog
โ โโโ KMS-API-DOCUMENTATION.md # Complete API reference
โ โโโ system-architecture.md # Detailed architecture guide
โ โโโ deploy-arm-kms.md # TEE deployment guide
โ โโโ deployment-guide.md # Production deployment
โ โโโ roadmap.md # Development roadmap
โ โโโ quick-curl-*.md # Testing references
โโโ scripts/ # ๐ง Automation Scripts
โ โโโ deploy-kms.sh # One-click deployment
โ โโโ test-kms-apis.py # Complete API test suite
โ โโโ test-all-apis-curl.sh # Curl-based testing
โ โโโ migrate-to-optee.sh # OP-TEE migration tool
โ โโโ setup-public-access.sh # Cloudflare tunnel setup
โ โโโ *.sh, *.py # Various utility scripts
โโโ kms/ # ๐ KMS Core Implementation
โ โโโ kms-core/ # Hardware-independent logic
โ โโโ kms-api/ # HTTP API server (Axum)
โ โโโ kms-host/ # TEE host interface
โ โโโ kms-ta/ # Trusted Application
โ โโโ kms-ta-test/ # Mock TEE for development
โ โโโ proto/ # Protocol definitions
โ โโโ bak/ # Backup and legacy code
โโโ third_party/ # ๐ External Dependencies
โโโ incubator-teaclave-trustzone-sdk/
โโโ openssl_aarch64/
- TEE-based Security: Private keys never leave the secure execution environment
- Hardware Isolation: ARM TrustZone provides hardware-level protection
- Secure Storage: All sensitive data encrypted at rest in TEE storage
- No Network Exposure: Private keys never transmitted over network
- Drop-in Replacement: Compatible with existing AWS KMS client code
- Standard APIs: Full TrentService API implementation
- Familiar Errors: AWS-compatible error responses and status codes
- Enterprise Ready: Supports high-availability and load balancing
- Sub-300ms Response: Average API response time under 300ms
- High Throughput: Supports concurrent key operations
- 24/7 Availability: Production deployment with 99.9% uptime
- Global CDN: Cloudflare integration for worldwide access
- Multiple Language Support: SDKs for JavaScript, Python, Rust
- Comprehensive Testing: Complete test suite with real API validation
- One-Click Deployment: Automated deployment scripts
- Rich Documentation: API docs with real examples and responses
The KMS runs on OP-TEE TrustZone with the NXP i.MX93 ELE (EdgeLock Enclave) as hardware root of trust. The key crypto-hardware decisions and concepts are documented:
- secp256k1 Hardware Analysis โ why Ethereum's secp256k1 signing stays in software, the SE05x external secure-element option, and a glossary.
- Build & Deploy on MX93 โ cross-compile pitfalls + TA signing-key requirement.
- Release Plan โ Beta2/Beta3/mainnet feature gating.
Key facts
- Ethereum private keys (secp256k1) are managed in software (
k256) inside the TEE secure world, protected by RPMB anti-rollback. The i.MX93 ELE hardware does not support secp256k1 โ only NIST P-256/384/521, Ed25519, AES, HMAC, SM4 (ๅฎๆต็กฎ่ฎค). Hardware secp256k1 would need an external SE05x secure element over I2C. - ELE's role = hardware root of trust: TRNG (wallet entropy), HUK (derives the secure-storage encryption key), P-256 (WebAuthn passkey verification), attestation. It is not the home of secp256k1 wallet keys.
- Glossary:
- I2C (Inter-Integrated Circuit, ่ฏปไฝ "IๆนC") โ a 2-wire chip-to-chip serial bus (SDA data + SCL clock); how external chips like SE05x attach to the SoC. Low bandwidth (โค3.4 Mbit/s).
- EAL6+ (Evaluation Assurance Level 6+) โ a Common Criteria (ISO/IEC 15408) security-certification level (EAL1 lowest โ EAL7 highest; higher = stricter third-party evaluation). Secure-element chips like SE05x are EAL6+. It measures how rigorously security was evaluated, not performance.
# Health check
curl -s https://kms.aastar.io/health
# Create a signing key
curl -X POST https://kms.aastar.io/ \
-H "Content-Type: application/json" \
-H "X-Amz-Target: TrentService.CreateKey" \
-d '{"KeyUsage":"SIGN_VERIFY","KeySpec":"ECC_SECG_P256K1","Origin":"AWS_KMS"}'# Python test suite (recommended)
python3 scripts/test-kms-apis.py --online
# Curl-based testing
./scripts/test-all-apis-curl.sh# Start KMS API server
cd kms/kms-api
cargo run --release
# Test locally
curl -X POST http://localhost:8080/health# Mock TEE deployment (fast)
./scripts/deploy-kms.sh mock-deploy
# With public tunnel
./scripts/deploy-kms.sh mock-deploy -t
# Real TEE deployment (requires OP-TEE)
./scripts/deploy-kms.sh qemu-deploy| Endpoint | Method | Purpose | Status |
|---|---|---|---|
/health |
GET | Service health check | โ Live |
/keys |
GET | List all keys | โ Live |
/ + TrentService.CreateKey |
POST | Generate new key | โ Live |
/ + TrentService.GetPublicKey |
POST | Retrieve public key | โ Live |
/ + TrentService.Sign |
POST | Sign message | โ Live |
Complete API Documentation: docs/KMS-API-DOCUMENTATION.md
- Rust: Memory-safe systems programming
- Axum: High-performance async HTTP framework
- secp256k1: Ethereum-compatible ECDSA
- UUID: Cryptographically secure key identifiers
- OP-TEE: Open-source Trusted Execution Environment
- ARM TrustZone: Hardware security features
- Teaclave SDK: Rust-based TEE development framework
- Cloudflare Tunnel: Secure public access without port forwarding
- Docker: Containerized development and deployment
- QEMU: ARM64 TEE simulation for development
- โ Mock TEE implementation for rapid development
- โ AWS KMS compatible API service
- โ Global deployment via Cloudflare
- โ Complete test suite and documentation
- ๐ Migration to real OP-TEE environment
- ๐ Hardware security module integration
- ๐ Advanced cryptographic features
- ๐ Multi-tenant support
- โณ High availability clustering
- โณ Hardware security module (HSM) integration
- โณ Compliance certifications (FIPS, Common Criteria)
- โณ Enterprise authentication and authorization
- Complete API Reference - Full API documentation with examples
- System Architecture - Detailed technical architecture
- Deployment Guide - Production deployment instructions
- Development Changelog - Complete development history
- Phase Roadmap - Future development plans
# Clone with submodules
git clone --recursive https://github.com/AAStarCommunity/AirAccount.git
# Install Rust and dependencies
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Build and test
cd kms && cargo build --release
python3 scripts/test-kms-apis.py --online# Complete test suite
./scripts/test-all-apis-curl.sh
# Performance benchmarking
python3 scripts/test-kms-apis.py --compare
# Development with mock TEE
cd kms/kms-ta-test && cargo runService Metrics (Live Production):
- ๐ Uptime: 24/7 availability
- โก Performance: ~267ms average response time
- ๐ Capacity: 35+ active keys managed
- ๐ก๏ธ Security: TEE-based private key protection
- ๐ Global: Accessible via Cloudflare CDN
Development Status:
- โ Core cryptographic operations (Phase 1-7 complete)
- ๐ Real TEE migration (Phase 8 in progress)
- โณ Enterprise features (Phase 9-10 planned)
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
๐ Try it now: https://kms.aastar.io/health
This project is licensed under the Apache License, Version 2.0.
Copyright 2024-present MushroomDAO Contributors.
See NOTICE ยท TRADEMARK.md ยท LICENSE-zh.md ยท TRADEMARK-zh.md for details.