From 38e7bbe80fb98b6d1a4ecb98e5dcd0ac77a5a842 Mon Sep 17 00:00:00 2001 From: 0xmad <0xmad@users.noreply.github.com> Date: Tue, 14 May 2024 12:55:03 -0500 Subject: [PATCH] docs(coordinator): add readme docs for coordinator --- coordinator/.env.example | 3 --- coordinator/README.md | 12 ++++++++++++ coordinator/hardhat.config.ts | 11 ----------- coordinator/package.json | 1 - 4 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 coordinator/README.md diff --git a/coordinator/.env.example b/coordinator/.env.example index bb6fa50e76..ef4dd88f12 100644 --- a/coordinator/.env.example +++ b/coordinator/.env.example @@ -21,9 +21,6 @@ COORDINATOR_RAPIDSNARK_EXE= # Location of zkey, wasm files COORDINATOR_ZKEY_PATH="./zkeys" -# Coordinator mnemonic phrase -COORDINATOR_MNEMONIC= - # Coordinator RPC url COORDINATOR_RPC_URL=http://localhost:8545 diff --git a/coordinator/README.md b/coordinator/README.md new file mode 100644 index 0000000000..f5a974bd85 --- /dev/null +++ b/coordinator/README.md @@ -0,0 +1,12 @@ +# Coordinator service + +## Instructions + +1. Add `.env` file (see `.env.example`). +2. Generate RSA key pair with `pnpm run generate-keypair`. +3. Download zkey files using `pnpm run download-zkeys:{type}` (only test type is available for now). +4. Make sure you copied RSA public key to your application. This will be needed for encrypting `Authorization` header and coordinator private key for proof generation. +5. Run `pnpm run start` to run the service. +6. All API calls must be called with `Authorization` header, where the value is encrypted with RSA public key, you generated before. Header value contains message signature and message digest created by `COORDINATOR_ADDRESS`. Format is `publicEncrypt({signature}:{digest})`. + Make sure you set `COORDINATOR_ADDRESS` env variable and sign any message with this address from your application (see [AccountSignatureGuard](./ts/auth/AccountSignatureGuard.service.ts)). +7. Proofs can be generated with `POST v1/proof/generate` API method (see [dto spec](./ts/proof/dto.ts) and [controller](./ts/app.controller.ts)). diff --git a/coordinator/hardhat.config.ts b/coordinator/hardhat.config.ts index 6908ef8957..c860372fe6 100644 --- a/coordinator/hardhat.config.ts +++ b/coordinator/hardhat.config.ts @@ -9,26 +9,15 @@ dotenv.config(); const parentDir = __dirname.includes("build") ? ".." : ""; -const accounts = process.env.COORDINATOR_MNEMONIC - ? { - mnemonic: process.env.COORDINATOR_MNEMONIC, - path: "m/44'/60'/0'/0", - initialIndex: 0, - count: 20, - } - : undefined; // use default accounts for tests - const config: HardhatUserConfig = { defaultNetwork: "localhost", networks: { localhost: { url: process.env.COORDINATOR_RPC_URL, loggingEnabled: false, - accounts, }, hardhat: { loggingEnabled: false, - accounts, }, }, paths: { diff --git a/coordinator/package.json b/coordinator/package.json index 025093ae5d..09e1805dce 100644 --- a/coordinator/package.json +++ b/coordinator/package.json @@ -11,7 +11,6 @@ ], "scripts": { "hardhat": "hardhat node", - "prebuild": "pnpm run generate-keypair", "build": "nest build", "start": "nest start", "start:dev": "nest start --watch",