Финальная часть после тестов скорости шифрования кадров (frames)

This commit is contained in:
RoyceDa
2026-03-21 19:37:52 +02:00
parent 0c823c398f
commit 98fbabc130
2 changed files with 1 additions and 66 deletions

View File

@@ -22,12 +22,9 @@ function toUint8Array(input: KeyInput): Uint8Array {
function fillNonceFromTimestamp(nonce: Uint8Array, tsRaw: unknown): void {
nonce.fill(0);
let ts = 0n;
if (typeof tsRaw === "bigint") ts = tsRaw;
else if (typeof tsRaw === "number" && Number.isFinite(tsRaw)) ts = BigInt(Math.floor(tsRaw));
// Записываем 64-bit timestamp в первые 8 байт nonce (BE)
nonce[0] = Number((ts >> 56n) & 0xffn);
nonce[1] = Number((ts >> 48n) & 0xffn);
nonce[2] = Number((ts >> 40n) & 0xffn);