Workspace IndexAlgorithms › Day 92

Polynomial IOPs — the trade-off between proof size and verification time TODO

Algorithms · Day 92 / 100 · F. Cryptography & ZK (Day 82-96)

Concept

A polynomial IOP (Interactive Oracle Proof) is an abstract protocol in which the prover submits polynomials as oracles and the verifier queries their evaluations at random points, reducing the correctness of a computation to a polynomial identity check. This abstraction layer discusses only completeness and soundness without using any real cryptography; once the oracles are replaced with an actual polynomial commitment scheme (PCS) and the protocol is made non-interactive via Fiat-Shamir, it becomes a concrete SNARK or STARK. That's why arithmetization (R1CS, PLONKish, AIR) is decoupled from the commitment scheme, and a system's proof size, verification time, proving time, and whether it needs a trusted setup are mostly determined by the choice of PCS. Pairing-based KZG has constant-size commitments and evaluation proofs with very fast verification, but it requires a structured trusted setup and isn't quantum-resistant. Hash-based FRI needs no trusted setup and relies only on hash assumptions, but trades that off for proof size and verification cost that grow poly-logarithmically.

On-chain verification cost scales almost directly with proof size and verifier computation, so choosing a proof system is really choosing your gas cost and trust assumptions at the same time.

Code & Formula

# 다항식 IOP — Schwartz-Zippel 보조정리: 서로 다른 두 다항식이 랜덤 점에서
# 우연히 같은 값을 낼 확률은 차수/체 크기(p)에 비례해 작아진다 (증명 크기 vs 검증 시간의 근거).

import random

p = 65537  # 작은 소수 유한체 GF(p)

def poly_eval(coeffs, x, p):
    # Horner's method, mod p
    result = 0
    for c in reversed(coeffs):
        result = (result * x + c) % p
    return result

def collision_rate(deg, trials, p):
    f = [random.randrange(p) for _ in range(deg + 1)]
    g = f.copy()
    g[0] = (g[0] + 1) % p  # f - g 는 0이 아닌 차수 deg 다항식
    hits = 0
    for _ in range(trials):
        r = random.randrange(p)
        if poly_eval(f, r, p) == poly_eval(g, r, p):
            hits += 1
    return hits / trials

trials = 20000
for deg in (1, 8, 64):
    rate = collision_rate(deg, trials, p)
    bound = deg / p  # Schwartz-Zippel 상한: 최대 deg/|F| 확률로 충돌
    print(f"deg={deg:3d}  관측 충돌률={rate:.6f}  이론 상한(deg/p)={bound:.6f}")

print("\n결론: 차수가 커질수록 충돌 확률 상한이 커지므로, 검증자가 신뢰할 수")
print("있으려면 체 크기 p 를 다항식 차수보다 충분히 크게 잡아야 한다.")

Exercise

Experiment with the Schwartz-Zippel lemma over a small finite field, and check how the probability that two different polynomials happen to agree at a random point scales with their degree relative to the field size.

Practical Connection

Compressing large volumes of off-chain matching in a prediction market into an on-chain settlement requires rollup-style validity proofs, and choosing between KZG (small proofs, needs trusted setup) and FRI (transparent, larger proofs) simultaneously decides your settlement gas cost and your security assumptions.

Where it lands in Jayverse

Key expressions

Words and phrases from this page worth keeping, with the Korean meaning and the sentence they come from.

