From 73e34f5c11494f36b332375ca4e3907630a82569 Mon Sep 17 00:00:00 2001 From: rrenkert Date: Wed, 6 Mar 2024 17:18:54 +0100 Subject: [PATCH 1/2] Prepend pub key size in cipher text --- client/src/app/gateways/vote-decrypt-gateway.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/src/app/gateways/vote-decrypt-gateway.service.ts b/client/src/app/gateways/vote-decrypt-gateway.service.ts index dc66de9cf4..fab414e1ea 100644 --- a/client/src/app/gateways/vote-decrypt-gateway.service.ts +++ b/client/src/app/gateways/vote-decrypt-gateway.service.ts @@ -350,10 +350,11 @@ export class VoteDecryptGatewayService { } private createPayload(ephPublKey: Uint8Array, nonce: Uint8Array, encrypted: Uint8Array): string { - const payload = new Uint8Array(this._publicKeySize + this._nonceSize + encrypted.length); - payload.set(ephPublKey.slice(0, this._publicKeySize)); - payload.set(nonce, this._publicKeySize); - payload.set(encrypted, this._publicKeySize + this._nonceSize); + const payload = new Uint8Array(this._publicKeySize + this._nonceSize + encrypted.length + 1); + payload.set([this._publicKeySize]) + payload.set(ephPublKey.slice(0, this._publicKeySize), 1); + payload.set(nonce, this._publicKeySize + 1); + payload.set(encrypted, this._publicKeySize + this._nonceSize + 1); return btoa(String.fromCharCode(...payload)); } } From 0e0a02da1a27d04dda558dc81799206d5b4cef3f Mon Sep 17 00:00:00 2001 From: rrenkert Date: Wed, 6 Mar 2024 17:28:47 +0100 Subject: [PATCH 2/2] Fixed linting --- client/src/app/gateways/vote-decrypt-gateway.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/app/gateways/vote-decrypt-gateway.service.ts b/client/src/app/gateways/vote-decrypt-gateway.service.ts index fab414e1ea..623359f4e5 100644 --- a/client/src/app/gateways/vote-decrypt-gateway.service.ts +++ b/client/src/app/gateways/vote-decrypt-gateway.service.ts @@ -351,7 +351,7 @@ export class VoteDecryptGatewayService { private createPayload(ephPublKey: Uint8Array, nonce: Uint8Array, encrypted: Uint8Array): string { const payload = new Uint8Array(this._publicKeySize + this._nonceSize + encrypted.length + 1); - payload.set([this._publicKeySize]) + payload.set([this._publicKeySize]); payload.set(ephPublKey.slice(0, this._publicKeySize), 1); payload.set(nonce, this._publicKeySize + 1); payload.set(encrypted, this._publicKeySize + this._nonceSize + 1);