Skip to content

emmorais/waas

Repository files navigation

πŸ” Wallet as a Service (WaaS)

A Threshold Signature Scheme (TSS) based wallet service built with Rust, providing secure multi-party computation for cryptocurrency operations. This service implements distributed key generation, hierarchical deterministic (HD) keys, and threshold signatures in order to avoid single point of failure.

πŸš€ Features

Core TSS Operations

  • πŸ”‘ Distributed Key Generation: Generate cryptographic keys across multiple parties using threshold cryptography
  • ✍️ Threshold Signatures: Create signatures that require cooperation from multiple parties
  • πŸ” Signature Verification: Verify signatures against public keys
  • πŸ—‘οΈ Secure Key Deletion: Safely remove all cryptographic material from storage

Hierarchical Deterministic (HD) Wallet

  • 🌱 Child Key Derivation: Generate deterministic child keys from a master key

Security & Infrastructure

  • πŸ›‘οΈ HTTPS/TLS: All communications encrypted with self-signed certificates
  • πŸ” Basic Authentication: Simple username/password protection (admin/admin123)
  • πŸ’Ύ Persistent Storage: Keys and configurations saved to local files
  • 🌐 Web UI: Modern, responsive interface for all operations

Cryptographic Libraries

  • tss-ecdsa: Core threshold signature implementation
  • k256: Elliptic curve operations (secp256k1)
  • ecdsa: ECDSA signature verification

Storage Format

  • keygen_result.json: Complete TSS key generation outputs (all private shares)
  • keygen_configs.bin: Participant configurations (binary serialized)
  • keygen_completed.marker: Completion marker file
  • hd_keys.json: Hierarchical deterministic key metadata

πŸ› οΈ Installation & Setup

Prerequisites

  • Rust (latest stable version)

Performance Notes

  • Signing can take 60+ seconds on slower systems

Browser Compatibility

  • βœ… Chrome: Fully tested and supported on Linux and Mac
  • ⚠️ Firefox: Known timeout issues with long TSS operations (not currently supported)
  • ⚠️ Safari: Known timeout issues with long TSS operations (not currently supported)
  • ⚠️ Edge: Not tested, compatibility unknown
  • πŸ“± Mobile browsers: Not tested, desktop Chrome recommended for development

Recommendation: Use Google Chrome for optimal experience. The application has been tested exclusively with Chrome on Linux and Mac systems.

Clone and Build

git clone https://github.com/emmorais/waas.git
cd waas
cargo build --release

πŸš€ Running the Server

Start the Service

cargo run

Server Output

🎯 TSS-ECDSA Wallet-as-a-Service Server
πŸ“ Listening on https://localhost:8443
πŸ” TLS encryption enabled
πŸ”‘ Authentication: admin/admin123
πŸ“Š Dashboard: https://localhost:8443/dashboard

✨ Ready to process TSS operations!

🌐 Testing & Usage

Access the Web Interface

  1. Open your browser and navigate to:

    https://localhost:8443/
    
  2. Accept the security warning (self-signed certificate is expected for local testing)

  3. Login with default credentials:

    • Username: admin
    • Password: admin123

Web Interface Operations

πŸ”‘ Key Generation

  1. Click "Generate Key Pair" to create new TSS keys
  2. The system will generate:
    • Multi-party private key shares
    • Aggregated public key
    • Root key for HD wallet derivation
    • Chain code for deterministic derivation

🌱 HD Key Derivation

  1. Enter a child index (optional - auto-generated if empty)
  2. Add a key label (optional)
  3. Click "Derive Child Key"
  4. View all keys with "List Keys"

✍️ Message Signing

  1. Enter your message in the text field
  2. Select which key to use (root or child) from the dropdown
  3. Click "Create Signature"
  4. The system performs distributed signature generation

πŸ” Signature Verification

  1. Enter the same message used for signing
  2. Click "Verify Signature" (uses the last generated signature)
  3. The system validates cryptographic authenticity

πŸ—‘οΈ Key Management

  • Delete Child Key: Remove specific derived keys
  • Delete Key Material: Remove all cryptographic data (requires confirmation)

Command Line Testing

