# CONSTANTS # ================================================================================================= # General constants const.ROOT_UNITY=7277203076849721926 const.DOMAIN_OFFSET=7 const.DOMAIN_OFFSET_INV=2635249152773512046 # MEMORY POINTERS # ================================================================================================= # Trace domain generator const.TRACE_DOMAIN_GENERATOR_PTR=4294799999 # Public inputs const.PUBLIC_INPUTS_PTR=4294800000 # OOD Frames # (72 + 9 + 8) * 2 * 2 Felt for current and next trace rows and 8 * 2 Felt for constraint composition # polynomials. Total memory slots required: ((72 + 9 + 8) * 2 * 2 + 8 * 2) / 4 = 93 const.OOD_TRACE_PTR=4294900000 const.OOD_CONSTRAINT_EVALS_PTR=4294900081 # Current trace row # 72 Felt for main portion of trace, 9 * 2 Felt for auxiliary portion of trace and 8 * 2 Felt for # constraint composition polynomials. Since we store these with the padding to make each of the # three portions a multiple of 8, the number of slots required is (80 + 24 + 16) / 4 = 30 const.CURRENT_TRACE_ROW_PTR=4294900100 # Random elements # There are are currently 16 ExtFelt for a total of 32 Felt. Thus the number of slots required is 8. const.AUX_RAND_ELEM_PTR=4294900150 # We need 2 Felt for each constraint. We take 2800 slots as an upper bound const.COMPOSITION_COEF_PTR=4294900200 # We need 2 Felt for each trace column and each of the 8 constraint composition columns. We thus need # (72 + 9 + 8) * 2 Felt i.e. 44 memory slots. const.DEEP_RAND_CC_PTR=4294903000 # FRI # # (FRI_COM_PTR - 100) ---| # . # . | <- FRI queries # . # FRI_COM_PTR ---| # . # . | <- FRI layer commitments and folding challenges # . # (FRI_COM_PTR + 32) ---| # . # . | <- Remainder codeword and polynomial # . # (FRI_COM_PTR + 66-1) ---| # # For each FRI layer, we need 2 memory slots, one for storing the FRI layer commitment and one for # storing the word [a0, a1, log2(lde_size), lde_size] where a := (a0, a1) is the folding randomness # and lde_size is the size of the LDE domain. Since we are using a folding factor of 4 and the # maximal degree of the remainder polynomial that we allow is 7, an upper limit of 16 FRI layers is # ample and the number of memory slots we thus allocate for this is 32. Moreover, we allocate # an additional 32 slots for the remainder codeword and 2 for the remainder polynomial. These are # expected to be laid out right after the FRI commitments. # The total number of slots thus becomes 66. const.FRI_COM_PTR=4294903200 # Commitment to main, auxiliary and composition polynomials traces const.MAIN_TRACE_COM_PTR=4294903300 const.AUX_TRACE_COM_PTR=4294903301 const.COMPOSITION_POLY_COM_PTR=4294903302 # Instant-specific constants const.LDE_SIZE_PTR=4294903303 const.Z_PTR=4294903304 const.NUM_QUERIES_PTR=4294903305 const.TRACE_LENGTH_PTR=4294903306 const.TRACE_LENGTH_LOG_PTR=4294903307 const.GRINDING_FACTOR_PTR=4294903308 # RPO capacity initialization words const.ZERO_WORD_PTR=4294903309 const.ZERO_ZERO_ZERO_ONE_PTR=4294903310 # State of RPO-based random coin const.C_PTR=4294903311 const.R1_PTR=4294903312 const.R2_PTR=4294903313 # Address used for storing temporary values: const.TMP1=4294903315 const.TMP2=4294903316 const.TMP3=4294903317 const.TMP4=4294903318 const.TMP5=4294903319 const.TMP6=4294903320 const.TMP7=4294903321 const.TMP8=4294903322 # The following is a table summarizing the memory pointers used: # +------------------------------------------+-------------------------+ # | ID | Address | # +------------------------------------------+-------------------------+ # | TRACE_DOMAIN_GENERATOR_PTR | 4294799999 | # | PUBLIC_INPUTS_PTR | 4294800000 | # | OOD_TRACE_PTR | 4294900000 | # | OOD_CONSTRAINT_EVALS_PTR | 4294900081 | # | CURRENT_TRACE_ROW_PTR | 4294900100 | # | AUX_RAND_ELEM_PTR | 4294900150 | # | COMPOSITION_COEF_PTR | 4294900200 | # | DEEP_RAND_CC_PTR | 4294903000 | # | FRI_COM_PTR | 4294903200 | # | MAIN_TRACE_COM_PTR | 4294903300 | # | AUX_TRACE_COM_PTR | 4294903301 | # | COMPOSITION_POLY_COM_PTR | 4294903302 | # | LDE_SIZE_PTR | 4294903303 | # | Z_PTR | 4294903304 | # | NUM_QUERIES_PTR | 4294903305 | # | TRACE_LENGTH_PTR | 4294903306 | # | TRACE_LENGTH_LOG_PTR | 4294903307 | # | GRINDING_FACTOR_PTR | 4294903308 | # | ZERO_WORD_PTR | 4294903309 | # | ZERO_ZERO_ZERO_ONE_PTR | 4294903310 | # | C_PTR | 4294903311 | # | R1_PTR | 4294903312 | # | R2_PTR | 4294903313 | # | TMP1 | 4294903315 | # | TMP2 | 4294903316 | # | TMP3 | 4294903317 | # | TMP4 | 4294903318 | # | TMP5 | 4294903319 | # | TMP6 | 4294903320 | # | TMP7 | 4294903321 | # | TMP8 | 4294903322 | # +------------------------------------------+-------------------------+ # ACCESSORS # ================================================================================================= export.root_unity push.ROOT_UNITY end # Procedure to push the trace domain generator address to the stack. # # Input: [...] # Output: [ptr, ...] wher ptr is the memory address of the trace domain generator # Cycles: 1 export.trace_domain_generator_ptr push.TRACE_DOMAIN_GENERATOR_PTR end export.domain_offset push.DOMAIN_OFFSET end export.domain_offset_inv push.DOMAIN_OFFSET_INV end export.public_inputs_ptr push.PUBLIC_INPUTS_PTR end export.ood_trace_ptr push.OOD_TRACE_PTR end export.ood_constraint_evals_ptr push.OOD_CONSTRAINT_EVALS_PTR end export.current_trace_row_ptr push.CURRENT_TRACE_ROW_PTR end export.aux_rand_elem_ptr push.AUX_RAND_ELEM_PTR end export.composition_coef_ptr push.COMPOSITION_COEF_PTR end export.deep_rand_coef_ptr push.DEEP_RAND_CC_PTR end export.fri_com_ptr push.FRI_COM_PTR end export.main_trace_com_ptr push.MAIN_TRACE_COM_PTR end export.aux_trace_com_ptr push.AUX_TRACE_COM_PTR end export.composition_poly_com_ptr push.COMPOSITION_POLY_COM_PTR end #! Address to store details about the lde size. #! #! Memory is `[lde_size, log(lde_size), lde_g, 0]` export.lde_size_ptr push.LDE_SIZE_PTR end #! Address for the point `z` and its exponentiation `z^N` where `N=trace_len`. #! #! Memory is `[(z_1, z_0)^n, z_1, z_0]` export.z_ptr push.Z_PTR end export.number_queries_ptr push.NUM_QUERIES_PTR end export.trace_length_ptr push.TRACE_LENGTH_PTR end export.trace_length_log_ptr push.TRACE_LENGTH_LOG_PTR end export.grinding_factor_ptr push.GRINDING_FACTOR_PTR end export.zero_word push.ZERO_WORD_PTR end export.zero_zero_zero_one_word push.ZERO_ZERO_ZERO_ONE_PTR end #! Returns the pointer to the capacity word of the random coin. #! #! Note: The random coin is implemented using a hash function, this returns the #! capacity portion of the RPO. export.c_ptr push.C_PTR end #! Returns the pointer to the first rate word of the random coin. #! #! Note: The random coin is implemented using a hash function, this returns the #! first rate word of the RPO. export.r1_ptr push.R1_PTR end #! Returns the pointer to the second rate word of the random coin. #! #! Note: The random coin is implemented using a hash function, this returns the #! second rate word of the RPO. export.r2_ptr push.R2_PTR end #! Address to store details to compute deep query denominators. #! #! Memory is `[gz1, gz0, z_1, z_0]` export.tmp1 push.TMP1 end export.tmp2 push.TMP2 end export.tmp3 push.TMP3 end export.tmp4 push.TMP4 end export.tmp5 push.TMP5 end export.tmp6 push.TMP6 end export.tmp7 push.TMP7 end export.tmp8 push.TMP8 end