A VOPRF (Verifiable Oblivious Pseudorandom Function) server implementation built with TypeScript, Express.js, and Node.js.
This server implements the VOPRF protocol as defined in RFC 9497 using the Cloudflare VOPRF-TS library.
-
Install dependencies:
npm install
-
Create a
.envfile (optional):PORT=8001 IP=127.0.0.1 SERVICE_NAME=voprf-server NODE_ENV=development
-
Start development server (with hot reload):
npm run dev
-
Build the project:
npm run build
-
Start production server:
npm start
-
Lint code:
npm run lint
-
Fix linting issues:
npm run lint:fix
-
Format code:
npm run format
-
Check formatting:
npm run format:check
GET /ping- Health check endpoint that returns{"reply": "pong"}
GET /voprf/public-key- Get the server's public key for VOPRF verificationPOST /voprf/evaluate- Perform blind evaluation of client requests
curl http://localhost:8001/voprf/public-keyResponse:
{
"publicKey": "base64-encoded-public-key",
"suite": "P384-SHA384"
}curl -X POST http://localhost:8001/voprf/evaluate \
-H "Content-Type: application/json" \
-d '{"evaluationRequest": "base64-encoded-evaluation-request"}'Run the included client example to see the full VOPRF protocol in action:
# Start the server in one terminal
npm run dev
# Run the client example in another terminal
npm run example:clientsrc/
├── index.ts # Application entry point
├── app.ts # Express app configuration
├── config/
│ └── index.ts # Environment configuration
└── voprf/
└── routes.ts # VOPRF server endpoints and logic
examples/
└── voprf-client.ts # Example VOPRF client implementation
The VOPRF (Verifiable Oblivious Pseudorandom Function) protocol allows a client to obtain pseudorandom function evaluations from a server without revealing the input to the server. The server cannot learn the client's input, and the client can verify that the server used the correct private key.
Protocol Flow:
- Client requests server's public key
- Client blinds their input and sends an evaluation request
- Server performs blind evaluation and returns the result
- Client unblinds the result to get the final PRF output
This implementation uses the P384-SHA384 suite for cryptographic operations.