72 lines
2.9 KiB
Markdown
72 lines
2.9 KiB
Markdown
# SigSocket Examples
|
|
|
|
This directory contains example applications demonstrating how to use the SigSocket library for cryptographic signing operations using WebSockets.
|
|
|
|
## Overview
|
|
|
|
These examples demonstrate a common workflow:
|
|
|
|
1. **Web Application with Integrated SigSocket Server**: An Actix-based web server that both serves the web UI and runs the SigSocket WebSocket server for handling connections and signing requests.
|
|
2. **Client Application**: A web interface that connects to the SigSocket WebSocket endpoint, receives signing requests, and submits signatures.
|
|
|
|
## Directory Structure
|
|
|
|
- `web_app/`: The web application with integrated SigSocket server
|
|
- `client_app/`: The client application that signs messages
|
|
|
|
## Running the Examples
|
|
|
|
You only need to run two components:
|
|
|
|
### 1. Start the Web Application with Integrated SigSocket Server
|
|
|
|
Start the web application which also runs the SigSocket server:
|
|
|
|
```bash
|
|
cd /path/to/sigsocket/examples/web_app
|
|
cargo run
|
|
```
|
|
|
|
This will start a web interface at http://127.0.0.1:8080 where you can submit messages to be signed. It also starts the SigSocket WebSocket server at ws://127.0.0.1:8080/ws.
|
|
|
|
### 2. Start the Client Application
|
|
|
|
The client application connects to the WebSocket endpoint and waits for signing requests:
|
|
|
|
```bash
|
|
cd /path/to/sigsocket/examples/client_app
|
|
cargo run
|
|
```
|
|
|
|
This will start a web interface at http://127.0.0.1:8082 where you can see signing requests and approve them.
|
|
|
|
## Using the Applications
|
|
|
|
1. Open the client app in a browser at http://127.0.0.1:8082
|
|
2. Note the public key displayed on the page
|
|
3. Open the web app in another browser window at http://127.0.0.1:8080
|
|
4. Enter the public key from step 2 into the "Public Key" field
|
|
5. Enter a message to be signed and submit the form
|
|
6. The message will be sent to the SigSocket server, which forwards it to the connected client
|
|
7. In the client app, you'll see the sign request appear - click "Sign Message" to approve
|
|
8. The signature will be sent back through the SigSocket server to the web app
|
|
9. The web app will display the signature
|
|
|
|
## How It Works
|
|
|
|
1. **SigSocket Server**: Provides a WebSocket endpoint for clients to connect and register with their public keys. It also accepts HTTP requests to sign messages with a specific client's key.
|
|
|
|
2. **Web Application**:
|
|
- Provides a form for users to enter a public key and message
|
|
- Uses the SigSocket service to send the message to be signed
|
|
- Displays the resulting signature
|
|
|
|
3. **Client Application**:
|
|
- Connects to the SigSocket server via WebSocket
|
|
- Registers with a public key
|
|
- Waits for signing requests
|
|
- Displays incoming requests and allows the user to approve them
|
|
- Signs messages using ECDSA with Secp256k1 and sends the signatures back
|
|
|
|
This demonstrates a real-world use case where a web application needs to verify a user's identity or get approval for transactions through cryptographic signatures, without having direct access to the private keys.
|