Skip to content

Commit

Permalink
[worker] add swapEndianness function, which doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
clangenb committed May 1, 2024
1 parent b6ee1c4 commit 0f56377
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/worker-api/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export class Worker extends WebSocketAsPromised implements IWorker {
}

public async encrypt(data: Uint8Array): Promise<Vec<u8>> {
// @ts-ignore
const cypherTextBuffer = await encryptWithPublicKey(data, this.shieldingKey() as CryptoKey);
const cypherArray = new Uint8Array(cypherTextBuffer);
return this.createType('Vec<u8>', compactAddLength(cypherArray))
Expand Down Expand Up @@ -156,3 +155,14 @@ export class Worker extends WebSocketAsPromised implements IWorker {
return await callGetter<Vault>(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;
}

0 comments on commit 0f56377

Please sign in to comment.