primitives.expression_bytecode.expression_evaluator

Contents

primitives.expression_bytecode.expression_evaluator#

Expression bytecode evaluator for STARK constraint polynomials.

Recovered from git history (731d33f4~1) and adapted to current codebase.

Mathematical variables used throughout this module:

N – domain size (number of trace rows, = 2^n_bits) N_ext – extended domain size (= 2^n_bits_ext), used for quotient evaluation xi – challenge evaluation point (random point from Fiat-Shamir transcript) zh/Z_H – vanishing polynomial Z_H(x) = x^N - 1 zi – inverse vanishing polynomial 1/Z_H(x) o – row offset for shifted polynomial evaluation (from opening points)

Attributes#

Classes#

BufferSet

Container for flat polynomial buffers used by the bytecode evaluator.

Params

Operand specification for expression evaluation.

Dest

Destination buffer for expression results.

ExpressionsCtx

Memory layout and stride mappings for polynomial access.

ExpressionsPack

Bytecode interpreter for constraint polynomial evaluation.

Module Contents#

primitives.expression_bytecode.expression_evaluator.FastValue[source]#
primitives.expression_bytecode.expression_evaluator.NROWS_PACK = 65536[source]#
primitives.expression_bytecode.expression_evaluator.PUBLIC_INPUTS_OFFSET = 2[source]#
primitives.expression_bytecode.expression_evaluator.NUMBERS_OFFSET = 3[source]#
primitives.expression_bytecode.expression_evaluator.AIR_VALUES_OFFSET = 4[source]#
primitives.expression_bytecode.expression_evaluator.PROOF_VALUES_OFFSET = 5[source]#
primitives.expression_bytecode.expression_evaluator.AIRGROUP_VALUES_OFFSET = 6[source]#
primitives.expression_bytecode.expression_evaluator.CHALLENGES_OFFSET = 7[source]#
primitives.expression_bytecode.expression_evaluator.EVALS_OFFSET = 8[source]#
class primitives.expression_bytecode.expression_evaluator.BufferSet[source]#

Container for flat polynomial buffers used by the bytecode evaluator.

This replaces the deleted ProofContext class with a minimal set of buffers needed by the expression interpreter.

trace: numpy.ndarray[source]#
aux_trace: numpy.ndarray[source]#
const_pols: numpy.ndarray[source]#
const_pols_extended: numpy.ndarray[source]#
public_inputs: numpy.ndarray[source]#
challenges: numpy.ndarray[source]#
evals: numpy.ndarray[source]#
air_values: numpy.ndarray[source]#
airgroup_values: numpy.ndarray[source]#
proof_values: numpy.ndarray[source]#
x_div_x_sub: numpy.ndarray | None = None[source]#
custom_commits: numpy.ndarray | None = None[source]#
class primitives.expression_bytecode.expression_evaluator.Params[source]#

Operand specification for expression evaluation.

exp_id: int = 0[source]#
dim: int = 1[source]#
stage: int = 0[source]#
stage_pos: int = 0[source]#
pols_map_id: int = 0[source]#
row_offset_index: int = 0[source]#
inverse: bool = False[source]#
batch: bool = True[source]#
op: str = 'tmp'[source]#
value: int = 0[source]#
class primitives.expression_bytecode.expression_evaluator.Dest[source]#

Destination buffer for expression results.

dest: numpy.ndarray = None[source]#
exp_id: int = -1[source]#
offset: int = 0[source]#
stage_pos: int = 0[source]#
stage_cols: int = 0[source]#
expr: bool = False[source]#
dim: int = 1[source]#
domain_size: int = 0[source]#
params: list[Params] = None[source]#
class primitives.expression_bytecode.expression_evaluator.ExpressionsCtx(stark_info: protocol.stark_info.StarkInfo, prover_helpers: protocol.air_config.ProverHelpers | None = None, n_queries: int | None = None, verify: bool = False)[source]#

Memory layout and stride mappings for polynomial access.

stark_info[source]#
prover_helpers = None[source]#
n_queries = None[source]#
verify = False[source]#
xis: numpy.ndarray | None = None[source]#
next_strides[source]#
next_strides_extended[source]#
map_offsets[source]#
map_offsets_extended[source]#
map_sections_n[source]#
map_offsets_custom_fixed[source]#
map_offsets_custom_fixed_extended[source]#
map_sections_n_custom_fixed[source]#
min_row = 0[source]#
max_row[source]#
min_row_extended = 0[source]#
max_row_extended[source]#
map_offset_fri_pol[source]#
buffer_commits_size[source]#
n_stages[source]#
n_publics[source]#
n_challenges[source]#
n_evals[source]#
rows_per_batch[source]#
set_xi(xis: numpy.ndarray) None[source]#

Set xi evaluation points for FRI division.

xi = challenge evaluation point (random point from Fiat-Shamir transcript). Used to compute x/(x - xi) for FRI opening checks.

calculate_expression(buffers: BufferSet, dest: numpy.ndarray, expression_id: int, inverse: bool = False, compilation_time: bool = False) None[source]#

Evaluate a single expression into dest buffer.

abstractmethod calculate_expressions(buffers: BufferSet, dest: Dest, domain_size: int, domain_extended: bool, compilation_time: bool = False, verify_constraints: bool = False, debug: bool = False) None[source]#

Evaluate expressions across domain. Overridden by ExpressionsPack.

class primitives.expression_bytecode.expression_evaluator.ExpressionsPack(stark_info: protocol.stark_info.StarkInfo, expressions_bin: primitives.expression_bytecode.expressions_bin.ExpressionsBin, prover_helpers: protocol.air_config.ProverHelpers | None = None, nrows_pack: int = NROWS_PACK, n_queries: int | None = None, verify: bool = False)[source]#

Bases: ExpressionsCtx

Bytecode interpreter for constraint polynomial evaluation.

rows_per_batch[source]#
calculate_expressions(buffers: BufferSet, dest: Dest, domain_size: int, domain_extended: bool, compilation_time: bool = False, verify_constraints: bool = False, debug: bool = False) None[source]#

Execute bytecode to evaluate constraint expressions.