/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import type { Crypto } from "@matter/general"; import { Bytes } from "@matter/general"; /** * Check-In Protocol message codec and counter validation. * * Payload wire layout: nonce(13) ‖ AES-128-CCM(counter LE32 ‖ applicationData) ‖ MIC(16). * Nonce = first 13 bytes of HMAC-SHA256(key, counter LE32). * * @see {@link MatterSpecification.v161.Core} § 4.22.3.1 */ export declare class CheckInMessage { #private; /** * Derives the 13-byte nonce from the HMAC-SHA256 of the counter. * * @see {@link MatterSpecification.v161.Core} § 4.22.3.1 */ static generateNonce(crypto: Crypto, key: Bytes, counter: number): Promise; /** * Encodes a Check-In payload: nonce ‖ AES-128-CCM(counter LE32 ‖ applicationData). */ static encode(crypto: Crypto, key: Bytes, counter: number, applicationData: Bytes): Promise; /** * Decodes a Check-In payload and authenticates it. * * Throws {@link UnexpectedDataError} on length violations, decryption failure, or nonce mismatch. * * @see {@link MatterSpecification.v161.Core} § 4.22.4.2 */ static decode(crypto: Crypto, key: Bytes, payload: Bytes): Promise; /** * Encodes an ICD-specific Check-In payload where applicationData encodes activeModeThreshold as uint16 LE. * * @see {@link MatterSpecification.v161.Core} § 9.15.1.3.3 */ static encodeIcd(crypto: Crypto, key: Bytes, counter: number, activeModeThreshold: number): Promise; /** * Decodes an ICD-specific Check-In payload, recovering counter and activeModeThreshold. * * Throws {@link UnexpectedDataError} if applicationData is shorter than 2 bytes. * * @see {@link MatterSpecification.v161.Core} § 9.15.1.3.3 */ static decodeIcd(crypto: Crypto, key: Bytes, payload: Bytes): Promise; /** * Validates a received counter against rolling state, returning whether it is fresh and whether a key refresh * is needed. * * @see {@link MatterSpecification.v161.Core} § 4.22.3.4.1 */ static validateCounter(counter: number, state: CheckInMessage.CounterState): CheckInMessage.CounterValidation; /** * Whether a counter offset of `offset` from the key's starting counter requires a key refresh. * * @see {@link MatterSpecification.v161.Core} § 4.22.3.4.1 */ static refreshNeededAt(offset: number): boolean; } export declare namespace CheckInMessage { /** Decoded Check-In message. */ interface DecodedCheckIn { counter: number; applicationData: Bytes; } /** Decoded ICD Check-In message. */ interface DecodedIcdCheckIn { counter: number; activeModeThreshold: number; } /** * Rolling counter state used to validate that incoming Check-In counters are not replays and to detect * when the key pair must be refreshed. * * @see {@link MatterSpecification.v161.Core} § 4.22.3.4.1 */ interface CounterState { /** The starting counter value of the current key, from which offsets are measured. */ counterStart: number; /** The unsigned offset of the last accepted counter from counterStart. */ lastOffset: number; } /** Result of {@link CheckInMessage.validateCounter}. */ interface CounterValidation { /** Whether the counter is fresh (not a replay and within the valid window). */ valid: boolean; /** Unsigned distance from counterStart to counter, wrapping at 2^32. */ offset: number; /** True when offset ≥ 2^31; the caller must trigger a key refresh. */ refreshNeeded: boolean; } } //# sourceMappingURL=CheckInMessage.d.ts.map