Skip to content

Function: validateC2paSegment() ​

ts
function validateC2paSegment(
   segmentBytes, 
   sessionKeys, 
   sequenceState?
): Promise<
  | {
  nextSequenceState: SequenceState;
  result: SegmentValidationResult;
}
| null>;

Defined in: segment/validateC2paSegment.ts:51

Validates a C2PA live stream segment using the VSI/EMSG method (§19.7.3).

Extracts the EMSG box, decodes the COSE_Sign1 and VSI map, matches the session key by kid, then performs all cryptographic checks: signature verification, BMFF content hash, sequence number floor, and key validity.

Returns null if the segment does not contain a C2PA EMSG box.

A segment whose signature, content hash, or key validity does not verify returns the received sequenceState unchanged.

A duplicate, out-of-order, or below-minimum sequenceNumber fails with livevideo.segment.invalid. A gap in the sequence numbers does not fail the segment. result.sequenceResult reports the gap with its missing range.

Parameters ​

segmentBytes ​

Uint8Array

Raw segment bytes

sessionKeys ​

readonly ValidatedSessionKey[]

Available session keys from the init segment

sequenceState? ​

SequenceState = ...

Current sequence state for this stream

Returns ​

Promise< | { nextSequenceState: SequenceState; result: SegmentValidationResult; } | null>

Validation result and the sequence state for the next call, or null if no C2PA EMSG box

Throws ​

Error If the VSI EMSG box does not hold a COSE_Sign1 structure with a valid VSI map as its payload

Example ​

ts
it('returns null when segment has no C2PA EMSG box', async () => {
	const result = await validateC2paSegment(new Uint8Array(0), [])

	strictEqual(result, null)
})

A Streaming Video Technology Alliance project.