PoCs

Simplicity CTF 나중에 도전

Blockstream의 첫 Simplicity CTF — 컨트랙트에 잠긴 0.01 LBTC(~$600) 해제하면 보상. Simplicity(비트코인/Liquid용 신 스마트컨트랙트 언어) 실전 학습 기회.

아직 만들지 않았습니다

이 페이지는 카드에 적힌 내용을 펼쳐 보여줄 뿐입니다 — 돌아가는 코드도, 열어볼 데모도 아직 없습니다. 무엇을 왜 만들려는지가 아래에 있습니다.

어떻게 보나

아직 범위 미정 — 시간 날 때 도전. github.com/Arvolear/simplicity-ctf (7/7 추가)

기술 노트

각 항목이 실제로 무엇을 보여주고 어떻게 동작하는지 — 위 카드보다 자세한 기술 설명입니다.

Simplicity CTF 나중에 도전준비 중

목적: Simplicity 실전 학습 기회 — 시간 날 때 도전.

동작 방식: Blockstream의 첫 Simplicity CTF — 컨트랙트에 잠긴 0.01 LBTC(~$600) 해제하면 보상.

관련 코드:
"""Simplicity CTF: a toy combinator evaluator in Simplicity's spirit --
small pure functions composed (not a stack of imperative statements) to
check an unlock condition, mirroring the CTF's "unlock the locked LBTC" goal.
"""

# Combinators: each takes an "environment" (witness bytes) and returns a value.
def unit(_env):
    return ()

def iden(env):
    return env

def comp(f, g):
    """Sequential composition: g after f."""
    return lambda env: g(f(env))

def pair(f, g):
    """Parallel composition: run f and g on the same input, pair results."""
    return lambda env: (f(env), g(env))

def case(f, g):
    """Branch on a boolean-tagged input: (True, x) -> f(x), (False, x) -> g(x)."""
    def run(env):
        tag, value = env
        return f(value) if tag else g(value)
    return run


# Build an unlock condition purely by combinator composition, Simplicity-style:
# witness = (has_preimage, preimage_bytes)
SECRET_HASH = hash("liquid-bitcoin-secret") & 0xFFFF

def check_preimage(preimage):
    return (hash(preimage) & 0xFFFF) == SECRET_HASH

def reject(_env):
    return False

unlock_program = case(
    f=lambda preimage: check_preimage(preimage),  # tag=True branch: verify preimage
    g=reject,                                       # tag=False branch: always fail
)

for label, witness in [
    ("correct preimage", (True, "liquid-bitcoin-secret")),
    ("wrong preimage", (True, "guess")),
    ("no preimage supplied", (False, None)),
]:
    unlocked = unlock_program(witness)
    print(f"{label}: witness={witness} -> unlocked={unlocked}")

docs/code/pocs/simplicity-ctf.py