-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'prover/limitless-top-level' of github.com:Consensys/lin…
…ea-monorepo into prover/limitless-circuits-as-queries
- Loading branch information
Showing
35 changed files
with
2,634 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package accessors | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/consensys/gnark/frontend" | ||
"github.com/consensys/linea-monorepo/prover/maths/field" | ||
"github.com/consensys/linea-monorepo/prover/protocol/ifaces" | ||
"github.com/consensys/linea-monorepo/prover/protocol/query" | ||
"github.com/consensys/linea-monorepo/prover/symbolic" | ||
) | ||
|
||
const ( | ||
DISTRIBUTED_PROJECTION_ACCESSOR = "DISTRIBUTED_PROJECTION_ACCESSOR" | ||
) | ||
|
||
// FromDistributedProjectionAccessor implements [ifaces.Accessor] and accesses the result of | ||
// a [query.DISTRIBUTED_PROJECTION]. | ||
type FromDistributedProjectionAccessor struct { | ||
// Q is the underlying query whose parameters are accessed by the current | ||
// [ifaces.Accessor]. | ||
Q query.DistributedProjection | ||
} | ||
|
||
// NewDistributedProjectionAccessor creates an [ifaces.Accessor] returning the opening | ||
// point of a [query.DISTRIBUTED_PROJECTION]. | ||
func NewDistributedProjectionAccessor(q query.DistributedProjection) ifaces.Accessor { | ||
return &FromDistributedProjectionAccessor{Q: q} | ||
} | ||
|
||
// Name implements [ifaces.Accessor] | ||
func (l *FromDistributedProjectionAccessor) Name() string { | ||
return fmt.Sprintf("%v_%v", DISTRIBUTED_PROJECTION_ACCESSOR, l.Q.ID) | ||
} | ||
|
||
// String implements [github.com/consensys/linea-monorepo/prover/symbolic.Metadata] | ||
func (l *FromDistributedProjectionAccessor) String() string { | ||
return l.Name() | ||
} | ||
|
||
// GetVal implements [ifaces.Accessor] | ||
func (l *FromDistributedProjectionAccessor) GetVal(run ifaces.Runtime) field.Element { | ||
params := run.GetParams(l.Q.ID).(query.DistributedProjectionParams) | ||
return params.ScaledHorner | ||
} | ||
|
||
func (l *FromDistributedProjectionAccessor) GetValCumSumCurr(run ifaces.Runtime) field.Element { | ||
params := run.GetParams(l.Q.ID).(query.DistributedProjectionParams) | ||
return params.HashCumSumOneCurr | ||
} | ||
|
||
func (l *FromDistributedProjectionAccessor) GetValCumSumPrev(run ifaces.Runtime) field.Element { | ||
params := run.GetParams(l.Q.ID).(query.DistributedProjectionParams) | ||
return params.HashCumSumOnePrev | ||
} | ||
|
||
// GetFrontendVariable implements [ifaces.Accessor] | ||
func (l *FromDistributedProjectionAccessor) GetFrontendVariable(_ frontend.API, circ ifaces.GnarkRuntime) frontend.Variable { | ||
params := circ.GetParams(l.Q.ID).(query.GnarkDistributedProjectionParams) | ||
return params.Sum | ||
} | ||
|
||
// AsVariable implements the [ifaces.Accessor] interface | ||
func (l *FromDistributedProjectionAccessor) AsVariable() *symbolic.Expression { | ||
return symbolic.NewVariable(l) | ||
} | ||
|
||
// Round implements the [ifaces.Accessor] interface | ||
func (l *FromDistributedProjectionAccessor) Round() int { | ||
return l.Q.Round | ||
} |
68 changes: 68 additions & 0 deletions
68
prover/protocol/compiler/distributedprojection/compiler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package distributedprojection | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/consensys/linea-monorepo/prover/maths/field" | ||
"github.com/consensys/linea-monorepo/prover/protocol/coin" | ||
"github.com/consensys/linea-monorepo/prover/protocol/ifaces" | ||
"github.com/consensys/linea-monorepo/prover/protocol/query" | ||
"github.com/consensys/linea-monorepo/prover/protocol/wizard" | ||
"github.com/consensys/linea-monorepo/prover/symbolic" | ||
) | ||
|
||
func CompileDistributedProjection(comp *wizard.CompiledIOP) { | ||
|
||
for _, qName := range comp.QueriesParams.AllUnignoredKeys() { | ||
// Filter out non distributed projection queries | ||
distributedprojection, ok := comp.QueriesParams.Data(qName).(query.DistributedProjection) | ||
if !ok { | ||
continue | ||
} | ||
|
||
// This ensures that the distributed projection query is not used again in the | ||
// compilation process. We know that the query was not already ignored at the beginning | ||
// because we are iterating over the unignored keys. | ||
round := comp.QueriesParams.Round(qName) | ||
compile(comp, round, distributedprojection) | ||
} | ||
} | ||
|
||
func compile(comp *wizard.CompiledIOP, round int, distributedprojection query.DistributedProjection) { | ||
var ( | ||
pa = &distribuedProjectionProverAction{ | ||
Name: distributedprojection.ID, | ||
Query: distributedprojection, | ||
FilterA: make([]*symbolic.Expression, len(distributedprojection.Inp)), | ||
FilterB: make([]*symbolic.Expression, len(distributedprojection.Inp)), | ||
ColumnA: make([]*symbolic.Expression, len(distributedprojection.Inp)), | ||
ColumnB: make([]*symbolic.Expression, len(distributedprojection.Inp)), | ||
HornerA: make([]ifaces.Column, len(distributedprojection.Inp)), | ||
HornerB: make([]ifaces.Column, len(distributedprojection.Inp)), | ||
HornerA0: make([]query.LocalOpening, len(distributedprojection.Inp)), | ||
HornerB0: make([]query.LocalOpening, len(distributedprojection.Inp)), | ||
EvalCoins: make([]coin.Info, len(distributedprojection.Inp)), | ||
IsA: make([]bool, len(distributedprojection.Inp)), | ||
IsB: make([]bool, len(distributedprojection.Inp)), | ||
} | ||
) | ||
pa.Push(comp, distributedprojection) | ||
pa.RegisterQueries(comp, round, distributedprojection) | ||
comp.RegisterProverAction(round, pa) | ||
comp.RegisterVerifierAction(round, &distributedProjectionVerifierAction{ | ||
Name: pa.Name, | ||
Query: pa.Query, | ||
HornerA0: pa.HornerA0, | ||
HornerB0: pa.HornerB0, | ||
IsA: pa.IsA, | ||
IsB: pa.IsB, | ||
EvalCoins: pa.EvalCoins, | ||
FilterA: pa.FilterA, | ||
FilterB: pa.FilterB, | ||
CumNumOnesPrevSegmentsA: make([]big.Int, len(distributedprojection.Inp)), | ||
CumNumOnesPrevSegmentsB: make([]big.Int, len(distributedprojection.Inp)), | ||
NumOnesCurrSegmentA: make([]field.Element, len(distributedprojection.Inp)), | ||
NumOnesCurrSegmentB: make([]field.Element, len(distributedprojection.Inp)), | ||
}) | ||
|
||
} |
Oops, something went wrong.