From 817a69fab6471784578602024e19f3a10485af8f Mon Sep 17 00:00:00 2001 From: Vasiliy Olekhov Date: Fri, 10 Nov 2023 10:52:38 +0300 Subject: [PATCH] Added events and removed gas estimation from solidity code #45 NilFoundation/evm-placeholder-verification#86 --- .../transpiler/templates/modular_verifier.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/nil/blueprint/transpiler/templates/modular_verifier.hpp b/include/nil/blueprint/transpiler/templates/modular_verifier.hpp index 089b685..b75cc6f 100644 --- a/include/nil/blueprint/transpiler/templates/modular_verifier.hpp +++ b/include/nil/blueprint/transpiler/templates/modular_verifier.hpp @@ -103,7 +103,6 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{ uint256 Z_at_xi; uint256 l0; uint256[f_parts] F; - uint256 gas; bool b; } @@ -151,10 +150,9 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{ function verify( bytes calldata blob, uint256[] calldata public_input - ) public view returns (bool result) { + ) public returns (bool result) { verifier_state memory state; state.b = true; - state.gas = gasleft(); state.xi = basic_marshalling.get_uint256_be(blob, $EVAL_PROOF_OFFSET$); state.Z_at_xi = addmod(field.pow_small(state.xi, rows_amount, modulus), modulus-1, modulus); state.l0 = mulmod( @@ -166,7 +164,7 @@ 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)) { - console.log("Wrong public input!"); + emit WrongPublicInput(); state.b = false; } } @@ -225,7 +223,6 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{ F_consolidated = addmod(F_consolidated, mulmod(state.F[i],transcript.get_field_challenge(tr_state, modulus), modulus), modulus); unchecked{i++;} } - uint256 points_num = basic_marshalling.get_length(blob, $EVAL_PROOF_OFFSET$ + 0x20); transcript.update_transcript_b32_by_offset_calldata(tr_state, blob, 0x59); } @@ -241,7 +238,7 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{ if(!modular_commitment_scheme_$TEST_NAME$.verify_eval( blob[z_offset - 0x8:], commitments, state.xi, tr_state.current_challenge )) { - console.log("Error from commitment scheme!"); + emit WrongCommitment(); state.b = false; } } @@ -260,13 +257,16 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{ unchecked{i++;} } if( F_consolidated != mulmod(T_consolidated, state.Z_at_xi, modulus) ) { - console.log("Error. Table does't satisfy constraint system"); + emit ConstraintSystemNotSatisfied(); state.b = false; } - if(state.b) console.log("SUCCESS!"); else console.log("FAILURE!"); + if(state.b) { + emit ProofVerified(); + } else { + emit ProofVerificationFailed(); + } } - console.log("Gas for verification:", state.gas-gasleft()); result = state.b; } }