From 8fed5d8d4f2ceebab77452e476404cd64ae33839 Mon Sep 17 00:00:00 2001 From: "e.tatuzova" Date: Thu, 19 Jan 2023 11:47:54 +0400 Subject: [PATCH] Columns_rotations [][] => [4][] #29 --- contracts/algebra/polynomial.sol | 17 +- .../commitments/batched_fri_verifier.sol | 7 +- .../commitments/batched_lpc_verifier.sol | 30 +++- .../components/mina_base/mina_base_gate0.sol | 2 +- .../components/mina_base/mina_base_gate1.sol | 2 +- .../components/mina_base/mina_base_gate10.sol | 2 +- .../components/mina_base/mina_base_gate11.sol | 2 +- .../components/mina_base/mina_base_gate12.sol | 2 +- .../components/mina_base/mina_base_gate13.sol | 2 +- .../components/mina_base/mina_base_gate14.sol | 2 +- .../components/mina_base/mina_base_gate15.sol | 2 +- .../components/mina_base/mina_base_gate16.sol | 2 +- .../mina_base/mina_base_gate16_1.sol | 2 +- .../components/mina_base/mina_base_gate17.sol | 2 +- .../components/mina_base/mina_base_gate18.sol | 2 +- .../components/mina_base/mina_base_gate2.sol | 2 +- .../components/mina_base/mina_base_gate3.sol | 2 +- .../components/mina_base/mina_base_gate4.sol | 2 +- .../components/mina_base/mina_base_gate5.sol | 2 +- .../components/mina_base/mina_base_gate6.sol | 2 +- .../components/mina_base/mina_base_gate7.sol | 2 +- .../components/mina_base/mina_base_gate8.sol | 2 +- .../components/mina_base/mina_base_gate9.sol | 2 +- contracts/components/mina_base_split_gen.sol | 21 ++- .../mina_scalar/mina_scalar_gate0.sol | 2 +- .../mina_scalar/mina_scalar_gate1.sol | 2 +- .../mina_scalar/mina_scalar_gate10.sol | 2 +- .../mina_scalar/mina_scalar_gate11.sol | 2 +- .../mina_scalar/mina_scalar_gate12.sol | 2 +- .../mina_scalar/mina_scalar_gate13.sol | 2 +- .../mina_scalar/mina_scalar_gate14.sol | 2 +- .../mina_scalar/mina_scalar_gate15.sol | 2 +- .../mina_scalar/mina_scalar_gate16.sol | 2 +- .../mina_scalar/mina_scalar_gate17.sol | 2 +- .../mina_scalar/mina_scalar_gate18.sol | 2 +- .../mina_scalar/mina_scalar_gate19.sol | 2 +- .../mina_scalar/mina_scalar_gate2.sol | 2 +- .../mina_scalar/mina_scalar_gate20.sol | 2 +- .../mina_scalar/mina_scalar_gate21.sol | 2 +- .../mina_scalar/mina_scalar_gate22.sol | 2 +- .../mina_scalar/mina_scalar_gate3.sol | 2 +- .../mina_scalar/mina_scalar_gate4.sol | 2 +- .../mina_scalar/mina_scalar_gate8.sol | 2 +- .../mina_scalar/mina_scalar_gate9.sol | 2 +- .../components/mina_scalar_split_gen.sol | 2 +- ...pi_unified_addition_component_calldata.sol | 6 +- contracts/components/unified_addition_gen.sol | 2 +- contracts/mina/mina_state_proof.sol | 4 +- contracts/placeholder/init_vars.sol | 2 +- .../placeholder/permutation_argument.sol | 4 +- .../placeholder/placeholder_verifier.sol | 25 +-- contracts/placeholder/proof_map_parser.sol | 4 +- .../test/public_api_mina_state_proof.sol | 4 +- ...ic_api_placeholder_mina_base_component.sol | 2 +- ..._api_placeholder_mina_scalar_component.sol | 2 +- ...placeholder_unified_addition_component.sol | 2 +- contracts/types.sol | 6 +- test/data/unified_addition_test1_params.json | 6 +- test/data/unified_addition_test2_params.json | 6 +- test/web3_mina_state_proof_test.py | 62 +++---- test/web3_placeholder_mina_base_test.py | 159 +++++------------- test/web3_placeholder_mina_scalar_test.py | 84 ++++----- web3_verify.py | 58 ++++--- 63 files changed, 286 insertions(+), 309 deletions(-) diff --git a/contracts/algebra/polynomial.sol b/contracts/algebra/polynomial.sol index 0f397ae..4157771 100644 --- a/contracts/algebra/polynomial.sol +++ b/contracts/algebra/polynomial.sol @@ -55,6 +55,21 @@ library polynomial { return result; } + /* + evaluate fixed length polynomial + */ + function evaluate4(uint256[4] memory coeffs, uint256 point, uint256 modulus) + internal pure returns (uint256) { + uint256 result; + + for( uint256 i = 0; i < 4;){ + result = mulmod(result, point, modulus); + result = addmod(result, coeffs[3 - i], modulus); + unchecked{i++;} + } + return result; + } + function evaluate_by_ptr(bytes calldata blob, uint256 offset, uint256 len, uint256 point, uint256 modulus) internal pure returns (uint256) { uint256 result; @@ -126,7 +141,7 @@ library polynomial { function mul_poly(uint256[] memory a, uint256[] memory b, uint256 modulus) internal pure returns (uint256[] memory result) { - uint256[] memory result = new uint256[](a.length + b.length - 1); + result = new uint256[](a.length + b.length - 1); for (uint256 i = 0; i < b.length;) { for (uint256 j = 0; j < a.length;) { assembly { diff --git a/contracts/commitments/batched_fri_verifier.sol b/contracts/commitments/batched_fri_verifier.sol index 743a8d0..4da0309 100644 --- a/contracts/commitments/batched_fri_verifier.sol +++ b/contracts/commitments/batched_fri_verifier.sol @@ -163,17 +163,18 @@ library batched_fri_verifier { y_ij = basic_marshalling.get_i_j_uint256_from_vector_of_vectors(blob, offset, i, j); } - function y_to_y0_for_first_step(uint256 x, uint256 y, uint256[] memory batched_U, uint256[] memory batched_V, uint256 modulus) + function y_to_y0_for_first_step(uint256 x, uint256 y, uint256[4] memory batched_U, uint256[4] memory batched_V, uint256 modulus) internal view returns(uint256 result){ uint256 U_evaluated_neg; uint256 V_evaluated_inv; - U_evaluated_neg = modulus - polynomial.evaluate( + + U_evaluated_neg = modulus - polynomial.evaluate4( batched_U, x, modulus ); V_evaluated_inv = field.inverse_static( - polynomial.evaluate( + polynomial.evaluate4( batched_V, x, modulus diff --git a/contracts/commitments/batched_lpc_verifier.sol b/contracts/commitments/batched_lpc_verifier.sol index 5c97162..206ddc9 100644 --- a/contracts/commitments/batched_lpc_verifier.sol +++ b/contracts/commitments/batched_lpc_verifier.sol @@ -205,10 +205,13 @@ library batched_lpc_verifier { z_offset = basic_marshalling.skip_length(skip_to_z(blob, offset)); if( fri_params.step_list[0] != 1){ uint256[4] memory eval4; + uint256[] memory V; + uint256[] memory U; + uint256 i; for (polynom_index = 0; polynom_index < fri_params.leaf_size;) { eval4 = evaluation_points.length == 1? evaluation_points[0]: evaluation_points[polynom_index]; - fri_params.batched_U[polynom_index] = polynomial.interpolate( + U = polynomial.interpolate( blob, eval4_to_eval(eval4), z_offset, @@ -216,6 +219,14 @@ library batched_lpc_verifier { ); z_offset = basic_marshalling.skip_vector_of_uint256_be(blob, z_offset); + fri_params.batched_U[polynom_index][0] = + fri_params.batched_U[polynom_index][1] = + fri_params.batched_U[polynom_index][2] = + fri_params.batched_U[polynom_index][3] = 0; + for(i = 0; i < eval4[0];){ + fri_params.batched_U[polynom_index][i] = U[i]; + unchecked{ i++; } + } unchecked{ polynom_index++; } } @@ -225,17 +236,26 @@ library batched_lpc_verifier { fri_params.batched_V[polynom_index] = fri_params.batched_V[0]; else{ eval4 = evaluation_points[polynom_index]; - fri_params.batched_V[polynom_index] = new uint256[](1); - fri_params.batched_V[polynom_index][0] = 1; + V = new uint256[](1); + V[0] = 1; for (point_index = 0; point_index < eval4[0];) { fri_params.lpc_z[0] = fri_params.modulus - eval4[point_index+1]; - fri_params.batched_V[polynom_index] = polynomial.mul_poly( - fri_params.batched_V[polynom_index], + V = polynomial.mul_poly( + V, fri_params.lpc_z, fri_params.modulus ); unchecked{ point_index++; } } + fri_params.batched_V[polynom_index][0] = + fri_params.batched_V[polynom_index][1] = + fri_params.batched_V[polynom_index][2] = + fri_params.batched_V[polynom_index][3] = 0; + for(i = 0; i <= eval4[0];){ + fri_params.batched_V[polynom_index][i] = V[i]; + unchecked{ i++; } + } + //require(false, logging.uint2hexstr(eval4[0])); } unchecked{ polynom_index++; } } diff --git a/contracts/components/mina_base/mina_base_gate0.sol b/contracts/components/mina_base/mina_base_gate0.sol index 1b56fb9..b38b9f5 100644 --- a/contracts/components/mina_base/mina_base_gate0.sol +++ b/contracts/components/mina_base/mina_base_gate0.sol @@ -44,7 +44,7 @@ library mina_base_gate0 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate1.sol b/contracts/components/mina_base/mina_base_gate1.sol index 7309174..012433c 100644 --- a/contracts/components/mina_base/mina_base_gate1.sol +++ b/contracts/components/mina_base/mina_base_gate1.sol @@ -42,7 +42,7 @@ library mina_base_gate1 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate10.sol b/contracts/components/mina_base/mina_base_gate10.sol index 73e3952..3c58735 100644 --- a/contracts/components/mina_base/mina_base_gate10.sol +++ b/contracts/components/mina_base/mina_base_gate10.sol @@ -41,7 +41,7 @@ library mina_base_gate10 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate11.sol b/contracts/components/mina_base/mina_base_gate11.sol index 7d42295..c7cb2f4 100644 --- a/contracts/components/mina_base/mina_base_gate11.sol +++ b/contracts/components/mina_base/mina_base_gate11.sol @@ -41,7 +41,7 @@ library mina_base_gate11 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate12.sol b/contracts/components/mina_base/mina_base_gate12.sol index ed65e86..f9ef0e0 100644 --- a/contracts/components/mina_base/mina_base_gate12.sol +++ b/contracts/components/mina_base/mina_base_gate12.sol @@ -41,7 +41,7 @@ library mina_base_gate12 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate13.sol b/contracts/components/mina_base/mina_base_gate13.sol index 0e6190b..178911f 100644 --- a/contracts/components/mina_base/mina_base_gate13.sol +++ b/contracts/components/mina_base/mina_base_gate13.sol @@ -41,7 +41,7 @@ library mina_base_gate13 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate14.sol b/contracts/components/mina_base/mina_base_gate14.sol index dc988b5..48b1c5f 100644 --- a/contracts/components/mina_base/mina_base_gate14.sol +++ b/contracts/components/mina_base/mina_base_gate14.sol @@ -40,7 +40,7 @@ library mina_base_gate14 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate15.sol b/contracts/components/mina_base/mina_base_gate15.sol index 20ca982..b671e64 100644 --- a/contracts/components/mina_base/mina_base_gate15.sol +++ b/contracts/components/mina_base/mina_base_gate15.sol @@ -40,7 +40,7 @@ library mina_base_gate15 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate16.sol b/contracts/components/mina_base/mina_base_gate16.sol index b43ff63..c9235d0 100644 --- a/contracts/components/mina_base/mina_base_gate16.sol +++ b/contracts/components/mina_base/mina_base_gate16.sol @@ -41,7 +41,7 @@ library mina_base_gate16 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate16_1.sol b/contracts/components/mina_base/mina_base_gate16_1.sol index 391246d..5aa889d 100644 --- a/contracts/components/mina_base/mina_base_gate16_1.sol +++ b/contracts/components/mina_base/mina_base_gate16_1.sol @@ -41,7 +41,7 @@ library mina_base_gate16_1 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate17.sol b/contracts/components/mina_base/mina_base_gate17.sol index 9729b50..4180e7c 100644 --- a/contracts/components/mina_base/mina_base_gate17.sol +++ b/contracts/components/mina_base/mina_base_gate17.sol @@ -41,7 +41,7 @@ library mina_base_gate17 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate18.sol b/contracts/components/mina_base/mina_base_gate18.sol index 0e638a5..8a32bf4 100644 --- a/contracts/components/mina_base/mina_base_gate18.sol +++ b/contracts/components/mina_base/mina_base_gate18.sol @@ -42,7 +42,7 @@ library mina_base_gate18 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate2.sol b/contracts/components/mina_base/mina_base_gate2.sol index 8a80c2b..4ae14c9 100644 --- a/contracts/components/mina_base/mina_base_gate2.sol +++ b/contracts/components/mina_base/mina_base_gate2.sol @@ -41,7 +41,7 @@ library mina_base_gate2 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate3.sol b/contracts/components/mina_base/mina_base_gate3.sol index b636056..798b28b 100644 --- a/contracts/components/mina_base/mina_base_gate3.sol +++ b/contracts/components/mina_base/mina_base_gate3.sol @@ -40,7 +40,7 @@ library mina_base_gate3 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate4.sol b/contracts/components/mina_base/mina_base_gate4.sol index f856daf..bc39b74 100644 --- a/contracts/components/mina_base/mina_base_gate4.sol +++ b/contracts/components/mina_base/mina_base_gate4.sol @@ -40,7 +40,7 @@ library mina_base_gate4 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate5.sol b/contracts/components/mina_base/mina_base_gate5.sol index 425d482..e089150 100644 --- a/contracts/components/mina_base/mina_base_gate5.sol +++ b/contracts/components/mina_base/mina_base_gate5.sol @@ -41,7 +41,7 @@ library mina_base_gate5 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate6.sol b/contracts/components/mina_base/mina_base_gate6.sol index c81e12a..2f706c0 100644 --- a/contracts/components/mina_base/mina_base_gate6.sol +++ b/contracts/components/mina_base/mina_base_gate6.sol @@ -41,7 +41,7 @@ library mina_base_gate6 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate7.sol b/contracts/components/mina_base/mina_base_gate7.sol index 9a3088c..8cb9309 100644 --- a/contracts/components/mina_base/mina_base_gate7.sol +++ b/contracts/components/mina_base/mina_base_gate7.sol @@ -42,7 +42,7 @@ library mina_base_gate7 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate8.sol b/contracts/components/mina_base/mina_base_gate8.sol index bea8233..0b4fac7 100644 --- a/contracts/components/mina_base/mina_base_gate8.sol +++ b/contracts/components/mina_base/mina_base_gate8.sol @@ -40,7 +40,7 @@ library mina_base_gate8 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base/mina_base_gate9.sol b/contracts/components/mina_base/mina_base_gate9.sol index a24365e..5ec567c 100644 --- a/contracts/components/mina_base/mina_base_gate9.sol +++ b/contracts/components/mina_base/mina_base_gate9.sol @@ -41,7 +41,7 @@ library mina_base_gate9 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_base_split_gen.sol b/contracts/components/mina_base_split_gen.sol index ecad0f6..215ed90 100644 --- a/contracts/components/mina_base_split_gen.sol +++ b/contracts/components/mina_base_split_gen.sol @@ -53,43 +53,48 @@ library mina_base_split_gen { bytes calldata blob, types.gate_argument_local_vars memory gate_params, types.arithmetization_params memory ar_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) internal returns (uint256 gates_evaluation) { // TODO: check witnesses number in proof profiling.start_block("mina_base_split_gen:evaluate_gates_be"); gate_params.witness_evaluations = new uint256[][](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++) { + 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); + 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 (uint256 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.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++) { + 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( blob, gate_params.offset, i + ar_params.permutation_columns + ar_params.permutation_columns, j ); + unchecked{j++;} } + unchecked{i++;} } gate_params.theta_acc = 1; diff --git a/contracts/components/mina_scalar/mina_scalar_gate0.sol b/contracts/components/mina_scalar/mina_scalar_gate0.sol index 371a75a..3c52b14 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate0.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate0.sol @@ -44,7 +44,7 @@ library mina_scalar_gate0 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate1.sol b/contracts/components/mina_scalar/mina_scalar_gate1.sol index 28195d8..da6417a 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate1.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate1.sol @@ -42,7 +42,7 @@ library mina_scalar_gate1 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate10.sol b/contracts/components/mina_scalar/mina_scalar_gate10.sol index 39d23d9..a304909 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate10.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate10.sol @@ -41,7 +41,7 @@ library mina_scalar_gate10 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate11.sol b/contracts/components/mina_scalar/mina_scalar_gate11.sol index 997340d..799a7c4 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate11.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate11.sol @@ -41,7 +41,7 @@ library mina_scalar_gate11 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate12.sol b/contracts/components/mina_scalar/mina_scalar_gate12.sol index 98fb0d4..a779312 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate12.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate12.sol @@ -41,7 +41,7 @@ library mina_scalar_gate12 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate13.sol b/contracts/components/mina_scalar/mina_scalar_gate13.sol index 0837a0a..af07b44 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate13.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate13.sol @@ -41,7 +41,7 @@ library mina_scalar_gate13 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate14.sol b/contracts/components/mina_scalar/mina_scalar_gate14.sol index 1f04912..bf2a787 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate14.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate14.sol @@ -40,7 +40,7 @@ library mina_scalar_gate14 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate15.sol b/contracts/components/mina_scalar/mina_scalar_gate15.sol index 65fefae..60a01b3 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate15.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate15.sol @@ -40,7 +40,7 @@ library mina_scalar_gate15 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate16.sol b/contracts/components/mina_scalar/mina_scalar_gate16.sol index 2a3ccc6..cb89091 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate16.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate16.sol @@ -41,7 +41,7 @@ library mina_scalar_gate16 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate17.sol b/contracts/components/mina_scalar/mina_scalar_gate17.sol index fa1d222..060cb56 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate17.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate17.sol @@ -41,7 +41,7 @@ library mina_scalar_gate17 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate18.sol b/contracts/components/mina_scalar/mina_scalar_gate18.sol index fde263c..b526cae 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate18.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate18.sol @@ -41,7 +41,7 @@ library mina_scalar_gate18 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate19.sol b/contracts/components/mina_scalar/mina_scalar_gate19.sol index e2ca7b9..4bb3e26 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate19.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate19.sol @@ -41,7 +41,7 @@ library mina_scalar_gate19 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate2.sol b/contracts/components/mina_scalar/mina_scalar_gate2.sol index 12624c9..3cedfc4 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate2.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate2.sol @@ -41,7 +41,7 @@ library mina_scalar_gate2 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate20.sol b/contracts/components/mina_scalar/mina_scalar_gate20.sol index dbba59d..a8059ee 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate20.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate20.sol @@ -41,7 +41,7 @@ library mina_scalar_gate20 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate21.sol b/contracts/components/mina_scalar/mina_scalar_gate21.sol index c854463..37fd641 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate21.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate21.sol @@ -41,7 +41,7 @@ library mina_scalar_gate21 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate22.sol b/contracts/components/mina_scalar/mina_scalar_gate22.sol index 9284d23..bb05c0c 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate22.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate22.sol @@ -41,7 +41,7 @@ library mina_scalar_gate22 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate3.sol b/contracts/components/mina_scalar/mina_scalar_gate3.sol index db6bfed..b5bd7c4 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate3.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate3.sol @@ -40,7 +40,7 @@ library mina_scalar_gate3 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate4.sol b/contracts/components/mina_scalar/mina_scalar_gate4.sol index 2f013a4..c0b12a5 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate4.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate4.sol @@ -40,7 +40,7 @@ library mina_scalar_gate4 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate8.sol b/contracts/components/mina_scalar/mina_scalar_gate8.sol index 3fb7937..538322d 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate8.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate8.sol @@ -40,7 +40,7 @@ library mina_scalar_gate8 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar/mina_scalar_gate9.sol b/contracts/components/mina_scalar/mina_scalar_gate9.sol index d4c93f9..ee83de4 100644 --- a/contracts/components/mina_scalar/mina_scalar_gate9.sol +++ b/contracts/components/mina_scalar/mina_scalar_gate9.sol @@ -41,7 +41,7 @@ library mina_scalar_gate9 { // TODO: columns_rotations could be hard-coded function evaluate_gate_be( types.gate_argument_local_vars memory gate_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) external pure returns (uint256 gates_evaluation, uint256 theta_acc) { gates_evaluation = gate_params.gates_evaluation; theta_acc = gate_params.theta_acc; diff --git a/contracts/components/mina_scalar_split_gen.sol b/contracts/components/mina_scalar_split_gen.sol index 2b96298..fc82b15 100644 --- a/contracts/components/mina_scalar_split_gen.sol +++ b/contracts/components/mina_scalar_split_gen.sol @@ -52,7 +52,7 @@ library mina_split_gen { bytes calldata blob, types.gate_argument_local_vars memory gate_params, types.arithmetization_params memory ar_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) internal returns (uint256 gates_evaluation) { // TODO: check witnesses number in proof profiling.start_block("mina_scalar_split_gen::evaluate_gates_be"); diff --git a/contracts/components/test/public_api_unified_addition_component_calldata.sol b/contracts/components/test/public_api_unified_addition_component_calldata.sol index 17b37e1..85583da 100644 --- a/contracts/components/test/public_api_unified_addition_component_calldata.sol +++ b/contracts/components/test/public_api_unified_addition_component_calldata.sol @@ -41,10 +41,8 @@ contract TestUnifiedAdditionComponent { types.gate_argument_local_vars memory gate_params; gate_params.modulus = modulus; gate_params.theta = theta; - gate_params.eval_proof_witness_offset = proof_map - .eval_proof_witness_offset; - gate_params.eval_proof_selector_offset = proof_map - .eval_proof_selector_offset; + gate_params.eval_proof_witness_offset = proof_map.eval_proof_witness_offset; + gate_params.eval_proof_selector_offset = proof_map.eval_proof_selector_offset; m_evaluation_result = unified_addition_component_gen .evaluate_gates_be(blob, gate_params, columns_rotations); diff --git a/contracts/components/unified_addition_gen.sol b/contracts/components/unified_addition_gen.sol index ddbed8d..22e4fca 100644 --- a/contracts/components/unified_addition_gen.sol +++ b/contracts/components/unified_addition_gen.sol @@ -41,7 +41,7 @@ library unified_addition_component_gen { bytes calldata blob, types.gate_argument_local_vars memory gate_params, types.arithmetization_params memory ar_params, - int256[][] memory columns_rotations + int256[4][] memory columns_rotations ) internal pure returns (uint256 gates_evaluation) { // TODO: check witnesses number in proof diff --git a/contracts/mina/mina_state_proof.sol b/contracts/mina/mina_state_proof.sol index e63a7a2..28f23ed 100644 --- a/contracts/mina/mina_state_proof.sol +++ b/contracts/mina/mina_state_proof.sol @@ -51,7 +51,7 @@ contract MinaStateProof { types.arithmetization_params arithmetization_params; } - function init_vars(test_local_vars memory vars, uint256[] memory init_params, int256[][] memory columns_rotations) internal view{ + function init_vars(test_local_vars memory vars, uint256[] memory init_params, int256[4][] memory columns_rotations) internal view{ uint256 idx = 0; vars.fri_params.modulus = init_params[idx++]; vars.fri_params.r = init_params[idx++]; @@ -112,7 +112,7 @@ contract MinaStateProof { function verify( bytes calldata blob, uint256[][] calldata init_params, - int256[][][] calldata columns_rotations + int256[4][][2] calldata columns_rotations ) public { gas_usage_t memory gas_usage; gas_usage.start = gasleft(); diff --git a/contracts/placeholder/init_vars.sol b/contracts/placeholder/init_vars.sol index 331bd36..1ef1d82 100644 --- a/contracts/placeholder/init_vars.sol +++ b/contracts/placeholder/init_vars.sol @@ -34,7 +34,7 @@ library init_vars { } function init(bytes calldata blob, uint256[] calldata init_params, - int256[][] calldata columns_rotations, vars_t memory vars) internal view { + int256[4][] calldata columns_rotations, vars_t memory vars) internal view { (vars.proof_map, vars.proof_size) = placeholder_proof_map_parser.parse_be(blob, 0); require(vars.proof_size == blob.length, "Proof is not correct!"); diff --git a/contracts/placeholder/permutation_argument.sol b/contracts/placeholder/permutation_argument.sol index 5102f81..40c9d08 100644 --- a/contracts/placeholder/permutation_argument.sol +++ b/contracts/placeholder/permutation_argument.sol @@ -191,10 +191,10 @@ library permutation_argument { ) { for ( local_vars.idx2 = 0; - local_vars.idx2 < common_data.columns_rotations[local_vars.idx1].length; + local_vars.idx2 < uint256(common_data.columns_rotations[local_vars.idx1][0]); local_vars.idx2++ ) { - if (common_data.columns_rotations[local_vars.idx1][local_vars.idx2] == 0 ) { + if (common_data.columns_rotations[local_vars.idx1][local_vars.idx2+1] == 0 ) { local_vars.zero_index = local_vars.idx2; } } diff --git a/contracts/placeholder/placeholder_verifier.sol b/contracts/placeholder/placeholder_verifier.sol index 01d98d2..e771d29 100644 --- a/contracts/placeholder/placeholder_verifier.sol +++ b/contracts/placeholder/placeholder_verifier.sol @@ -93,13 +93,13 @@ library placeholder_verifier { local_vars.evaluation_points = new uint256[4][](fri_params.leaf_size); for (uint256 i = 0; i < ar_params.witness_columns;) { - local_vars.evaluation_points[i][0] = common_data.columns_rotations[i].length; - for (uint256 j = 0; j < common_data.columns_rotations[i].length;) { - if(common_data.columns_rotations[i][j] == 0){ + local_vars.evaluation_points[i][0] = uint256(common_data.columns_rotations[i][0]); + for (uint256 j = 0; j < uint256(common_data.columns_rotations[i][0]);) { + if(common_data.columns_rotations[i][j+1] == 0){ local_vars.evaluation_points[i][j+1] = local_vars.challenge; - } else if(common_data.columns_rotations[i][j] == 1){ + } else if(common_data.columns_rotations[i][j+1] == 1){ local_vars.evaluation_points[i][j+1] = challenge_omega; - } else if(common_data.columns_rotations[i][j] == -1) { + } else if(common_data.columns_rotations[i][j+1] == -1) { local_vars.evaluation_points[i][j+1] = challenge_inversed_omega; } else { // TODO: check properly if column_rotations will be not one of 0, +-1 @@ -107,12 +107,12 @@ library placeholder_verifier { uint256 omega; uint256 e; - if (common_data.columns_rotations[i][j] < 0) { + if (common_data.columns_rotations[i][j+1] < 0) { omega = inversed_omega; - e = uint256(-common_data.columns_rotations[i][j]); + e = uint256(-common_data.columns_rotations[i][j+1]); } else { omega = common_data.omega; - e = uint256(common_data.columns_rotations[i][j]); + e = uint256(common_data.columns_rotations[i][j+1]); } assembly{ for{mstore(add(local_vars, E_OFFSET), mload(add(local_vars, CHALLENGE_OFFSET)))} gt(e,0) {e := shr(e, 1)} { @@ -138,7 +138,7 @@ library placeholder_verifier { profiling.end_block(); if (!batched_lpc_verifier.parse_verify_proof_be(blob, proof_map.eval_proof_variable_values_offset, local_vars.evaluation_points, tr_state, fri_params)) { - //require(false, "Wrong variable values LPC proof"); + require(false, "Wrong variable values LPC proof"); return false; } @@ -152,7 +152,7 @@ library placeholder_verifier { if (!batched_lpc_verifier.parse_verify_proof_be(blob, proof_map.eval_proof_permutation_offset, local_vars.evaluation_points, tr_state, fri_params)) { - // require(false, "Wrong permutation LPC proof"); + require(false, "Wrong permutation LPC proof"); return false; } profiling.end_block(); @@ -161,7 +161,7 @@ library placeholder_verifier { local_vars.evaluation_points[0] = challenge_point; if (!batched_lpc_verifier.parse_verify_proof_be(blob, proof_map.eval_proof_quotient_offset, local_vars.evaluation_points, tr_state, fri_params)) { -// require(false, "Wrong quotient LPC proof"); + require(false, "Wrong quotient LPC proof"); return false; } profiling.end_block(); @@ -169,7 +169,7 @@ library placeholder_verifier { profiling.start_block("PV::fixed"); if (!batched_lpc_verifier.parse_verify_proof_be(blob, proof_map.eval_proof_fixed_values_offset, local_vars.evaluation_points, tr_state, fri_params)) { -// require(false, "Wrong fixed values LPC proof"); + require(false, "Wrong fixed values LPC proof"); return false; } profiling.end_block(); @@ -273,6 +273,7 @@ library placeholder_verifier { ) } if (local_vars.F_consolidated != local_vars.Z_at_challenge) { + require(false, "Final check"); return false; } profiling.end_block(); diff --git a/contracts/placeholder/proof_map_parser.sol b/contracts/placeholder/proof_map_parser.sol index bbfcb19..e27b31e 100644 --- a/contracts/placeholder/proof_map_parser.sol +++ b/contracts/placeholder/proof_map_parser.sol @@ -63,8 +63,8 @@ library placeholder_proof_map_parser { function init(types.fri_params_type memory fri_params, uint256 max_leaf_size) internal pure { fri_params.batched_fri_verified_data = new bytes(0x20 * max_leaf_size); - fri_params.batched_U = new uint256[][](max_leaf_size); - fri_params.batched_V = new uint256[][](max_leaf_size); + fri_params.batched_U = new uint256[4][](max_leaf_size); + fri_params.batched_V = new uint256[4][](max_leaf_size); fri_params.lpc_z = new uint256[](2); fri_params.lpc_z[1] = 1; } diff --git a/contracts/placeholder/test/public_api_mina_state_proof.sol b/contracts/placeholder/test/public_api_mina_state_proof.sol index e7118c0..8535d83 100644 --- a/contracts/placeholder/test/public_api_mina_state_proof.sol +++ b/contracts/placeholder/test/public_api_mina_state_proof.sol @@ -44,7 +44,7 @@ contract TestMinaStateProof { types.placeholder_common_data common_data; } - function init_vars(test_local_vars memory vars, uint256[] memory init_params, int256[][] memory columns_rotations) internal view{ + function init_vars(test_local_vars memory vars, uint256[] memory init_params, int256[4][] memory columns_rotations) internal view{ uint256 idx = 0; vars.fri_params.modulus = init_params[idx++]; vars.fri_params.r = init_params[idx++]; @@ -118,7 +118,7 @@ contract TestMinaStateProof { // 8 + D_omegas_size) q_size // [..., q_i, ...] uint256[][] calldata init_params, - int256[][][] calldata columns_rotations + int256[4][][2] calldata columns_rotations ) public { profiling.start_block("public_api_mina_state_proof::verify"); test_local_vars memory vars; diff --git a/contracts/placeholder/test/public_api_placeholder_mina_base_component.sol b/contracts/placeholder/test/public_api_placeholder_mina_base_component.sol index 2750621..f025044 100644 --- a/contracts/placeholder/test/public_api_placeholder_mina_base_component.sol +++ b/contracts/placeholder/test/public_api_placeholder_mina_base_component.sol @@ -46,7 +46,7 @@ contract TestPlaceholderVerifierMinaBase { // 8 + D_omegas_size) q_size // [..., q_i, ...] uint256[] calldata init_params, - int256[][] calldata columns_rotations + int256[4][] calldata columns_rotations ) public { profiling.start_block("public_api_placeholder_mina_base_component::verify"); init_vars.vars_t memory vars; diff --git a/contracts/placeholder/test/public_api_placeholder_mina_scalar_component.sol b/contracts/placeholder/test/public_api_placeholder_mina_scalar_component.sol index b3c15c0..0b707a6 100644 --- a/contracts/placeholder/test/public_api_placeholder_mina_scalar_component.sol +++ b/contracts/placeholder/test/public_api_placeholder_mina_scalar_component.sol @@ -44,7 +44,7 @@ contract TestPlaceholderVerifierMinaScalar { // 8 + D_omegas_size) q_size // [..., q_i, ...] uint256[] calldata init_params, - int256[][] calldata columns_rotations + int256[4][] calldata columns_rotations ) public{ profiling.start_block("public_api_placeholder_mina_scalar_component::verify"); init_vars.vars_t memory vars; diff --git a/contracts/placeholder/test/public_api_placeholder_unified_addition_component.sol b/contracts/placeholder/test/public_api_placeholder_unified_addition_component.sol index 80a4a6e..68ab86e 100644 --- a/contracts/placeholder/test/public_api_placeholder_unified_addition_component.sol +++ b/contracts/placeholder/test/public_api_placeholder_unified_addition_component.sol @@ -44,7 +44,7 @@ contract TestPlaceholderVerifierUnifiedAddition { // 8 + D_omegas_size) q_size // [..., q_i, ...] uint256[] calldata init_params, - int256[][] calldata columns_rotations + int256[4][] calldata columns_rotations ) public { profiling.start_block("public_api_placeholder_unified_addition::component verify"); init_vars.vars_t memory vars; diff --git a/contracts/types.sol b/contracts/types.sol index 0570ce1..5f8c79e 100644 --- a/contracts/types.sol +++ b/contracts/types.sol @@ -162,9 +162,9 @@ library types { //0x100 uint256[] correct_order_idx; // Ordered indices to pack ys to check merkle proofs //0x120 - uint256[][] batched_U; + uint256[4][] batched_U; //0x140 - uint256[][] batched_V; + uint256[4][] batched_V; //0x160 bytes batched_fri_verified_data; @@ -297,7 +297,7 @@ library types { uint256 rows_amount; // 0x20 uint256 omega; - int256[][] columns_rotations; + int256[4][] columns_rotations; } struct placeholder_local_variables{ diff --git a/test/data/unified_addition_test1_params.json b/test/data/unified_addition_test1_params.json index 132edab..6f30d40 100644 --- a/test/data/unified_addition_test1_params.json +++ b/test/data/unified_addition_test1_params.json @@ -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_test1.json" } \ No newline at end of file diff --git a/test/data/unified_addition_test2_params.json b/test/data/unified_addition_test2_params.json index adc6c30..25b9fca 100644 --- a/test/data/unified_addition_test2_params.json +++ b/test/data/unified_addition_test2_params.json @@ -12,9 +12,9 @@ "step_list":[1, 1], "arithmetization_params":[11, 1, 1, 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_test2.json" } \ No newline at end of file diff --git a/test/web3_mina_state_proof_test.py b/test/web3_mina_state_proof_test.py index 3011460..b99f5df 100644 --- a/test/web3_mina_state_proof_test.py +++ b/test/web3_mina_state_proof_test.py @@ -4,7 +4,7 @@ test_contract_path = 'placeholder/test/public_api_mina_state_proof.sol' linked_proofs_libs_names = [] -linked_unified_addition_libs_names = [ +linked_libs_names = [ "mina_scalar_gate0", "mina_scalar_gate1", "mina_scalar_gate2", @@ -78,27 +78,29 @@ def init_test1(): params['init_params'][1].append(len(q)) params['init_params'][1].extend(q) - params['columns_rotations'][0] = [] - params['columns_rotations'][0] = [[0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, -1, ], - [0, -1, ], - [0, -1, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], - [0, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], - [0, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ]] + params['columns_rotations'][0] = [ [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [2, 0, 1, 0 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [2, 0, -1, 0], + [2, 0, -1, 0], + [2, 0, -1, 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 ], [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 ], [1, 0, 0, 0 ], [1, 0, 0, 0 ], + [1, 0, 0, 0 ], [1, 0, 0, 0 ]] + step_list = [1] * 16 params['init_params'][1].append(len(step_list)) params['init_params'][1].extend(step_list) # step_list @@ -132,14 +134,14 @@ def init_test1(): params['init_params'][2].append((len(arithmetization_params))) params['init_params'][2].extend(arithmetization_params) - + params['columns_rotations'][1] = [] for i in range(47): - params['columns_rotations'][1].append([0, ]) - params['columns_rotations'][1][0] = [0, 1, -1] - params['columns_rotations'][1][1] = [0, -1, 1] - params['columns_rotations'][1][2] = [0, 1] - params['columns_rotations'][1][5] = [0, -1] - params['columns_rotations'][1][13] = [0, 1] + params['columns_rotations'][1].append([1, 0, 0, 0 ]) + params['columns_rotations'][1][0] = [3, 0, 1, -1] + params['columns_rotations'][1][1] = [3, 0,-1, 1] + params['columns_rotations'][1][2] = [2, 0, 1, 0] + params['columns_rotations'][1][5] = [2, 0,-1, 0] + params['columns_rotations'][1][13] = [2, 0, 1, 0] params['log_file'] = 'logs/mina_state_proof.json' return params @@ -147,4 +149,4 @@ def init_test1(): if __name__ == '__main__': do_placeholder_verification_test_via_transact_simple(test_contract_name, test_contract_path, - linked_unified_addition_libs_names, init_test1) + linked_libs_names, init_test1) diff --git a/test/web3_placeholder_mina_base_test.py b/test/web3_placeholder_mina_base_test.py index c7450e3..09455b9 100644 --- a/test/web3_placeholder_mina_base_test.py +++ b/test/web3_placeholder_mina_base_test.py @@ -26,81 +26,7 @@ "mina_base_gate18", "placeholder_verifier" ] - -def init_test2(): - params = dict() - params['_test_name'] = "Placeholder proof verification for mina" - f = open(base_path + 'test/data/generated_eval15_step1_scalar.data') - params["proof"] = f.read() - f.close() - - params['init_params'] = [] - params['init_params'].append(28948022309329048855892746252171976963363056481941647379679742748393362948097) - params['init_params'].append(17) - params['init_params'].append(262143) - params['init_params'].append(1) - params['init_params'].append(262144) - params['init_params'].append(8161969249340783987761324711568624975237533050088779660262354930448819472052) - params['init_params'].append(67) - D_omegas = [ - 8161969249340783987761324711568624975237533050088779660262354930448819472052, - 3886175100316118007371640746558739196649017900618601982075775335403275343459, - 3858771995582327432623779775365915133688365037773367998141837063280219681489, - 27089958442152501875810132276080823478704708607790900112361486996955217465106, - 4962941270686734179124851736304457391480500057160355425531240539629160391514, - - 24698565941386146905064983207718127075873794584889341429041780832303738174137, - 19342635675472973030958703460855586838246018162847467754269942910820871215401, - 5032528351894390093615884424140114457150112013647720477219996067428709871325, - 22090338513913049959963172982829382927035332346328063108352787446596923585926, - 25165177819627306674965102406249393023864159703467953217189030835046387946339, - - 20406162866908888653425069393176433404558180282626759233524330349859168426307, - 24118114923975171970075748640221677083961848771131734379542430306560974812756, - 25227411734906969830001887161842150884725543104432911324890985713481442730673, - 2799975530188595297561234903824607897079093402088395318086163719444963742400, - 19366951025174438143523342051730202536500593522667444600037456491292628123146, - - 4855188899445002300170730717563617051094175372704778513906105166874447905568, - 4265513433803163958251475299683560813532603332905934989976535652412227143402, - ] - - params['init_params'].append(len(D_omegas)) - params['init_params'].extend(D_omegas) - q = [0, 0, 1] - params['init_params'].append(len(q)) - params['init_params'].extend(q) - - step_list = [1] * 17 - params['init_params'].append(len(step_list)) - params['init_params'].extend(step_list) # step_list - - arithmetization_params = [15, 1, 1, 30] # witness, public_input, constant, selector - params['init_params'].append((len(arithmetization_params))) - params['init_params'].extend(arithmetization_params) - - params['columns_rotations'] = [[0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, -1, ], - [0, -1, ], - [0, -1, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ]] - - params['log_file'] = 'logs/mina_scalar_test_eval15_step1.json' - return params - + def init_test1(): params = dict() params['_test_name'] = "Placeholder proof verification for mina" @@ -149,27 +75,28 @@ def init_test1(): params['init_params'].append((len(arithmetization_params))) params['init_params'].extend(arithmetization_params) - params['columns_rotations'] = [] - params['columns_rotations'] = [[0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, -1, ], - [0, -1, ], - [0, -1, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], - [0, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], - [0, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ]] + params['columns_rotations'] = [ [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [2, 0, 1, 0 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [2, 0, -1, 0], + [2, 0, -1, 0], + [2, 0, -1, 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 ], [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 ], [1, 0, 0, 0 ], [1, 0, 0, 0 ], + [1, 0, 0, 0 ], [1, 0, 0, 0 ]] params['log_file'] = 'logs/mina_base_test_eval1_step_1.json' @@ -226,24 +153,28 @@ def init_test2(): params['init_params'].append((len(arithmentization_params))) params['init_params'].extend(arithmentization_params) - params['columns_rotations'] = [[0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, -1, ], - [0, -1, ], - [0, -1, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ]] + params['columns_rotations'] = [ [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [2, 0, 1, 0 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [2, 0, -1, 0], + [2, 0, -1, 0], + [2, 0, -1, 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 ], [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 ], [1, 0, 0, 0 ], [1, 0, 0, 0 ], + [1, 0, 0, 0 ], [1, 0, 0, 0 ]] params['log_file'] = 'logs/mina_base_test_eval10_step_1.json' return params diff --git a/test/web3_placeholder_mina_scalar_test.py b/test/web3_placeholder_mina_scalar_test.py index 7d3788c..90e0338 100644 --- a/test/web3_placeholder_mina_scalar_test.py +++ b/test/web3_placeholder_mina_scalar_test.py @@ -72,12 +72,12 @@ def init_test1(): params['columns_rotations'] = [] for i in range(47): - params['columns_rotations'].append([0, ]) - params['columns_rotations'][0] = [0, 1, -1] - params['columns_rotations'][1] = [0, -1, 1] - params['columns_rotations'][2] = [0, 1] - params['columns_rotations'][5] = [0, -1] - params['columns_rotations'][13] = [0, 1] + params['columns_rotations'].append([1, 0, 0, 0 ]) + params['columns_rotations'][0] = [3, 0, 1, -1] + params['columns_rotations'][1] = [3, 0,-1, 1] + params['columns_rotations'][2] = [2, 0, 1, 0] + params['columns_rotations'][5] = [2, 0,-1, 0] + params['columns_rotations'][13] = [2, 0, 1, 0] params['log_file'] = 'logs/mina_scalar_test_eval1_step1.json' @@ -117,12 +117,12 @@ def init_test2(): params['columns_rotations'] = [] for i in range(47): - params['columns_rotations'].append([0, ]) - params['columns_rotations'][0] = [0, 1, -1] - params['columns_rotations'][1] = [0, -1, 1] - params['columns_rotations'][2] = [0, 1] - params['columns_rotations'][5] = [0, -1] - params['columns_rotations'][13] = [0, 1] + params['columns_rotations'].append([1, 0, 0, 0 ]) + params['columns_rotations'][0] = [3, 0, 1, -1] + params['columns_rotations'][1] = [3, 0,-1, 1] + params['columns_rotations'][2] = [2, 0, 1, 0] + params['columns_rotations'][5] = [2, 0,-1, 0] + params['columns_rotations'][13] = [2, 0, 1, 0] params['log_file'] = 'logs/mina_scalar_test_eval15_step1.json' return params @@ -171,12 +171,12 @@ def init_test3(): params['columns_rotations'] = [] for i in range(47): - params['columns_rotations'].append([0, ]) - params['columns_rotations'][0] = [0, 1, -1] - params['columns_rotations'][1] = [0, -1, 1] - params['columns_rotations'][2] = [0, 1] - params['columns_rotations'][5] = [0, -1] - params['columns_rotations'][13] = [0, 1] + params['columns_rotations'].append([1, 0, 0, 0 ]) + params['columns_rotations'][0] = [3, 0, 1, -1] + params['columns_rotations'][1] = [3, 0,-1, 1] + params['columns_rotations'][2] = [2, 0, 1, 0] + params['columns_rotations'][5] = [2, 0,-1, 0] + params['columns_rotations'][13] = [2, 0, 1, 0] params['log_file'] = 'logs/mina_scalar_test_eval1_step3_3_3_1_1.json' return params @@ -225,12 +225,12 @@ def init_test3(): params['columns_rotations'] = [] for i in range(47): - params['columns_rotations'].append([0, ]) - params['columns_rotations'][0] = [0, 1, -1] - params['columns_rotations'][1] = [0, -1, 1] - params['columns_rotations'][2] = [0, 1] - params['columns_rotations'][5] = [0, -1] - params['columns_rotations'][13] = [0, 1] + params['columns_rotations'].append([1, 0, 0, 0 ]) + params['columns_rotations'][0] = [3, 0, 1, -1] + params['columns_rotations'][1] = [3, 0,-1, 1] + params['columns_rotations'][2] = [2, 0, 1, 0] + params['columns_rotations'][5] = [2, 0,-1, 0] + params['columns_rotations'][13] = [2, 0, 1, 0] params['log_file'] = 'logs/mina_scalar_test_eval1_step3_3_3_1_1.json' return params @@ -279,12 +279,12 @@ def init_test4(): params['columns_rotations'] = [] for i in range(47): - params['columns_rotations'].append([0, ]) - params['columns_rotations'][0] = [0, 1, -1] - params['columns_rotations'][1] = [0, -1, 1] - params['columns_rotations'][2] = [0, 1] - params['columns_rotations'][5] = [0, -1] - params['columns_rotations'][13] = [0, 1] + params['columns_rotations'].append([1, 0, 0, 0 ]) + params['columns_rotations'][0] = [3, 0, 1, -1] + params['columns_rotations'][1] = [3, 0,-1, 1] + params['columns_rotations'][2] = [2, 0, 1, 0] + params['columns_rotations'][5] = [2, 0,-1, 0] + params['columns_rotations'][13] = [2, 0, 1, 0] params['log_file'] = 'logs/mina_scalar_test_eval1_step1_4_4_1_1.json' return params @@ -333,12 +333,12 @@ def init_test5(): params['columns_rotations'] = [] for i in range(47): - params['columns_rotations'].append([0, ]) - params['columns_rotations'][0] = [0, 1, -1] - params['columns_rotations'][1] = [0, -1, 1] - params['columns_rotations'][2] = [0, 1] - params['columns_rotations'][5] = [0, -1] - params['columns_rotations'][13] = [0, 1] + params['columns_rotations'].append([1, 0, 0, 0 ]) + params['columns_rotations'][0] = [3, 0, 1, -1] + params['columns_rotations'][1] = [3, 0,-1, 1] + params['columns_rotations'][2] = [2, 0, 1, 0] + params['columns_rotations'][5] = [2, 0,-1, 0] + params['columns_rotations'][13] = [2, 0, 1, 0] params['log_file'] = 'logs/mina_scalar_test_eval1_step_1_3_3_1_1_1_1.json' return params @@ -387,12 +387,12 @@ def init_test6(): params['columns_rotations'] = [] for i in range(47): - params['columns_rotations'].append([0, ]) - params['columns_rotations'][0] = [0, 1, -1] - params['columns_rotations'][1] = [0, -1, 1] - params['columns_rotations'][2] = [0, 1] - params['columns_rotations'][5] = [0, -1] - params['columns_rotations'][13] = [0, 1] + params['columns_rotations'].append([1, 0, 0, 0 ]) + params['columns_rotations'][0] = [3, 0, 1, -1] + params['columns_rotations'][1] = [3, 0,-1, 1] + params['columns_rotations'][2] = [2, 0, 1, 0] + params['columns_rotations'][5] = [2, 0,-1, 0] + params['columns_rotations'][13] = [2, 0, 1, 0] params['log_file'] = 'logs/mina_scalar_test_eval1_step_1_3_3_3_1.json' return params diff --git a/web3_verify.py b/web3_verify.py index 6783e17..0af8781 100644 --- a/web3_verify.py +++ b/web3_verify.py @@ -59,26 +59,28 @@ def init_connection(url): params['init_params'][1].extend(arithmetization_params) params['columns_rotations'][0] = [] - params['columns_rotations'][0] = [[0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, 1, -1, ], - [0, -1, ], - [0, -1, ], - [0, -1, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], - [0, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], - [0, ], - [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ], [0, ]] + params['columns_rotations'][0] = [ [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [2, 0, 1, 0 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [3, 0, 1, -1 ], + [2, 0, -1, 0], + [2, 0, -1, 0], + [2, 0, -1, 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 ], [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 ], [1, 0, 0, 0 ], [1, 0, 0, 0 ], + [1, 0, 0, 0 ], [1, 0, 0, 0 ]] params['init_params'][2] = [] params['init_params'][2].append(28948022309329048855892746252171976963363056481941647379679742748393362948097) @@ -105,16 +107,18 @@ def init_connection(url): params['init_params'][2].append((len(arithmetization_params))) params['init_params'][2].extend(arithmetization_params) + params['columns_rotations'][1] = [] for i in range(47): - params['columns_rotations'][1].append([0, ]) - params['columns_rotations'][1][0] = [0, 1, -1] - params['columns_rotations'][1][1] = [0, -1, 1] - params['columns_rotations'][1][2] = [0, 1] - params['columns_rotations'][1][5] = [0, -1] - params['columns_rotations'][1][13] = [0, 1] + params['columns_rotations'][1].append([1, 0, 0, 0 ]) + params['columns_rotations'][1][0] = [3, 0, 1, -1] + params['columns_rotations'][1][1] = [3, 0,-1, 1] + params['columns_rotations'][1][2] = [2, 0, 1, 0] + params['columns_rotations'][1][5] = [2, 0,-1, 0] + params['columns_rotations'][1][13] = [2, 0, 1, 0] + print("Placeholder proof verification for Mina aux state proof") - abi = [{'anonymous': False, 'inputs': [{'indexed': False, 'internalType': 'uint256', 'name': 'gas_usage', 'type': 'uint256'}], 'name': 'mina_gas_usage_emit', 'type': 'event'}, {'inputs': [{'internalType': 'bytes', 'name': 'blob', 'type': 'bytes'}, {'internalType': 'uint256[][]', 'name': 'init_params', 'type': 'uint256[][]'}, {'internalType': 'int256[][][]', 'name': 'columns_rotations', 'type': 'int256[][][]'}], 'name': 'verify', 'outputs': [], 'stateMutability': 'nonpayable', 'type': 'function'}] + abi = [{'anonymous': False, 'inputs': [{'indexed': False, 'internalType': 'uint256', 'name': 'gas_usage', 'type': 'uint256'}], 'name': 'mina_gas_usage_emit', 'type': 'event'}, {'inputs': [{'internalType': 'bytes', 'name': 'blob', 'type': 'bytes'}, {'internalType': 'uint256[][]', 'name': 'init_params', 'type': 'uint256[][]'}, {'internalType': 'int256[][][]', 'name': 'columns_rotations', 'type': 'int256[4][][2]'}], 'name': 'verify', 'outputs': [], 'stateMutability': 'nonpayable', 'type': 'function'}] test_contract_inst = w3.eth.contract(address=args.address, abi=abi) run_tx_hash = test_contract_inst.functions.verify(params['proof'], params['init_params'], params['columns_rotations']).transact()