From d0a2618f15dff8ff39275334cc3645e95362b48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Dr=C3=A9an?= Date: Sat, 11 Apr 2026 13:28:33 +0200 Subject: [PATCH 1/2] refactor: extract KeyGenerationResult message from GenerateKeyResponse --- README.md | 6 ++---- proto/engine/v1/engine.proto | 6 ++++++ src/grpc/grpc.types.ts | 10 ++++++++-- src/queue/key-generation.processor.ts | 8 ++++---- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a8ddfb6..34d4c22 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,8 @@ Content-Type: application/json } ``` +- `Algorithm`: see [documentation](https://shreeed-app.github.io/multi-party-computation-controller-api/enums/grpc_grpc.types.Algorithm.html) for possible enum values. + **Response:** `202 Accepted` ```json @@ -117,8 +119,6 @@ Content-Type: application/json } ``` ---- - ### `POST /signing` Enqueues a threshold-signature job. Requires a previously completed key-generation for the given `keyIdentifier`. @@ -146,8 +146,6 @@ Content-Type: application/json } ``` ---- - ### `GET /jobs/:jobId` Returns the current status of a job. The `:jobId` must be a valid UUID. diff --git a/proto/engine/v1/engine.proto b/proto/engine/v1/engine.proto index 6974e4f..4653cd3 100644 --- a/proto/engine/v1/engine.proto +++ b/proto/engine/v1/engine.proto @@ -47,6 +47,12 @@ message GenerateKeyRequest { * state. */ message GenerateKeyResponse { + /** Generated public key and public key package. */ + KeyGenerationResult result = 1; +} + +/** Key generation result containing the public key and public key package. */ +message KeyGenerationResult { /** * Canonical public key bytes. * - secp256k1 compressed: 33 bytes diff --git a/src/grpc/grpc.types.ts b/src/grpc/grpc.types.ts index 7dccc8f..4d95215 100644 --- a/src/grpc/grpc.types.ts +++ b/src/grpc/grpc.types.ts @@ -29,8 +29,8 @@ interface GenerateKeyRequest { readonly participants: number; } -/** Response from the `GenerateKey` RPC. */ -interface GenerateKeyResponse { +/** Key generation result containing the public key and public key package. */ +interface KeyGenerationResult { /** * Canonical public key bytes. * @@ -46,6 +46,11 @@ interface GenerateKeyResponse { readonly publicKeyPackage: Buffer; } +/** Response from the `GenerateKey` RPC. */ +interface GenerateKeyResponse { + readonly result: KeyGenerationResult; +} + /** Request payload for the `Sign` RPC. */ interface SignRequest { /** Must match the identifier used during `GenerateKey`. */ @@ -137,6 +142,7 @@ export { type EcdsaSignature, type GenerateKeyRequest, type GenerateKeyResponse, + type KeyGenerationResult, type SignatureResult, type SignRequest, type SignResponse, diff --git a/src/queue/key-generation.processor.ts b/src/queue/key-generation.processor.ts index c69e16d..418226e 100644 --- a/src/queue/key-generation.processor.ts +++ b/src/queue/key-generation.processor.ts @@ -70,11 +70,11 @@ class KeyGenerationProcessor extends WorkerHost { throw result.error; } - const publicKey: string = Buffer.from(result.value.publicKey).toString( - "hex", - ); + const publicKey: string = Buffer.from( + result.value.result.publicKey, + ).toString("hex"); const publicKeyPackage: string = Buffer.from( - result.value.publicKeyPackage, + result.value.result.publicKeyPackage, ).toString("base64"); // Persist key metadata immediately so the signing processor can retrieve From e10d3efcf44892ca0b409e5866234938033a8c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Dr=C3=A9an?= Date: Sat, 11 Apr 2026 13:36:54 +0200 Subject: [PATCH 2/2] fix: update key-generation processor tests to match nested GenerateKeyResponse structure --- src/queue/key-generation.processor.spec.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/queue/key-generation.processor.spec.ts b/src/queue/key-generation.processor.spec.ts index df7e804..e86f485 100644 --- a/src/queue/key-generation.processor.spec.ts +++ b/src/queue/key-generation.processor.spec.ts @@ -52,8 +52,10 @@ describe("KeyGenerationProcessor", () => { // Arrange — mock a successful gRPC response. grpcService.generateKey.mockReturnValue( okAsync({ - publicKey: PUBLIC_KEY_BYTES, - publicKeyPackage: PUBLIC_KEY_PACKAGE_BYTES, + result: { + publicKey: PUBLIC_KEY_BYTES, + publicKeyPackage: PUBLIC_KEY_PACKAGE_BYTES, + }, }), ); @@ -71,8 +73,10 @@ describe("KeyGenerationProcessor", () => { it("Returns the hex public key and base64 public key package.", async () => { grpcService.generateKey.mockReturnValue( okAsync({ - publicKey: PUBLIC_KEY_BYTES, - publicKeyPackage: PUBLIC_KEY_PACKAGE_BYTES, + result: { + publicKey: PUBLIC_KEY_BYTES, + publicKeyPackage: PUBLIC_KEY_PACKAGE_BYTES, + }, }), ); @@ -91,8 +95,10 @@ describe("KeyGenerationProcessor", () => { it("Stores key metadata immediately after a successful key generation.", async () => { grpcService.generateKey.mockReturnValue( okAsync({ - publicKey: PUBLIC_KEY_BYTES, - publicKeyPackage: PUBLIC_KEY_PACKAGE_BYTES, + result: { + publicKey: PUBLIC_KEY_BYTES, + publicKeyPackage: PUBLIC_KEY_PACKAGE_BYTES, + }, }), );