CRACK Solution

Digest Lock

CRACK hash-equality gate (djb2)

In-game screenshot of Digest Lock
In-game view
FamilyCRACK Graph0.893 DifficultyHard Ring05 IDz2_hash_gate

Prerequisites

FLOW CONTROL

Unlocks

GRAY WALK

Accepted input opcode
Techniquehash-equality gate (djb2) Rulenonzero Sampleopcode

Walkthrough

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

Reject Samples

  • OPCODE
  • decode
  • opcods
  • opcod
  • opcodes
  • syscal
Verifier Listing
; z2_hash_gate: a hash-equality gate. There are no per-character comparisons:
; the whole input is folded into one number by the djb2 rolling hash and that
; number is checked against a single magic constant. The djb2 fingerprint is a
; 5381 seed and a times-33 step (acc = acc*33 + c). The length must be 6, and the
; fold must equal the baked magic. The player recognizes the hash, reads the
; magic, and finds a 6-character word that produces it. The intended preimage is
; "opcode". r0 = 1 on accept; rule: nonzero.
;
; SUBSTITUTION NOTE (8-bit faithful shrink): the original compared a full 32-bit
; djb2 against 0x12EE89FF. That 32-bit accumulator cannot live in a byte, so this
; folds with the SAME djb2 recurrence (seed 5381, *33, + byte) reduced mod 256
; and compares against the magic LOW BYTE 0xFF. The hash-gate technique: fold
; the whole string, compare to one constant, recover a fixed-length preimage: ; is preserved; "opcode" folds to 0xFF mod 256 and is the intended preimage.

        len   r2
        cmp   r2, 6
        jnz   bad           ; preimage length is 6

        ; --- djb2 fold over the whole input, mod 256 --------------------
        mov   r3, 5         ; seed 5381 low byte = 0x05
        mov   r7, 0
loop:   cmp   r7, 6
        jge   gate
        ldb   r0, [r7]
        mul   r3, 33        ; acc *= 33  (low byte)
        add   r3, r0        ; acc += byte
        inc   r7
        jmp   loop

        ; --- compare the fold to the magic (0xFF) -----------------------
gate:   cmp   r3, 0xFF
        jnz   bad

        mov   r0, 1
        ret
bad:    mov   r0, 0
        ret