From 7ef3d12d8511c961c055ac6ca1cb7f2b80d4c698 Mon Sep 17 00:00:00 2001 From: "e.tatuzova" Date: Mon, 29 Apr 2024 05:56:21 +0400 Subject: [PATCH] Commit with console.logs #78 --- .../transpiler/templates/commitment_scheme.hpp | 9 +++++++-- .../transpiler/templates/modular_verifier.hpp | 10 +++++++--- .../transpiler/templates/permutation_argument.hpp | 3 +++ .../templates/permutation_argument_chunked.hpp | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/nil/blueprint/transpiler/templates/commitment_scheme.hpp b/include/nil/blueprint/transpiler/templates/commitment_scheme.hpp index 35839e6..65e7f6b 100644 --- a/include/nil/blueprint/transpiler/templates/commitment_scheme.hpp +++ b/include/nil/blueprint/transpiler/templates/commitment_scheme.hpp @@ -284,11 +284,16 @@ unchecked { { uint256 offset; + for(uint8 i = 0; i < batches_num;){ + console.log("Commitment"); + console.logBytes32(bytes32(commitments[i])); + i++; + } uint256 challenge2 = transcript.get_field_challenge(tr_state, modulus); + console.log("Commitment challenge from transcript", challenge2); if (challenge!= challenge2) { - console.log(challenge); - console.log(challenge2); + console.log("Challenge from proof", challenge); console.log("Wrong challenge"); return false; } diff --git a/include/nil/blueprint/transpiler/templates/modular_verifier.hpp b/include/nil/blueprint/transpiler/templates/modular_verifier.hpp index 827f17d..bd2aa2d 100644 --- a/include/nil/blueprint/transpiler/templates/modular_verifier.hpp +++ b/include/nil/blueprint/transpiler/templates/modular_verifier.hpp @@ -165,6 +165,8 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{ bytes calldata blob, uint256[] calldata public_input ) public returns (bool result) { + console.logBytes(blob[0:0x1000]); + console.log("Proof size = ", blob.length); verifier_state memory state; state.b = true; state.xi = basic_marshalling.get_uint256_be(blob, $EVAL_PROOF_OFFSET$); @@ -176,12 +178,12 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{ ); //0. Direct public input check -/* if(public_input.length > 0) { - if (!public_input_direct(blob[$TABLE_Z_OFFSET$:$TABLE_Z_OFFSET$+$QUOTIENT_OFFSET$], public_input, state)) { + if(public_input.length > 0) { + if (!public_input_direct(blob[$TABLE_OFFSET$:$TABLE_END_OFFSET$], public_input, state)) { emit WrongPublicInput(); state.b = false; } - }*/ + } //1. Init transcript types.transcript_data memory tr_state; @@ -203,6 +205,7 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{ //6. Gate argument IGateArgument modular_gate_argument = IGateArgument(_gate_argument_address); uint256 theta = transcript.get_field_challenge(tr_state, modulus); + console.log("Theta: ", theta); state.F[7] = modular_gate_argument.verify(blob[table_offset:table_end_offset], theta); state.F[7] = mulmod( state.F[7], @@ -234,6 +237,7 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{ //7. Push quotient to transcript for( uint8 i = 0; i < f_parts;){ uint256 alpha = transcript.get_field_challenge(tr_state, modulus); + console.log("Alpha: ", alpha); F_consolidated = addmod(F_consolidated, mulmod(state.F[i], alpha, modulus), modulus); unchecked{i++;} } diff --git a/include/nil/blueprint/transpiler/templates/permutation_argument.hpp b/include/nil/blueprint/transpiler/templates/permutation_argument.hpp index 53d6172..8876da7 100644 --- a/include/nil/blueprint/transpiler/templates/permutation_argument.hpp +++ b/include/nil/blueprint/transpiler/templates/permutation_argument.hpp @@ -61,12 +61,15 @@ library modular_permutation_argument_$TEST_NAME${ uint256 l0, bytes32 tr_state_before // It's better than transfer all random values ) internal view returns (uint256[3] memory F, bytes32 tr_state_after){ + console.log("Permutation argument max quotient chunks: ", max_quotient_chunks); types.transcript_data memory tr_state; tr_state.current_challenge = tr_state_before; perm_state memory state; state.beta = transcript.get_field_challenge(tr_state, modulus); state.gamma = transcript.get_field_challenge(tr_state, modulus); + console.log("Beta: ", state.beta); + console.log("Gamma: ", state.gamma); state.V_P_value = basic_marshalling.get_uint256_be(blob, table_values_offset + $PERMUTATION_TABLE_OFFSET$); state.h = 1; diff --git a/include/nil/blueprint/transpiler/templates/permutation_argument_chunked.hpp b/include/nil/blueprint/transpiler/templates/permutation_argument_chunked.hpp index 0844bea..d0e2383 100644 --- a/include/nil/blueprint/transpiler/templates/permutation_argument_chunked.hpp +++ b/include/nil/blueprint/transpiler/templates/permutation_argument_chunked.hpp @@ -64,6 +64,7 @@ library modular_permutation_argument_$TEST_NAME${ uint256 l0, bytes32 tr_state_before // It's better than transfer all random values ) internal view returns (uint256[3] memory F, bytes32 tr_state_after){ + console.log("Permutation argument(chunked) max quotient chunks: ", max_quotient_chunks); types.transcript_data memory tr_state; tr_state.current_challenge = tr_state_before; perm_state memory state;