Expression뜻 · 쓰이는 자리
trade-off상충 관계(하나를 얻으면 다른 걸 잃는 관계) · 증명 크기와 검증 시간 사이의 관계를 말할 때 · "the trade-off between proof size and verification time"
decoupled from~로부터 분리된 · 산술화 방식이 커밋먼트 스킴과 독립적일 때 · "is decoupled from the commitment scheme"
structured trusted setup구조화된 신뢰 설정(초기값을 안전하게 생성해야 하는 절차) · KZG 방식의 약점을 가리킬 때 · "requires a structured trusted setup"
quantum-resistant양자내성이 있는(양자컴퓨터 공격에 안전한) · 암호 방식의 안전성을 평가할 때 · "isn't quantum-resistant"
polynomial identity check다항식 항등식 검사 · 복잡한 계산 검증을 단순화한 결과물을 가리킬 때 · "to a polynomial identity check"
abstraction layer추상화 계층 · 실제 암호 기술과 분리된 개념적 설명 단계 · "This abstraction layer discusses only completeness and soundness"
non-interactive비대화형(질의응답 없이 한번에 완성되는) · Fiat-Shamir로 변환된 증명 방식을 가리킬 때 · "the protocol is made non-interactive via Fiat-Shamir"
scales almost directly with~에 거의 정비례해 커지다 · 온체인 검증 비용이 증명 크기에 비례할 때 · "verification cost scales almost directly with proof size"
IOP대화형 오라클 증명(Interactive Oracle Proof) · prover가 다항식을 오라클로 제출하고 verifier가 무작위 지점에서 평가값을 질의하는 추상 프로토콜 · "A polynomial IOP (Interactive Oracle Proof) is an abstract protocol"
PCS다항식 커밋먼트 스킴(Polynomial Commitment Scheme) · 증명 크기·검증 시간·신뢰설정 필요 여부를 좌우하는 핵심 구성요소 · "mostly determined by the choice of PCS"
SNARK간결한 비대화형 지식증명(Succinct Non-interactive ARgument of Knowledge) · Fiat-Shamir로 비대화형화된 구체적 증명 시스템 · "it becomes a concrete SNARK or STARK"
STARK확장 가능한 투명 지식증명(Scalable Transparent ARgument of Knowledge) · 신뢰설정 없이 해시 기반 FRI 계열로 구성되는 증명 시스템 · "it becomes a concrete SNARK or STARK"
KZGKate-Zaverucha-Goldberg 커밋먼트 · 페어링 기반의 고정크기 커밋먼트·평가증명, 검증은 빠르지만 구조화된 신뢰설정 필요 · "Pairing-based KZG has constant-size commitments"
FRIFast Reed-Solomon IOP of Proximity · 해시 기반 저차원성 검사 프로토콜, 신뢰설정은 불필요하나 증명 크기가 커짐 · "Hash-based FRI needs no trusted setup"
AIR대수적 중간표현(Algebraic Intermediate Representation) · 계산을 다항식 제약으로 표현하는 산술화 방식 중 하나 · "arithmetization (R1CS, PLONKish, AIR)"
R1CS1계수 제약 시스템(Rank-1 Constraint System) · 계산을 이차 제약식으로 표현하는 대표적 산술화 방식 · "arithmetization (R1CS, PLONKish, AIR)"

If you study this on a given day, add a note link and a ✅ to this line in the source curriculum (docs/knowledge/dev-100-curriculum.md) and this spot will lead straight to the note body. You can also write directly on this page — but regenerating overwrites it, so it's safer to keep anything you want to save as markdown under docs/algorithms/.


한국어

다항식 IOP TODO

Algorithms · Day 92 / 100 · F. 암호학·ZK (Day 82–96)

증명 크기 대 검증 시간 트레이드오프

개념

다항식 IOP(Interactive Oracle Proof)는 증명자가 다항식을 오라클로 제출하고 검증자가 무작위 점에서의 평가를 질의하는 추상 프로토콜로, 계산의 정당성을 다항식 항등식 검사로 환원한다. 이 추상 계층은 실제 암호를 쓰지 않고 완전성·건전성만 논하며, 오라클을 실제 다항식 커밋먼트 스킴(PCS)으로 바꾸고 Fiat-Shamir로 비대화형화하면 구체적인 SNARK/STARK가 된다. 그래서 산술화(R1CS, PLONKish, AIR)와 커밋먼트 방식이 분리되고, 시스템의 증명 크기·검증 시간·증명 시간·신뢰 설정 여부는 대부분 PCS 선택에서 갈린다. 페어링 기반 KZG는 커밋먼트와 평가 증명이 상수 크기이고 검증이 매우 빠르지만 구조화된 신뢰 설정이 필요하고 양자 내성이 없다. 해시 기반 FRI는 신뢰 설정이 필요 없고 해시 가정만 쓰지만 증명 크기와 검증 비용이 로그 제곱 규모로 커지는 트레이드오프를 갖는다.

온체인 검증 비용은 증명 크기와 검증자 연산량에 거의 비례하므로, 어떤 증명 시스템을 쓰느냐가 곧 가스비와 신뢰 가정의 선택이 된다.

코드 · 수식

# 다항식 IOP — Schwartz-Zippel 보조정리: 서로 다른 두 다항식이 랜덤 점에서
# 우연히 같은 값을 낼 확률은 차수/체 크기(p)에 비례해 작아진다 (증명 크기 vs 검증 시간의 근거).

import random

p = 65537  # 작은 소수 유한체 GF(p)

def poly_eval(coeffs, x, p):
    # Horner's method, mod p
    result = 0
    for c in reversed(coeffs):
        result = (result * x + c) % p
    return result

def collision_rate(deg, trials, p):
    f = [random.randrange(p) for _ in range(deg + 1)]
    g = f.copy()
    g[0] = (g[0] + 1) % p  # f - g 는 0이 아닌 차수 deg 다항식
    hits = 0
    for _ in range(trials):
        r = random.randrange(p)
        if poly_eval(f, r, p) == poly_eval(g, r, p):
            hits += 1
    return hits / trials

trials = 20000
for deg in (1, 8, 64):
    rate = collision_rate(deg, trials, p)
    bound = deg / p  # Schwartz-Zippel 상한: 최대 deg/|F| 확률로 충돌
    print(f"deg={deg:3d}  관측 충돌률={rate:.6f}  이론 상한(deg/p)={bound:.6f}")

