Skip to content
This repository has been archived by the owner on Feb 17, 2025. It is now read-only.

52 add test circuit with two public columns #53

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions include/nil/blueprint/transpiler/templates/modular_verifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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(
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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);
}

Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down
Loading