A web-based tool for generating deterministic keys and building Mostro protocol messages with NIP-59 gift wrap encryption.
Mostro Web Tool is a development and testing utility for the Mostro P2P exchange protocol. It provides:
- BIP39 Mnemonic Generation: Creates deterministic seed phrases for reproducible key derivation
- Hierarchical Key Derivation: Implements Mostro's BIP44 derivation scheme (
m/44'/1237'/38383'/0) - Message Builder: Interactive UI for constructing Mostro protocol messages (orders, disputes, ratings, etc.)
- NIP-59 Gift Wrap: Automatically encrypts and wraps messages following the Nostr NIP-59 specification
- API Endpoints: REST API for key derivation and message signing
This tool is intended for development, testing, and educational purposes. For production use, integrate these features directly into your Mostro client application.
- Identity Key (index 0): Used for reputation tracking and seal signing
- Trade Keys (index β₯ 1): One-time-use keys that rotate per trade for privacy
- Follows Mostro's key derivation standard:
m/44'/1237'/38383'/0/{index} - Compatible with any BIP39-compliant wallet that supports custom derivation paths
- Interactive form for all Mostro actions (40+ action types)
- Support for orders, disputes, ratings, direct messages, and session restoration
- Real-time message preview with JSON formatting
- Automatic signature generation using trade keys
- Validates message structure against
mostro-coretypes
- Implements standard NIP-59 encryption
- Three-layer security:
- Rumor: Signed with trade key, contains
(message, signature)tuple - Seal: Encrypted and signed with identity key
- Gift Wrap: Encrypted and signed with ephemeral key for metadata privacy
- Rumor: Signed with trade key, contains
- Compatible with Mostro daemon (mostrod) and other NIP-59 implementations
- Rust: 1.90.0 or later
- Cargo: 1.90.0 or later
# Clone the repository
git clone https://github.com/MostroP2P/mostro-webtool.git
cd mostro-webtool
# Build the project
cargo build --release
# Run the server
cargo run --releaseThe server will start on http://127.0.0.1:3000
- Open
http://127.0.0.1:3000in your browser - The tool will generate a new mnemonic automatically (or enter your own)
- View your identity key (index 0) and current trade key
- Build messages using the interactive form:
- Select message type (Order, Dispute, Rate, etc.)
- Choose an action (e.g.,
new-order,take-sell) - Fill in required fields
- Add optional payload (order details, dispute info, etc.)
- Click "Send to Mostro" to create a signed gift wrap event
- The tool will publish to your configured Nostr relay
- Use the + / - buttons to navigate between trade key indices
- Each trade should use a new index for privacy
- The web interface tracks your current trade index automatically
POST /api/trade-key
Content-Type: application/json
{
"mnemonic": "your twelve word mnemonic",
"index": 2
}Response:
{
"index": 2,
"derivation_path": "m/44'/1237'/38383'/0/2",
"public_key": "02a1b2c3...",
"private_key": "a1a2b3c4..."
}POST /api/build-gift-wrap
Content-Type: application/json
{
"mnemonic": "your mnemonic phrase",
"trade_index": 1,
"mostro_pubkey": "npub1...",
"message_json": "{\"order\":{\"version\":1,\"action\":\"new-order\",...}}"
}Response:
{
"gift_wrap_event": {
"id": "event_id",
"kind": 1059,
"pubkey": "ephemeral_key",
"content": "encrypted_content",
...
}
}mostro-webtool/
βββ src/
β βββ main.rs # Entry point, server initialization
β βββ lib.rs # Core logic, routes, key derivation, gift wrap
βββ tests/
β βββ trade_key_api.rs # API endpoint tests
β βββ gift_wrap_test.rs # NIP-59 encryption tests
βββ static/ # Static assets (logo, etc.)
βββ docs/ # Protocol documentation
β βββ protocol/ # Mostro protocol specs
βββ Cargo.toml # Dependencies and metadata
- Axum: Async web framework for HTTP server
- nostr-sdk: BIP39 mnemonic generation, NIP-06 key derivation, NIP-59 gift wrap
- mostro-core: Mostro protocol types and message validation
- bip39: Mnemonic phrase generation and validation
# Type-check only (fast)
cargo check
# Full compilation
cargo build
# Release build (optimized)
cargo build --release# Run all tests
cargo test
# Run specific test file
cargo test --test gift_wrap_test
# Run with output
cargo test -- --nocapture# Run linter
cargo clippy
# Format code
cargo fmt
# Check formatting
cargo fmt -- --check# Enable debug logging
RUST_LOG=mostro_webtool=debug cargo run
# Enable trace logging (very verbose)
RUST_LOG=mostro_webtool=trace cargo runMostro uses a specific BIP44 derivation path for key management:
m/44'/1237'/38383'/0/{index}
β β β β β
β β β β ββ Key index
β β β ββββββ Branch (always 0)
β β ββββββββββββββ Mostro account index
β βββββββββββββββββββββ Nostr Coin type (1237)
ββββββββββββββββββββββββββ Purpose (BIP44)
-
Identity Key (index 0):
m/44'/1237'/38383'/0/0- Signs the seal in gift wrap events
- Links trades to your reputation
- Persistent across all trades
-
Trade Keys (index β₯ 1):
m/44'/1237'/38383'/0/1,m/44'/1237'/38383'/0/2, ...- Sign individual messages
- Rotate for each trade
- Provide forward secrecy
Standard Mode: Use identity key (index 0) for seal signing to build reputation
Full Privacy Mode: Use trade key for seal signing (no reputation tracking)
Detailed protocol specifications are available in the docs/protocol/ directory.
- This tool is for development and testing only
- Never use production funds with test mnemonics
- Store mnemonics securely (use a password manager)
- The web interface generates mnemonics in the browser - for production, use a hardware wallet
- Private keys are never logged or persisted by the server
- Gift wrap events use ephemeral keys for metadata privacy
The project includes comprehensive test coverage:
# Run all tests
cargo test
# Gift wrap encryption tests
cargo test --test gift_wrap_test
# API endpoint tests
cargo test --test trade_key_api- β Key derivation with BIP39 mnemonics
- β Trade key rotation (indices 1-10)
- β NIP-59 gift wrap creation
- β Rumor extraction and signature verification
- β Seal signing with identity key
- β Message serialization and deserialization
- β trade_index injection and validation
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions, issues, or feature requests:
- Open an issue on GitHub
- Join the Mostro community discussions
- Check the docs/ directory for detailed documentation