You can also interact with the service via curl:

# Check if server is running
curl -k https://localhost:8443/

# Generate new keys (requires basic auth)
curl -k -u admin:admin123 -X POST https://localhost:8443/keygen

# Check existing keys
curl -k -u admin:admin123 -X GET https://localhost:8443/keygen

# Sign a message
curl -k -u admin:admin123 -X POST https://localhost:8443/sign \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello World", "child_index": 0}'

# Verify a signature
curl -k -u admin:admin123 -X POST https://localhost:8443/verify \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello World", "signature": "...", "child_index": 0}'

πŸ”’ Security Considerations

For Development/Testing

  • Uses self-signed TLS certificates (browsers will show security warnings)
  • Hardcoded credentials (admin/admin123) - change for production use
  • Local file storage - keys stored in working directory

Production Recommendations

  • Generate proper TLS certificates from a trusted CA
  • Implement secure credential management (environment variables, secrets manager)
  • Use hardware security modules (HSMs) for key storage
  • Add rate limiting and audit logging
  • Implement proper access controls and multi-factor authentication

πŸ“ File Structure

waas/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.rs              # HTTPS server & routing
β”‚   β”œβ”€β”€ keygen.rs            # TSS key generation
β”‚   β”œβ”€β”€ sign.rs              # Signing & verification
β”‚   β”œβ”€β”€ hd_keys.rs           # HD wallet functionality
β”‚   β”œβ”€β”€ delete_key.rs        # Key deletion
β”‚   β”œβ”€β”€ dashboard.rs         # Web API endpoints
β”‚   └── static/
β”‚       └── index.html       # Web interface
β”œβ”€β”€ cert.pem                 # TLS certificate
β”œβ”€β”€ key.pem                  # TLS private key
β”œβ”€β”€ Cargo.toml               # Dependencies
└── README.md               # This file

πŸ”§ Development

Adding New Features

  1. API Endpoints: Add routes in src/main.rs
  2. TSS Operations: Implement in respective modules
  3. Web Interface: Update src/static/index.html
  4. Storage: Modify storage functions in src/sign.rs

Testing Changes

# Build and run
cargo run

# Check logs for errors
# Access https://localhost:8443/ to test UI

πŸ†˜ Troubleshooting

Common Issues

❌ "Compiling"

error: failed to parse manifest at `/home/eduardo/waas/Cargo.toml`

Caused by:
  feature `edition2024` is required

  The package requires the Cargo feature called `edition2024`, but that feature is not stabilized in this version of Cargo (1.81.0 (2dbb1af80 2024-08-20)).
  Consider trying a newer version of Cargo (this may require the nightly release).
  See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2024 for more information about the status of this feature.

Fix:

rustup update

❌ "Connection refused"

  • Ensure the server is running with cargo run
  • Check that port 8443 is not blocked by firewall

❌ "TLS certificate error"

  • Click "Advanced" β†’ "Proceed to localhost (unsafe)" in browser
  • This is expected behavior with self-signed certificates

❌ "Authentication failed"

  • Use credentials: admin / admin123
  • Check that Authorization header is properly formatted

❌ "No root key found"

  • Generate keys first using the "Generate Key Pair" button
  • Ensure keygen_result.json file exists in working directory

❌ "TSS signature generation failed" but server logs show success

  • Most common cause: Browser/network timeout (operations take 60+ seconds on slower systems)

❌ "NetworkError when attempting to fetch resource"

  • Most common cause: Server not running or not accessible on https://localhost:8443
  • Browser compatibility issues: Firefox and Safari have known timeout issues with long TSS operations
    • Solution: Use Google Chrome instead - fully tested and supported
    • Status: Firefox and Safari support is not currently available
  • Check server status: Ensure cargo run is active and shows "Ready to process TSS operations!"
  • Certificate issues: Make sure you accepted the self-signed certificate warning in browser
  • Port conflicts: Verify port 8443 is not used by another process (lsof -i :8443 on Linux/Mac)
  • Firewall blocking: Check if firewall is blocking port 8443
  • Enhanced debugging: Open browser dev tools (F12) β†’ Console tab for detailed connection logs

About

wallet as a service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published