From 0f56377b58315dd6dee9cea0b015e24eb46eb357 Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Wed, 1 May 2024 16:26:17 +0200 Subject: [PATCH] [worker] add swapEndianness function, which doesn't work --- packages/worker-api/src/worker.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/worker-api/src/worker.ts b/packages/worker-api/src/worker.ts index 126c63ae..c108004a 100644 --- a/packages/worker-api/src/worker.ts +++ b/packages/worker-api/src/worker.ts @@ -116,7 +116,6 @@ export class Worker extends WebSocketAsPromised implements IWorker { } public async encrypt(data: Uint8Array): Promise> { - // @ts-ignore const cypherTextBuffer = await encryptWithPublicKey(data, this.shieldingKey() as CryptoKey); const cypherArray = new Uint8Array(cypherTextBuffer); return this.createType('Vec', compactAddLength(cypherArray)) @@ -156,3 +155,14 @@ export class Worker extends WebSocketAsPromised implements IWorker { return await callGetter(this, [Request.Worker, 'author_getShardVault', 'Vault'], {}, options) } } + +export function swapEndianness(uint8Array: Uint8Array): Uint8Array { + const length = uint8Array.length; + const swappedArray = new Uint8Array(length); + + for (let i = 0; i < length; i++) { + swappedArray[length - i - 1] = uint8Array[i]; + } + + return swappedArray; +}