Code Room
CodingMediumcod-g1123
Subject CryptographyLevel Mid–Senior~20 minCommon in Security interviewsIndustries Software development

Question

Implement a length-revealing-free equality routine used inside an auth check. Given two byte-value lists 'a' and 'b' (each element an int 0..255) representing a computed MAC and a provided MAC, return 1 if they are equal and 0 otherwise, but the comparison must accumulate differences over the FULL length rather than short-circuiting. If the lengths differ, return 0, but still fold every byte of the longer input into the accumulator (compare against 0 for missing positions) before returning, so the work done does not branch on the first mismatch. Return the int 1 or 0.

Implement
ct_equal(a: list[int], b: list[int]) → int
Examples
in[[1,2,3],[1,2,3]]out1
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.