-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prover/Adding Initial Compiler for Permutation Query #386
Draft
arijitdutta67
wants to merge
8
commits into
prover/limitless-top-level
Choose a base branch
from
prover/permutation-initial-wizard
base: prover/limitless-top-level
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
20df8d4
commit all ideas
AlexandreBelling 16fbcd9
added aggregator
Soleimani193 a199f4d
initial framework added
arijitdutta67 3afad76
added grand product query
arijitdutta67 9211a6a
Added initial framework of the grand prod query
arijitdutta67 a782abd
added list format for num and den
arijitdutta67 6e9ac0b
module discoverer is added
arijitdutta67 4f3fe25
added a test, not working yet
arijitdutta67 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,7 @@ | ||
package global | ||
|
||
import "github.com/consensys/linea-monorepo/prover/protocol/wizard" | ||
|
||
func IntoDistributedGlobal(comp *wizard.CompiledIOP) { | ||
panic("unimplemented") | ||
} |
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,7 @@ | ||
package inclusion | ||
|
||
import "github.com/consensys/linea-monorepo/prover/protocol/wizard" | ||
|
||
func IntoLogDerivativeSum(comp *wizard.CompiledIOP) { | ||
panic("unimplemented") | ||
} |
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,7 @@ | ||
package local | ||
|
||
import "github.com/consensys/linea-monorepo/prover/protocol/wizard" | ||
|
||
func IntoDistributedLocal(comp *wizard.CompiledIOP) { | ||
panic("unimplemented") | ||
} |
50 changes: 50 additions & 0 deletions
50
prover/protocol/distributed/compiler/permutation/permutation.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,50 @@ | ||
package permutation | ||
|
||
import ( | ||
"github.com/consensys/linea-monorepo/prover/protocol/coin" | ||
"github.com/consensys/linea-monorepo/prover/protocol/compiler/permutation" | ||
"github.com/consensys/linea-monorepo/prover/protocol/query" | ||
"github.com/consensys/linea-monorepo/prover/protocol/wizard" | ||
) | ||
|
||
func IntoGrandProduct(comp *wizard.CompiledIOP) { | ||
numRounds := comp.NumRounds() | ||
|
||
/* | ||
Handles the lookups and permutations checks | ||
*/ | ||
for i := 0; i < numRounds; i++ { | ||
queries := comp.QueriesNoParams.AllKeysAt(i) | ||
for _, qName := range queries { | ||
// Skip if it was already compiled | ||
if comp.QueriesNoParams.IsIgnored(qName) { | ||
continue | ||
} | ||
|
||
switch q_ := comp.QueriesNoParams.Data(qName).(type) { | ||
case query.Permutation: | ||
reducePermutationIntoGrandProduct(comp, q_, i) | ||
} | ||
} | ||
} | ||
} | ||
// The below function does the following: | ||
// 1. Register beta and alpha (for the random linear combination in case A and B are multi-columns) | ||
// 2. Tell the prover that they are not needed to be sampled as they are to be fetched from the randomness beacon | ||
func reducePermutationIntoGrandProduct(comp *wizard.CompiledIOP, q query.Permutation, round int) { | ||
var ( | ||
isMultiColumn = len(q.A[0]) > 1 | ||
alpha coin.Info | ||
// beta has to be different for different for different queries for the soundness of z-packing | ||
beta = comp.InsertCoin(round+1, permutation.DeriveName[coin.Name](q, "BETA"), coin.Field) | ||
) | ||
|
||
if isMultiColumn { | ||
alpha = comp.InsertCoin(round+1, permutation.DeriveName[coin.Name](q, "ALPHA"), coin.Field) | ||
} | ||
|
||
// Reduce a permutation query into a GrandProduct query | ||
comp.InsertGrandProduct(round, q.Name(), alpha, beta) | ||
arijitdutta67 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
} |
7 changes: 7 additions & 0 deletions
7
prover/protocol/distributed/compiler/projection/projection.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,7 @@ | ||
package projection | ||
|
||
import "github.com/consensys/linea-monorepo/prover/protocol/wizard" | ||
|
||
func IntoGrandSum(comp *wizard.CompiledIOP) { | ||
panic("unimplemented") | ||
} |
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,98 @@ | ||
package distributed | ||
|
||
import ( | ||
"github.com/consensys/linea-monorepo/prover/maths/field" | ||
"github.com/consensys/linea-monorepo/prover/protocol/compiler/mimc" | ||
"github.com/consensys/linea-monorepo/prover/protocol/compiler/specialqueries" | ||
"github.com/consensys/linea-monorepo/prover/protocol/distributed/compiler/global" | ||
"github.com/consensys/linea-monorepo/prover/protocol/distributed/compiler/inclusion" | ||
"github.com/consensys/linea-monorepo/prover/protocol/distributed/compiler/local" | ||
"github.com/consensys/linea-monorepo/prover/protocol/distributed/compiler/permutation" | ||
"github.com/consensys/linea-monorepo/prover/protocol/distributed/compiler/projection" | ||
"github.com/consensys/linea-monorepo/prover/protocol/ifaces" | ||
"github.com/consensys/linea-monorepo/prover/protocol/wizard" | ||
) | ||
|
||
type moduleName = string | ||
|
||
type DistributedWizard struct { | ||
Bootstrapper *wizard.CompiledIOP | ||
DistributedModules []DistributedModule | ||
Aggregator *wizard.CompiledIOP | ||
} | ||
|
||
// DistributedModule implements the utilities relevant to a single segment. | ||
type DistributedModule struct { | ||
LookupPermProj *wizard.CompiledIOP | ||
GlobalLocal *wizard.CompiledIOP | ||
VK [2]field.Element | ||
} | ||
|
||
type ModuleDiscoverer interface { | ||
// Analyze is responsible for letting the module discoverer compute how to | ||
// group best the columns into modules. | ||
Analyze(comp *wizard.CompiledIOP) | ||
NbModules() int | ||
ModuleList(comp *wizard.CompiledIOP) []string | ||
arijitdutta67 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
FindModule(col ifaces.Column) moduleName | ||
} | ||
|
||
// This transforms the initial wizard. So it is not really the initial | ||
// wizard anymore. That means the caller can forget about "initialWizard" | ||
// after calling the function. | ||
// maxNbSegment is a large max for the number of segments in a module. | ||
func Distribute(initialWizard *wizard.CompiledIOP, disc ModuleDiscoverer, maxNbSegments int) DistributedWizard { | ||
|
||
// prepare the initialWizard for the distribution. e.g., | ||
// adding auxiliary columns or dividing a lookup query to two queries one over T and the other over S. | ||
prepare(initialWizard) | ||
// it updates the map of Modules-Columns (that is a field of initialWizard). | ||
disc.Analyze(initialWizard) | ||
|
||
moduleLs := disc.ModuleList(initialWizard) | ||
distModules := []DistributedModule{} | ||
|
||
for _, modName := range moduleLs { | ||
// Segment Compilation; | ||
// Compile every dist module with the same sequence of compilation steps for uniformity | ||
distMod := extractDistModule(initialWizard, disc, modName) | ||
distModules = append(distModules, distMod) | ||
} | ||
|
||
// for each [DistributedModule] it checks the consistency among | ||
// its replications where the number of replications is maxNbSegments. | ||
aggr := aggregator(maxNbSegments, distModules, moduleLs) | ||
|
||
return DistributedWizard{ | ||
Bootstrapper: initialWizard, | ||
DistributedModules: distModules, | ||
Aggregator: aggr, | ||
} | ||
} | ||
|
||
// It adds the compilation steps | ||
func prepare(comp *wizard.CompiledIOP) { | ||
|
||
mimc.CompileMiMC(comp) | ||
specialqueries.RangeProof(comp) | ||
specialqueries.CompileFixedPermutations(comp) | ||
|
||
inclusion.IntoLogDerivativeSum(comp) | ||
permutation.IntoGrandProduct(comp) | ||
projection.IntoGrandSum(comp) | ||
local.IntoDistributedLocal(comp) | ||
global.IntoDistributedGlobal(comp) | ||
} | ||
|
||
func addSplittingStep(comp *wizard.CompiledIOP, disc ModuleDiscoverer) { | ||
panic("unimplemented") | ||
} | ||
|
||
func extractDistModule(comp *wizard.CompiledIOP, disc ModuleDiscoverer, moduleName moduleName) DistributedModule { | ||
panic("unimplemented") | ||
} | ||
|
||
|
||
func aggregator(n int, idsModules []DistributedModule, moduleNames []string) *wizard.CompiledIOP { | ||
panic("unimplemented") | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes considering that we will skip the preparation phase:
AddGdProductQuery(initialComp, moduleComp, disc, targetModuleName)