2.9 KiB
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:
- 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.
- 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 serverclient_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:
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:
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
- Open the client app in a browser at http://127.0.0.1:8082
- Note the public key displayed on the page
- Open the web app in another browser window at http://127.0.0.1:8080
- Enter the public key from step 2 into the "Public Key" field
- Enter a message to be signed and submit the form
- The message will be sent to the SigSocket server, which forwards it to the connected client
- In the client app, you'll see the sign request appear - click "Sign Message" to approve
- The signature will be sent back through the SigSocket server to the web app
- The web app will display the signature
How It Works
-
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.
-
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
-
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.