Simplify prekey id generation

This commit is contained in:
Fedor Indutny
2026-03-05 11:11:57 -08:00
committed by GitHub
parent 1a70c794e4
commit ff019a2490
3 changed files with 38 additions and 12 deletions

View File

@@ -0,0 +1,12 @@
// Copyright 2026 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
// Add two unsigned 24-bit integers and return truncated 24-bit result
export function wrappingAdd24(a: number, b: number): number {
if (!Number.isFinite(a) || !Number.isFinite(b)) {
throw new Error('Invalid arguments');
}
// eslint-disable-next-line no-bitwise
return (a + b) & 0xffffff;
}