print("\n결론: 차수가 커질수록 충돌 확률 상한이 커지므로, 검증자가 신뢰할 수")
print("있으려면 체 크기 p 를 다항식 차수보다 충분히 크게 잡아야 한다.")

연습

작은 유한체에서 Schwartz-Zippel 보조정리를 직접 실험해, 서로 다른 두 다항식이 랜덤 점에서 우연히 같은 값을 낼 확률이 차수/체 크기에 어떻게 비례하는지 확인해 볼 것.

실무 · Verex 연결

예측시장의 대량 오프체인 체결을 온체인에 압축해 정산하려면 rollup식 유효성 증명이 필요하고, 이때 KZG(작은 증명, 신뢰 설정)와 FRI(투명성, 큰 증명) 중 무엇을 고르느냐가 정산 가스와 보안 가정을 동시에 결정한다.

Jayverse에서의 위치

핵심 표현

이 페이지의 영어 본문에서 배울 만한 단어와 표현, 뜻과 나온 자리.

Expression뜻 · 쓰이는 자리
trade-off상충 관계(하나를 얻으면 다른 걸 잃는 관계) · 증명 크기와 검증 시간 사이의 관계를 말할 때 · "the trade-off between proof size and verification time"
decoupled from~로부터 분리된 · 산술화 방식이 커밋먼트 스킴과 독립적일 때 · "is decoupled from the commitment scheme"
structured trusted setup구조화된 신뢰 설정(초기값을 안전하게 생성해야 하는 절차) · KZG 방식의 약점을 가리킬 때 · "requires a structured trusted setup"
quantum-resistant양자내성이 있는(양자컴퓨터 공격에 안전한) · 암호 방식의 안전성을 평가할 때 · "isn't quantum-resistant"
polynomial identity check다항식 항등식 검사 · 복잡한 계산 검증을 단순화한 결과물을 가리킬 때 · "to a polynomial identity check"
abstraction layer추상화 계층 · 실제 암호 기술과 분리된 개념적 설명 단계 · "This abstraction layer discusses only completeness and soundness"
non-interactive비대화형(질의응답 없이 한번에 완성되는) · Fiat-Shamir로 변환된 증명 방식을 가리킬 때 · "the protocol is made non-interactive via Fiat-Shamir"
scales almost directly with~에 거의 정비례해 커지다 · 온체인 검증 비용이 증명 크기에 비례할 때 · "verification cost scales almost directly with proof size"
IOP대화형 오라클 증명(Interactive Oracle Proof) · prover가 다항식을 오라클로 제출하고 verifier가 무작위 지점에서 평가값을 질의하는 추상 프로토콜 · "A polynomial IOP (Interactive Oracle Proof) is an abstract protocol"
PCS다항식 커밋먼트 스킴(Polynomial Commitment Scheme) · 증명 크기·검증 시간·신뢰설정 필요 여부를 좌우하는 핵심 구성요소 · "mostly determined by the choice of PCS"
SNARK간결한 비대화형 지식증명(Succinct Non-interactive ARgument of Knowledge) · Fiat-Shamir로 비대화형화된 구체적 증명 시스템 · "it becomes a concrete SNARK or STARK"
STARK확장 가능한 투명 지식증명(Scalable Transparent ARgument of Knowledge) · 신뢰설정 없이 해시 기반 FRI 계열로 구성되는 증명 시스템 · "it becomes a concrete SNARK or STARK"
KZGKate-Zaverucha-Goldberg 커밋먼트 · 페어링 기반의 고정크기 커밋먼트·평가증명, 검증은 빠르지만 구조화된 신뢰설정 필요 · "Pairing-based KZG has constant-size commitments"
FRIFast Reed-Solomon IOP of Proximity · 해시 기반 저차원성 검사 프로토콜, 신뢰설정은 불필요하나 증명 크기가 커짐 · "Hash-based FRI needs no trusted setup"
AIR대수적 중간표현(Algebraic Intermediate Representation) · 계산을 다항식 제약으로 표현하는 산술화 방식 중 하나 · "arithmetization (R1CS, PLONKish, AIR)"
R1CS1계수 제약 시스템(Rank-1 Constraint System) · 계산을 이차 제약식으로 표현하는 대표적 산술화 방식 · "arithmetization (R1CS, PLONKish, AIR)"

공부한 날 원본 커리큘럼(docs/knowledge/dev-100-curriculum.md)의 이 줄에 노트 링크와 ✅ 를 붙이면, 이 자리는 노트 본문으로 바로 이어집니다. 노트 없이 이 페이지에 바로 적어도 됩니다 — 다만 다시 생성하면 덮어쓰이므로, 남길 글은 docs/algorithms/ 의 마크다운으로 쓰는 편이 안전합니다.

← 1144. 산술화1146. 재귀 증명과 증명 집계 →