From 4cae671f0db58ff4ee7c7a434ffe953ae3de3b33 Mon Sep 17 00:00:00 2001 From: arijitdutta67 Date: Thu, 20 Feb 2025 08:51:20 +0530 Subject: [PATCH] fixup: bug fix wip --- .../distributedprojection/verifier.go | 38 +++++++++++-------- .../compiler/projection/projection.go | 22 ++++++----- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/prover/protocol/compiler/distributedprojection/verifier.go b/prover/protocol/compiler/distributedprojection/verifier.go index b8e6322cf..332cfbb5d 100644 --- a/prover/protocol/compiler/distributedprojection/verifier.go +++ b/prover/protocol/compiler/distributedprojection/verifier.go @@ -59,35 +59,41 @@ func (va *distributedProjectionVerifierAction) scaledHornerCheck(run wizard.Runt ) if va.IsA[index] && va.IsB[index] { var ( - multA = field.One() - multB = field.One() + multA = field.One() + multB = field.One() + hornerA, hornerB field.Element ) - elemParam = run.GetLocalPointEvalParams(va.HornerB0[index].ID).Y - multB = run.GetRandomCoinField(va.EvalCoins[index].Name) - multB.Exp(multB, &va.CumNumOnesPrevSegmentsB[index]) - elemParam.Mul(&elemParam, &multB) - elemParam.Neg(&elemParam) - temp := run.GetLocalPointEvalParams(va.HornerA0[index].ID).Y + hornerA = run.GetLocalPointEvalParams(va.HornerA0[index].ID).Y multA = run.GetRandomCoinField(va.EvalCoins[index].Name) multA.Exp(multA, &va.CumNumOnesPrevSegmentsA[index]) - temp.Mul(&temp, &multA) - elemParam.Add(&elemParam, &temp) + hornerA.Mul(&hornerA, &multA) + elemParam.Add(&elemParam, &hornerA) + + hornerB = run.GetLocalPointEvalParams(va.HornerB0[index].ID).Y + multB = run.GetRandomCoinField(va.EvalCoins[index].Name) + multB.Exp(multB, &va.CumNumOnesPrevSegmentsB[index]) + hornerB.Mul(&elemParam, &multB) + elemParam.Sub(&elemParam, &hornerB) } else if va.IsA[index] && !va.IsB[index] { var ( - multA = field.One() + multA = field.One() + hornerA field.Element ) - elemParam = run.GetLocalPointEvalParams(va.HornerA0[index].ID).Y + hornerA = run.GetLocalPointEvalParams(va.HornerA0[index].ID).Y multA = run.GetRandomCoinField(va.EvalCoins[index].Name) multA.Exp(multA, &va.CumNumOnesPrevSegmentsA[index]) - elemParam.Mul(&elemParam, &multA) + hornerA.Mul(&hornerA, &multA) + elemParam.Add(&elemParam, &hornerA) } else if !va.IsA[index] && va.IsB[index] { var ( - multB = field.One() + multB = field.One() + hornerB field.Element ) - elemParam = run.GetLocalPointEvalParams(va.HornerB0[index].ID).Y + hornerB = run.GetLocalPointEvalParams(va.HornerB0[index].ID).Y multB = run.GetRandomCoinField(va.EvalCoins[index].Name) multB.Exp(multB, &va.CumNumOnesPrevSegmentsB[index]) - elemParam.Mul(&elemParam, &multB) + hornerB.Mul(&elemParam, &multB) + elemParam.Sub(&elemParam, &hornerB) } else { utils.Panic("Unsupported verifier action registered for %v", va.Name) } diff --git a/prover/protocol/distributed/compiler/projection/projection.go b/prover/protocol/distributed/compiler/projection/projection.go index bfe2b6e9e..72e89617a 100644 --- a/prover/protocol/distributed/compiler/projection/projection.go +++ b/prover/protocol/distributed/compiler/projection/projection.go @@ -58,7 +58,7 @@ func NewDistributeProjectionCtx( DistProjectionInput: make([]*query.DistributedProjectionInput, 0, MaxNumOfQueriesPerModule), EvalCoins: make([]coin.Info, 0, MaxNumOfQueriesPerModule), TargetModuleName: targetModuleName, - LastRoundProjection: getLastRoundPerm(initialComp), + LastRoundProjection: getLastRoundProjection(initialComp), NumSegmentsPerModule: numSegmentPerModule, QIds: make([]query.Projection, 0, MaxNumOfQueriesPerModule), } @@ -169,8 +169,8 @@ func (p *DistributeProjectionCtx) push(comp *wizard.CompiledIOP, q query.Project ColumnB: wizardutils.RandLinCombColSymbolic(alpha, q.Inp.ColumnB), FilterA: fA, FilterB: fB, - SizeA: utils.NextPowerOfTwo(q.Inp.FilterA.Size() / p.NumSegmentsPerModule), - SizeB: utils.NextPowerOfTwo(q.Inp.FilterB.Size() / p.NumSegmentsPerModule), + SizeA: q.Inp.FilterA.Size(), + SizeB: q.Inp.FilterB.Size(), EvalCoin: beta.Name, IsAInModule: true, IsBInModule: true, @@ -183,7 +183,7 @@ func (p *DistributeProjectionCtx) push(comp *wizard.CompiledIOP, q query.Project ColumnB: symbolic.NewConstant(1), FilterA: fA, FilterB: symbolic.NewConstant(1), - SizeA: q.Inp.FilterA.Size() / p.NumSegmentsPerModule, + SizeA: q.Inp.FilterA.Size(), EvalCoin: beta.Name, IsAInModule: true, IsBInModule: false, @@ -196,7 +196,7 @@ func (p *DistributeProjectionCtx) push(comp *wizard.CompiledIOP, q query.Project ColumnB: wizardutils.RandLinCombColSymbolic(alpha, q.Inp.ColumnB), FilterA: symbolic.NewConstant(1), FilterB: fB, - SizeB: q.Inp.FilterB.Size() / p.NumSegmentsPerModule, + SizeB: q.Inp.FilterB.Size(), EvalCoin: beta.Name, IsAInModule: false, IsBInModule: true, @@ -371,9 +371,11 @@ func (p *DistributeProjectionCtx) assignSumNumOnes(run *wizard.ProverRuntime) { func (p *DistributeProjectionCtx) computeScaledHorner(run *wizard.ProverRuntime) field.Element { var ( queryParam = field.Zero() - elemParam = field.Zero() ) for elemIndex, inp := range p.DistProjectionInput { + var ( + elemParam = field.Zero() + ) if inp.IsAInModule && inp.IsBInModule { var ( colABoard = inp.ColumnA.Board() @@ -392,7 +394,7 @@ func (p *DistributeProjectionCtx) computeScaledHorner(run *wizard.ProverRuntime) multA.Exp(multA, &inp.CumulativeNumOnesPrevSegmentsA) hornerA = hornerATrace[0] hornerA.Mul(&hornerA, &multA) - elemParam.Sub(&elemParam, &hornerA) + elemParam.Add(&elemParam, &hornerA) // Subtract hornerB after scaling hornerBTrace := poly.GetHornerTrace(colB, filterB, run.GetRandomCoinField(p.EvalCoins[elemIndex].Name)) hornerB = hornerBTrace[0] @@ -414,7 +416,7 @@ func (p *DistributeProjectionCtx) computeScaledHorner(run *wizard.ProverRuntime) multA.Exp(multA, &inp.CumulativeNumOnesPrevSegmentsA) hornerA = hornerATrace[0] hornerA.Mul(&hornerA, &multA) - elemParam.Sub(&elemParam, &hornerA) + elemParam.Add(&elemParam, &hornerA) } else if !inp.IsAInModule && inp.IsBInModule { var ( colBBoard = inp.ColumnB.Board() @@ -505,9 +507,9 @@ func (p *DistributeProjectionCtx) getCoinName(name string, round, queryInRound i return deriveName[coin.Name](p.QueryID(), name, round, queryInRound) } -// getLastRoundPerm scans the initialComp and looks for uncompiled projection queries. It returns +// getLastRoundProjection scans the initialComp and looks for uncompiled projection queries. It returns // the highest round found for a matched projection query. It returns -1 if no queries are found. -func getLastRoundPerm(initialComp *wizard.CompiledIOP) int { +func getLastRoundProjection(initialComp *wizard.CompiledIOP) int { var ( lastRound = -1