Skip to content

Commit 4d526ed

Browse files
committed
feat: integrate BLS precompile with zkevm
1 parent 81a8876 commit 4d526ed

File tree

2 files changed

+54
-11
lines changed

2 files changed

+54
-11
lines changed

prover/zkevm/settings.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package zkevm
33
import (
44
"github.com/consensys/linea-monorepo/prover/protocol/wizard"
55
"github.com/consensys/linea-monorepo/prover/zkevm/arithmetization"
6+
"github.com/consensys/linea-monorepo/prover/zkevm/prover/bls"
67
"github.com/consensys/linea-monorepo/prover/zkevm/prover/ecarith"
78
"github.com/consensys/linea-monorepo/prover/zkevm/prover/ecdsa"
89
"github.com/consensys/linea-monorepo/prover/zkevm/prover/ecpair"
@@ -27,6 +28,7 @@ type Settings struct {
2728
Ecadd, Ecmul ecarith.Limits
2829
Ecpair ecpair.Limits
2930
Sha2 sha2.Settings
31+
Bls bls.Limits
3032
PublicInput publicInput.Settings
3133
CompilationSuite CompilationSuite
3234
Metadata wizard.VersionMetadata

prover/zkevm/zkevm.go

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/consensys/linea-monorepo/prover/protocol/serialization"
66
"github.com/consensys/linea-monorepo/prover/protocol/wizard"
77
"github.com/consensys/linea-monorepo/prover/zkevm/arithmetization"
8+
"github.com/consensys/linea-monorepo/prover/zkevm/prover/bls"
89
"github.com/consensys/linea-monorepo/prover/zkevm/prover/ecarith"
910
"github.com/consensys/linea-monorepo/prover/zkevm/prover/ecdsa"
1011
"github.com/consensys/linea-monorepo/prover/zkevm/prover/ecpair"
@@ -45,6 +46,22 @@ type ZkEvm struct {
4546
// Sha2 is the module responsible for doing the computation of the Sha2
4647
// precompile.
4748
Sha2 *sha2.Sha2SingleProvider `json:"sha2"`
49+
// BlsG1Add is responsible for BLS G1 addition precompile.
50+
BlsG1Add *bls.BlsAdd `json:"blsG1Add"`
51+
// BlsG2Add is responsible for BLS G2 addition precompile.
52+
BlsG2Add *bls.BlsAdd `json:"blsG2Add"`
53+
// BlsG1Msm is responsible for BLS G1 multi-scalar multiplicaton precompile.
54+
BlsG1Msm *bls.BlsMsm `json:"blsG1Msm"`
55+
// BlsG2Msm is responsible for BLS G2 multi-scalar multiplication precompile.
56+
BlsG2Msm *bls.BlsMsm `json:"blsG2Msm"`
57+
// BlsG1Map is responsible for BLS Fp map to G1 precompile.
58+
BlsG1Map *bls.BlsMap `json:"blsG1Map"`
59+
// BlsG2Map is responsible for BLS Fp2 map to G2 precompile.
60+
BlsG2Map *bls.BlsMap `json:"blsG2Map"`
61+
// BlsPairingCheck is responsible for BLS pairing check precompile.
62+
BlsPairingCheck *bls.BlsPair `json:"blsPairingCheck"`
63+
// PointEval is responsible for EIP-4844 point evaluation precompile.
64+
PointEval *bls.BlsPointEval `json:"pointEval"`
4865
// Contains the actual wizard-IOP compiled object. This object is called to
4966
// generate the inner-proof.
5067
WizardIOP *wizard.CompiledIOP `json:"wizardIOP"`
@@ -93,17 +110,25 @@ func (z *ZkEvm) VerifyInner(proof wizard.Proof) error {
93110
func newZkEVM(b *wizard.Builder, s *Settings) *ZkEvm {
94111

95112
var (
96-
comp = b.CompiledIOP
97-
arith = arithmetization.NewArithmetization(b, s.Arithmetization)
98-
ecdsa = ecdsa.NewEcdsaZkEvm(comp, &s.Ecdsa)
99-
stateManager = statemanager.NewStateManager(comp, s.Statemanager)
100-
keccak = keccak.NewKeccakZkEVM(comp, s.Keccak, ecdsa.GetProviders())
101-
modexp = modexp.NewModuleZkEvm(comp, s.Modexp)
102-
ecadd = ecarith.NewEcAddZkEvm(comp, &s.Ecadd)
103-
ecmul = ecarith.NewEcMulZkEvm(comp, &s.Ecmul)
104-
ecpair = ecpair.NewECPairZkEvm(comp, &s.Ecpair)
105-
sha2 = sha2.NewSha2ZkEvm(comp, s.Sha2)
106-
publicInput = publicInput.NewPublicInputZkEVM(comp, &s.PublicInput, &stateManager.StateSummary)
113+
comp = b.CompiledIOP
114+
arith = arithmetization.NewArithmetization(b, s.Arithmetization)
115+
ecdsa = ecdsa.NewEcdsaZkEvm(comp, &s.Ecdsa)
116+
stateManager = statemanager.NewStateManager(comp, s.Statemanager)
117+
keccak = keccak.NewKeccakZkEVM(comp, s.Keccak, ecdsa.GetProviders())
118+
modexp = modexp.NewModuleZkEvm(comp, s.Modexp)
119+
ecadd = ecarith.NewEcAddZkEvm(comp, &s.Ecadd)
120+
ecmul = ecarith.NewEcMulZkEvm(comp, &s.Ecmul)
121+
ecpair = ecpair.NewECPairZkEvm(comp, &s.Ecpair)
122+
sha2 = sha2.NewSha2ZkEvm(comp, s.Sha2)
123+
blsG1Add = bls.NewG1AddZkEvm(comp, &s.Bls)
124+
blsG1Msm = bls.NewG1MsmZkEvm(comp, &s.Bls)
125+
blsG1Map = bls.NewG1MapZkEvm(comp, &s.Bls)
126+
blsG2Add = bls.NewG2AddZkEvm(comp, &s.Bls)
127+
blsG2Msm = bls.NewG2MsmZkEvm(comp, &s.Bls)
128+
blsG2Map = bls.NewG2MapZkEvm(comp, &s.Bls)
129+
blsPairingCheck = bls.NewPairingZkEvm(comp, &s.Bls)
130+
pointEval = bls.NewPointEvalZkEvm(comp, &s.Bls)
131+
publicInput = publicInput.NewPublicInputZkEVM(comp, &s.PublicInput, &stateManager.StateSummary)
107132
)
108133

109134
return &ZkEvm{
@@ -116,6 +141,14 @@ func newZkEVM(b *wizard.Builder, s *Settings) *ZkEvm {
116141
Ecmul: ecmul,
117142
Ecpair: ecpair,
118143
Sha2: sha2,
144+
BlsG1Add: blsG1Add,
145+
BlsG2Add: blsG2Add,
146+
BlsG1Msm: blsG1Msm,
147+
BlsG2Msm: blsG2Msm,
148+
BlsG1Map: blsG1Map,
149+
BlsG2Map: blsG2Map,
150+
BlsPairingCheck: blsPairingCheck,
151+
PointEval: pointEval,
119152
PublicInput: &publicInput,
120153
}
121154
}
@@ -139,6 +172,14 @@ func (z *ZkEvm) GetMainProverStep(input *Witness) (prover wizard.MainProverStep)
139172
z.Ecmul.Assign(run)
140173
z.Ecpair.Assign(run)
141174
z.Sha2.Run(run)
175+
z.BlsG1Add.Assign(run)
176+
z.BlsG2Add.Assign(run)
177+
z.BlsG1Msm.Assign(run)
178+
z.BlsG2Msm.Assign(run)
179+
z.BlsG1Map.Assign(run)
180+
z.BlsG2Map.Assign(run)
181+
z.BlsPairingCheck.Assign(run)
182+
z.PointEval.Assign(run)
142183
z.PublicInput.Assign(run, input.L2BridgeAddress, input.BlockHashList)
143184
}
144185
}

0 commit comments

Comments
 (0)