Skip to content

Commit

Permalink
Implement inFREE0
Browse files Browse the repository at this point in the history
  • Loading branch information
fractasy committed Nov 30, 2023
1 parent b3c9647 commit b634dfa
Show file tree
Hide file tree
Showing 7 changed files with 1,579 additions and 1,531 deletions.
9 changes: 6 additions & 3 deletions src/main_sm/fork_7/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace fork_7
#endif
#define CHECK_MAX_CNT_AT_THE_END

//#define LOG_COMPLETED_STEPS_TO_FILE

MainExecutor::MainExecutor (Goldilocks &fr, PoseidonGoldilocks &poseidon, const Config &config) :
fr(fr),
N(MainCommitPols::pilDegree()),
Expand Down Expand Up @@ -794,8 +796,8 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
/* FREE INPUT */
/**************/

// If inFREE, calculate the free input value, and add it to op
if (!fr.isZero(rom.line[zkPC].inFREE))
// If inFREE or inFREE0, calculate the free input value, and add it to op
if (!fr.isZero(rom.line[zkPC].inFREE) || !fr.isZero(rom.line[zkPC].inFREE0))
{
// freeInTag must be present
if (rom.line[zkPC].freeInTag.isPresent == false)
Expand Down Expand Up @@ -1989,7 +1991,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
pols.FREE7[i] = fi7;

// op = op + inFREE*fi
op0 = fr.add(op0, fr.mul(rom.line[zkPC].inFREE, fi0));
op0 = fr.add(op0, fr.mul(fr.add(rom.line[zkPC].inFREE, rom.line[zkPC].inFREE0), fi0));
op1 = fr.add(op1, fr.mul(rom.line[zkPC].inFREE, fi1));
op2 = fr.add(op2, fr.mul(rom.line[zkPC].inFREE, fi2));
op3 = fr.add(op3, fr.mul(rom.line[zkPC].inFREE, fi3));
Expand All @@ -2000,6 +2002,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,

// Copy ROM flags into the polynomials
pols.inFREE[i] = rom.line[zkPC].inFREE;
pols.inFREE0[i] = rom.line[zkPC].inFREE0;
}

if (!fr.isZero(op0) && !bProcessBatch)
Expand Down
1 change: 1 addition & 0 deletions src/main_sm/fork_7/main/rom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ void Rom::loadProgram(Goldilocks &fr, json &romJson)
if (l["inGAS"].is_string()) fr.fromString(line[i].inGAS, l["inGAS"]); else line[i].inGAS = fr.zero();
if (l["inSTEP"].is_string()) fr.fromString(line[i].inSTEP, l["inSTEP"]); else line[i].inSTEP = fr.zero();
if (l["inFREE"].is_string()) fr.fromString(line[i].inFREE, l["inFREE"]); else line[i].inFREE = fr.zero();
if (l["inFREE0"].is_string()) fr.fromString(line[i].inFREE0, l["inFREE0"]); else line[i].inFREE0 = fr.zero();
if (l["inRR"].is_string()) fr.fromString(line[i].inRR, l["inRR"]); else line[i].inRR = fr.zero();
if (l["inHASHPOS"].is_string()) fr.fromString(line[i].inHASHPOS, l["inHASHPOS"]); else line[i].inHASHPOS = fr.zero();
if (l["inCntArith"].is_string()) fr.fromString(line[i].inCntArith, l["inCntArith"]); else line[i].inCntArith = fr.zero();
Expand Down
3 changes: 2 additions & 1 deletion src/main_sm/fork_7/main/rom_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ string RomLine::toString(Goldilocks &fr)
if (!fr.isZero(inPC)) result += " inPC=" + fr.toString(inPC,10);
if (!fr.isZero(inGAS)) result += " inGAS=" + fr.toString(inGAS,10);
if (!fr.isZero(inSTEP)) result += " inSTEP=" + fr.toString(inSTEP,10);
if (!fr.isZero(inFREE))
if (!fr.isZero(inFREE) || !fr.isZero(inFREE0))
{
result += " inFREE=" + fr.toString(inFREE,10);
result += " inFREE0=" + fr.toString(inFREE0,10);
result += " freeInTag={" + freeInTag.toString() + "}";
}
if (!fr.isZero(inRR)) result += " inRR=" + fr.toString(inRR,10);
Expand Down
1 change: 1 addition & 0 deletions src/main_sm/fork_7/main/rom_line.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class RomLine {
Goldilocks::Element inGAS;
Goldilocks::Element inSTEP;
Goldilocks::Element inFREE;
Goldilocks::Element inFREE0;
Goldilocks::Element inRR;
Goldilocks::Element inHASHPOS;
Goldilocks::Element inCntArith;
Expand Down
Loading

0 comments on commit b634dfa

Please sign in to comment.