mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-17 23:34:14 +01:00
Simplify prekey id generation
This commit is contained in:
12
ts/util/wrappingAdd.std.ts
Normal file
12
ts/util/wrappingAdd.std.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user