Simplify prekey id generation

Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2026-03-05 13:31:17 -06:00
committed by GitHub
parent 7d582e92b3
commit ad31a34333
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;
}