Skip to content

Commit

Permalink
gate_params.evaluations [][]=>[4][] #29
Browse files Browse the repository at this point in the history
  • Loading branch information
e.tatuzova committed Jan 19, 2023
1 parent 8fed5d8 commit 0b4f3ee
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 63 deletions.
24 changes: 13 additions & 11 deletions contracts/components/mina_base_split_gen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,23 @@ library mina_base_split_gen {
) internal returns (uint256 gates_evaluation) {
// TODO: check witnesses number in proof
profiling.start_block("mina_base_split_gen:evaluate_gates_be");
uint256 i;
uint256 j;

gate_params.witness_evaluations = new uint256[][](ar_params.witness_columns);
gate_params.witness_evaluations = new uint256[4][](ar_params.witness_columns);
gate_params.offset = batched_lpc_verifier.skip_to_z(blob, gate_params.eval_proof_witness_offset);
for (uint256 i = 0; i < ar_params.witness_columns;) {
gate_params.witness_evaluations[i] = new uint256[](uint256(columns_rotations[i][0]));
for (uint256 j = 0; j < uint256(columns_rotations[i][0]);) {
gate_params.witness_evaluations[i][j] = basic_marshalling.get_i_j_uint256_from_vector_of_vectors(blob, gate_params.offset, i, j);
for (i = 0; i < ar_params.witness_columns;) {
gate_params.witness_evaluations[i][0] = uint256(columns_rotations[i][0]);
for (j = 0; j < uint256(columns_rotations[i][0]);) {
gate_params.witness_evaluations[i][j+1] = basic_marshalling.get_i_j_uint256_from_vector_of_vectors(blob, gate_params.offset, i, j);
unchecked{j++;}
}
unchecked{i++;}
}

gate_params.selector_evaluations = new uint256[](GATES_N);
gate_params.offset = batched_lpc_verifier.skip_to_z(blob, gate_params.eval_proof_selector_offset);
for (uint256 i = 0; i < GATES_N; ) {
for (i = 0; i < GATES_N; ) {
gate_params.selector_evaluations[i] = basic_marshalling.get_i_j_uint256_from_vector_of_vectors(
blob,
gate_params.offset,
Expand All @@ -81,12 +83,12 @@ library mina_base_split_gen {
unchecked{i++;}
}

gate_params.constant_evaluations = new uint256[][](ar_params.constant_columns);
gate_params.constant_evaluations = new uint256[4][](ar_params.constant_columns);
gate_params.offset = batched_lpc_verifier.skip_to_z(blob, gate_params.eval_proof_constant_offset);
for (uint256 i = 0; i < ar_params.constant_columns;) {
gate_params.constant_evaluations[i] = new uint256[](uint256(columns_rotations[i][0]));
for (uint256 j = 0; j < uint256(columns_rotations[i][0]);) {
gate_params.constant_evaluations[i][j] = basic_marshalling.get_i_j_uint256_from_vector_of_vectors(
for (i = 0; i < ar_params.constant_columns;) {
gate_params.constant_evaluations[i][0] = uint256(columns_rotations[i][0]);
for (j = 0; j < uint256(columns_rotations[i][0]);) {
gate_params.constant_evaluations[i][j+1] = basic_marshalling.get_i_j_uint256_from_vector_of_vectors(
blob,
gate_params.offset,
i + ar_params.permutation_columns + ar_params.permutation_columns,
Expand Down
30 changes: 19 additions & 11 deletions contracts/components/mina_scalar_split_gen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,40 +55,48 @@ library mina_split_gen {
int256[4][] memory columns_rotations
) internal returns (uint256 gates_evaluation) {
// TODO: check witnesses number in proof
uint256 i;
uint256 j;

profiling.start_block("mina_scalar_split_gen::evaluate_gates_be");

gate_params.witness_evaluations = new uint256[][](ar_params.witness_columns);
gate_params.witness_evaluations = new uint256[4][](ar_params.witness_columns);
gate_params.offset = batched_lpc_verifier.skip_to_z(blob, gate_params.eval_proof_witness_offset);
for (uint256 i = 0; i < ar_params.witness_columns; i++) {
gate_params.witness_evaluations[i] = new uint256[](columns_rotations[i].length);
for (uint256 j = 0; j < columns_rotations[i].length; j++) {
gate_params.witness_evaluations[i][j] = basic_marshalling.get_i_j_uint256_from_vector_of_vectors(blob, gate_params.offset, i, j);
for (i = 0; i < ar_params.witness_columns;) {
gate_params.witness_evaluations[i][0] = uint256(columns_rotations[i][0]);
for (j = 0; j < uint256(columns_rotations[i][0]);) {
gate_params.witness_evaluations[i][j+1] = basic_marshalling.get_i_j_uint256_from_vector_of_vectors(blob, gate_params.offset, i, j);
unchecked{j++;}
}
unchecked{i++;}
}

gate_params.selector_evaluations = new uint256[](GATES_N);
gate_params.offset = batched_lpc_verifier.skip_to_z(blob, gate_params.eval_proof_selector_offset);
for (uint256 i = 0; i < GATES_N; i++) {
for (i = 0; i < GATES_N;) {
gate_params.selector_evaluations[i] = basic_marshalling.get_i_j_uint256_from_vector_of_vectors(
blob,
gate_params.offset,
i + ar_params.permutation_columns + ar_params.permutation_columns + ar_params.constant_columns,
0
);
unchecked{i++;}
}

gate_params.constant_evaluations = new uint256[][](ar_params.constant_columns);
gate_params.constant_evaluations = new uint256[4][](ar_params.constant_columns);
gate_params.offset = batched_lpc_verifier.skip_to_z(blob, gate_params.eval_proof_constant_offset);
for (uint256 i = 0; i < ar_params.constant_columns; i++) {
gate_params.constant_evaluations[i] = new uint256[](columns_rotations[i].length);
for (uint256 j = 0; j < columns_rotations[i].length; j++) {
gate_params.constant_evaluations[i][j] = basic_marshalling.get_i_j_uint256_from_vector_of_vectors(
for (i = 0; i < ar_params.constant_columns;) {
gate_params.constant_evaluations[i][0] = uint256(columns_rotations[i][0]);
for (j = 0; j < uint256(columns_rotations[i][0]); j++) {
gate_params.constant_evaluations[i][j+1] = basic_marshalling.get_i_j_uint256_from_vector_of_vectors(
blob,
gate_params.offset,
i + ar_params.permutation_columns + ar_params.permutation_columns,
j
);
unchecked{j++;}
}
unchecked{i++;}
}

gate_params.theta_acc = 1;
Expand Down
41 changes: 3 additions & 38 deletions contracts/types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -398,46 +398,11 @@ library types {
// 0x160
uint256 offset;
// 0x180
uint256[][] witness_evaluations;
uint256[4][] witness_evaluations;
// 0x1a0
uint256[][] constant_evaluations;
uint256[4][] constant_evaluations;
// 0x1c0
uint256[][] public_input_evaluations;
// 0x1e0
uint256 eval_proof_constant_offset;
}

struct gate_argument_local_vars_updated{
// 0x0
uint256 modulus;
// 0x20
uint256 theta;
// 0x40
uint256 constraint_eval;
// 0x60
uint256 gate_eval;
// 0x80
uint256[] witness_evaluations_offsets;
// 0xa0
uint256[] selector_evaluations;
// 0xc0
uint256 eval_proof_witness_offset;
// 0xe0
uint256 eval_proof_selector_offset;
// 0x100
uint256 gates_evaluation;
// 0x120
uint256 theta_acc;
// 0x140
uint256 selector_evaluations_offset;
// 0x160
uint256 offset;
// 0x180
uint256[][] witness_evaluations;
// 0x1a0
uint256[][] constant_evaluations;
// 0x1c0
uint256[][] public_input_evaluations;
uint256[4][] public_input_evaluations;
// 0x1e0
uint256 eval_proof_constant_offset;
}
Expand Down
6 changes: 3 additions & 3 deletions test/data/unified_addition_lambda40_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"step_list":[1, 1],
"arithmetization_params":[11, 1, 0, 1 ],
"columns_rotations": [
[ 0 ],[ 0 ],[ 0 ],[ 0 ],[ 0 ],
[ 0 ],[ 0 ],[ 0 ],[ 0 ],[ 0 ],
[ 0 ],[ 0 ],[ 0 ],[ 0 ]
[ 1, 0, 0, 0 ],[ 1, 0, 0, 0 ],[ 1, 0, 0, 0 ],[ 1, 0, 0, 0 ],[ 1, 0, 0, 0 ],
[ 1, 0, 0, 0 ],[ 1, 0, 0, 0 ],[ 1, 0, 0, 0 ],[ 1, 0, 0, 0 ],[ 1, 0, 0, 0 ],
[ 1, 0, 0, 0 ],[ 1, 0, 0, 0 ],[ 1, 0, 0, 0 ],[ 1, 0, 0, 0 ]
],
"log_file":"logs/unified_addition_lambda40_test.json"
}

0 comments on commit 0b4f3ee

Please sign in to comment.