Skip to content

AAStarCommunity/AirAccount

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

605 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

KMS (Key Management System) on TEE

License: Apache 2.0 Service Status API Compatibility API Docs Version

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.

้ƒจ็ฝฒๆ–นๆกˆ / Deployment Modes

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ใ€‚

๐ŸŒ Live Service

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"}'

๐Ÿ“– API Documentation

Interactive API docs (Swagger UI) โ€” served live by the KMS itself, always matching the deployed build:

๐Ÿ”— https://kms.aastar.io/docs

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.

๐Ÿ”‘ API Key ่ฎค่ฏไธŽ็ฎก็†

ๆ•ๆ„Ÿ่ทฏ็”ฑ๏ผˆ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 ่ฆ†็›–ใ€‚

๐Ÿ” ๆ—ฅๅฟ—ไธŽ่ฐƒ่ฏ• (Logs & Debugging)

ๆ—ฅๅฟ—ๅˆ†ไธคๅฑ‚๏ผš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 ่‡ชๅทฑ่ฐƒๅˆฐ debug

TA ๆทฑๅบฆๆ—ฅๅฟ—๏ผˆๅœจ 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๏ผ‰ใ€‚

๐Ÿ”’ Trust & Verifiability (ไฟกไปปๅขžๅผบ)

ไฝ ไธ็”จ"็›ธไฟก 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ใ€‚

๐Ÿ—๏ธ System Architecture

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
Loading

๐Ÿ“ Project Structure

โ”œโ”€โ”€ 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/

โœจ Key Features

๐Ÿ”’ Security First

  • 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

๐Ÿ”— AWS KMS Compatibility

  • 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

โšก Performance & Reliability

  • 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

๐Ÿ› ๏ธ Developer Experience

  • 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

๐Ÿ” Security Architecture & Hardware Background

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:

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.

๐Ÿš€ Quick Start

1. Test the Live Service

# 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"}'

2. Run Complete API Tests

# Python test suite (recommended)
python3 scripts/test-kms-apis.py --online

# Curl-based testing
./scripts/test-all-apis-curl.sh

3. Local Development

# Start KMS API server
cd kms/kms-api
cargo run --release

# Test locally
curl -X POST http://localhost:8080/health

4. Deploy Your Own Instance

# 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

๐Ÿ“Š API Reference

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

๐Ÿ”ง Technology Stack

Core Components

  • Rust: Memory-safe systems programming
  • Axum: High-performance async HTTP framework
  • secp256k1: Ethereum-compatible ECDSA
  • UUID: Cryptographically secure key identifiers

Security Layer

  • OP-TEE: Open-source Trusted Execution Environment
  • ARM TrustZone: Hardware security features
  • Teaclave SDK: Rust-based TEE development framework

Infrastructure

  • Cloudflare Tunnel: Secure public access without port forwarding
  • Docker: Containerized development and deployment
  • QEMU: ARM64 TEE simulation for development

๐Ÿ—๏ธ Architecture Phases

Current: Phase 7 (Production Ready)

  • โœ… Mock TEE implementation for rapid development
  • โœ… AWS KMS compatible API service
  • โœ… Global deployment via Cloudflare
  • โœ… Complete test suite and documentation

Next: Phase 8 (Security Enhancement)

  • ๐Ÿ”„ Migration to real OP-TEE environment
  • ๐Ÿ”„ Hardware security module integration
  • ๐Ÿ”„ Advanced cryptographic features
  • ๐Ÿ”„ Multi-tenant support

Future: Phase 9-10 (Enterprise Scale)

  • โณ High availability clustering
  • โณ Hardware security module (HSM) integration
  • โณ Compliance certifications (FIPS, Common Criteria)
  • โณ Enterprise authentication and authorization

๐Ÿ“š Documentation

๐Ÿค Contributing

Development Setup

# 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

Testing

# 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 run

๐Ÿ“ˆ Current Status

Service 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)

๐Ÿ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


๐Ÿš€ Try it now: https://kms.aastar.io/health

License

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.

About

Your lifelong crypto account solution, open source, self-runable and self-custody

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages