CRACK Solution

Parity Byte

CRACK XOR reduction

In-game screenshot of Parity Byte
In-game view
FamilyCRACK Graph0.272 DifficultyEasy Ring03 IDz4_xor_parity
Accepted input PARITY00
TechniqueXOR reduction Rulenonzero SamplePARITY00

Walkthrough

Recover the accepted input below, then submit it to the CRACK verifier.

Reject Samples

  • PARITY01
  • QARITY00
  • PARITY0
  • PARITY000
  • AAAAAAAA
Verifier Listing
; z4_xor_parity: "Parity Byte". The classic XOR-reduction / longitudinal parity
; check: fold every input byte together with XOR and require the running value to
; match a single constant, exactly like an LRC checksum byte. Only the combined
; XOR matters, not the individual bytes, so two characters are pinned to make the
; intended answer unique. Technique: XOR reduction. Fits the 8-bit core exactly.
; r0 = 1 on accept. Accept rule: nonzero.
;
;   length must be 8 ; input[0] == 'P' (0x50) ; input[7] == '0' (0x30)
;   c0 ^ c1 ^ ... ^ c7 must equal 0x07
;
; sample "PARITY00": P^A^R^I^T^Y^'0'^'0' = 0x07, with the pinned first 'P' / last '0'.

        len   r2
        cmp   r2, 8
        jnz   bad           ; exactly 8 bytes

        ; --- two anchors so the parity target resolves to one word ----------
        mov   r7, 0
        ldb   r0, [r7]
        cmp   r0, 0x50      ; 'P'
        jnz   bad
        mov   r7, 7
        ldb   r0, [r7]
        cmp   r0, 0x30      ; '0'
        jnz   bad

        ; --- XOR-fold every byte into one parity value ----------------------
        mov   r3, 0         ; r3 = parity accumulator
        mov   r7, 0
xloop:  cmp   r7, 8
        jge   final
        ldb   r0, [r7]
        xor   r3, r0
        inc   r7
        jmp   xloop

final:  cmp   r3, 0x07
        jnz   bad
        mov   r0, 1
        ret
bad:    mov   r0, 0
        ret