Skip to content
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

feat: end-to-end modexp, ecadd, ecmul and ecpairing #39

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6d32557
chore: added .idea to .gitignore
NikitaMasych Sep 3, 2024
e7d6dd7
feat(zkevm_opcode_defs): added addresses for modexp, ecadd, ecmul, ec…
NikitaMasych Sep 3, 2024
a2a4cec
feat(zk_evm_abstractions): added modexp, ecadd, ecmul, ecpairing; exp…
NikitaMasych Sep 4, 2024
2716404
feat(zk_evm): added tests for modexp, ecadd, ecmul, ecpairing
NikitaMasych Sep 4, 2024
2c713f2
feat(zkevm_circuits): added modexp, ecadd, ecmul, ecpairing
NikitaMasych Sep 4, 2024
ff16146
feat(zkevm_circuits): added modexp, ecadd, ecmul, ecpairing to demux_…
NikitaMasych Sep 4, 2024
53ed5ee
feat(zkevm_circuits): added modexp, ecadd, ecmul, ecpairing to scheduler
NikitaMasych Sep 4, 2024
96d7bf0
feat(circuit_definitions): added modexp, ecadd, ecmul, ecpairing to b…
NikitaMasych Sep 4, 2024
bcf40f3
feat(circuit_sequencer_api): added modexp, ecadd, ecmul, ecpairing to…
NikitaMasych Sep 4, 2024
1fb62b6
feat(zkevm_test_harness): added modexp, ecadd, ecmul and ecpairing
NikitaMasych Sep 5, 2024
46d7a67
fix(zkevm_circuits): changed validation exceptions to reverse in bn254
NikitaMasych Sep 23, 2024
deeb541
fix: removed redundant validation in ecpairing
NikitaMasych Sep 26, 2024
07469dd
fix(zkevm_circuits): ecmul implementation
NikitaMasych Oct 1, 2024
315a125
fix: capacity estimator working to ecadd
NikitaMasych Oct 1, 2024
144d1e1
fix: capacity estimator working to ecmul
NikitaMasych Oct 1, 2024
b5c5006
fix: capacity estimator working to modexp
NikitaMasych Oct 2, 2024
4a342df
fix: capacity estimator working to ecpairing
NikitaMasych Oct 3, 2024
426e29d
feat(zk_evm_abstractions): enable ecpairing for arbitrary amount of p…
NikitaMasych Oct 3, 2024
3040ae0
feat: implemented ecpairing witness in test-harness
NikitaMasych Oct 4, 2024
ba7bcba
feat: optimized modexp
NikitaMasych Oct 4, 2024
297f231
fix(zkevm_test_harness): fixed stuff to run ecpairing capacity estima…
NikitaMasych Oct 4, 2024
75391e6
fix: corrected path to save geometry config and run estimation
NikitaMasych Oct 4, 2024
cb2d29d
fix(zk_evm_abstractions): remove unnecessary reads for b, e, m sizes …
NikitaMasych Oct 9, 2024
a4442a3
fix: correct ecpairing witness formation in abstractions + cargo fmt
NikitaMasych Oct 9, 2024
29acaa9
fix: correct modexp expected memory queries amount
NikitaMasych Oct 10, 2024
40e7625
fix: correct amount of queries in asserts for witnesses
NikitaMasych Oct 10, 2024
5f1aab7
feat: removed unnecessary modexp success query
NikitaMasych Oct 11, 2024
529ebbe
fix(zkevm_circuits): added zero exp handling
NikitaMasych Oct 11, 2024
da8ff1f
fix: ecpairing witness in memory_related + removed unnecessary comput…
NikitaMasych Oct 14, 2024
b47f72c
feat: updated basic_test.json
NikitaMasych Oct 14, 2024
dc2e152
perf(circuit_definitions): update ecpairing's CircuitBuilder
NikitaMasych Oct 17, 2024
89e3c75
fix: resolve warnings
NikitaMasych Oct 17, 2024
887daa9
feat(zkevm_test_harness): update basic_test.json
NikitaMasych Oct 17, 2024
e9c8da0
fix: rollback BASE_LAYER_CAP_SIZE to 16
NikitaMasych Oct 30, 2024
72b7fab
fix: resolve some issues around ecpairing witness formation
NikitaMasych Oct 31, 2024
0a465ca
fix: rollback RECURSION_LAYER_CAP_SIZE to 16
NikitaMasych Oct 31, 2024
b87df44
fix: resolve prover_utils after rebase
NikitaMasych Nov 15, 2024
f9e7a7f
fix: compute setup in harness includes up to ecpairing now
NikitaMasych Dec 11, 2024
920c6ed
fix: ecpairing fsm placeholder state defaults to 1
NikitaMasych Dec 11, 2024
a76e983
tmp: removed all harness artifacts, increased nextest timeout, custom…
NikitaMasych Dec 11, 2024
e3fda92
fix: post-review fixes
NikitaMasych Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tmp: removed all harness artifacts, increased nextest timeout, custom…
… encoding for ecpairing fsm
  • Loading branch information
NikitaMasych committed Dec 11, 2024
commit a76e983172fa0feb40e1b54903d2d17e21a0396d
2 changes: 1 addition & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[profile.default]
slow-timeout = { period = "180s", terminate-after = 5, grace-period = "30s" }
slow-timeout = { period = "5h", terminate-after = 5, grace-period = "30s" }

76 changes: 74 additions & 2 deletions crates/zkevm_circuits/src/bn254/ec_pairing/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ use serde::{Deserialize, Serialize};
Derivative,
CSAllocatable,
CSSelectable,
CSVarLengthEncodable,
WitnessHookable,
WitVarLengthEncodable,
)]
#[derivative(Clone, Debug)]
#[DerivePrettyComparison("true")]
Expand All @@ -41,6 +39,80 @@ pub struct EcPairingFunctionFSM<F: SmallField> {
pub precompile_call_params: EcPairingPrecompileCallParams<F>,
}

impl<F: SmallField> CircuitVarLengthEncodable<F> for EcPairingFunctionFSM<F> {
#[inline(always)]
fn encoding_length(&self) -> usize {
let mut total_len = 0;
total_len += CircuitVarLengthEncodable::<F>::encoding_length(&self.read_precompile_call);
total_len += CircuitVarLengthEncodable::<F>::encoding_length(&self.read_words_for_round);
total_len += CircuitVarLengthEncodable::<F>::encoding_length(&self.completed);
// total_len += CircuitVarLengthEncodable::<F>::encoding_length(&self.pairing_inner_state);
total_len +=
CircuitVarLengthEncodable::<F>::encoding_length(&self.timestamp_to_use_for_read);
total_len +=
CircuitVarLengthEncodable::<F>::encoding_length(&self.timestamp_to_use_for_write);
total_len += CircuitVarLengthEncodable::<F>::encoding_length(&self.precompile_call_params);
total_len
}
fn encode_to_buffer<CS: ConstraintSystem<F>>(&self, cs: &mut CS, dst: &mut Vec<Variable>) {
CircuitVarLengthEncodable::<F>::encode_to_buffer(&self.read_precompile_call, cs, dst);
CircuitVarLengthEncodable::<F>::encode_to_buffer(&self.read_words_for_round, cs, dst);
CircuitVarLengthEncodable::<F>::encode_to_buffer(&self.completed, cs, dst);
// CircuitVarLengthEncodable::<F>::encode_to_buffer(&self.pairing_inner_state, cs, dst);
CircuitVarLengthEncodable::<F>::encode_to_buffer(&self.timestamp_to_use_for_read, cs, dst);
CircuitVarLengthEncodable::<F>::encode_to_buffer(&self.timestamp_to_use_for_write, cs, dst);
CircuitVarLengthEncodable::<F>::encode_to_buffer(&self.precompile_call_params, cs, dst);
}
}

impl<F: SmallField> WitnessVarLengthEncodable<F> for EcPairingFunctionFSM<F> {
fn witness_encoding_length(witness: &Self::Witness) -> usize {
let mut total_len = 0;
total_len += <Boolean<F> as WitnessVarLengthEncodable<F>>::witness_encoding_length(
&witness.read_precompile_call,
);
total_len += <Boolean<F> as WitnessVarLengthEncodable<F>>::witness_encoding_length(
&witness.read_words_for_round,
);
total_len += <Boolean<F> as WitnessVarLengthEncodable<F>>::witness_encoding_length(
&witness.completed,
);
// total_len += <BN256Fq12NNField<F> as WitnessVarLengthEncodable<F>>::witness_encoding_length(&witness. pairing_inner_state);
total_len += <UInt32<F> as WitnessVarLengthEncodable<F>>::witness_encoding_length(
&witness.timestamp_to_use_for_read,
);
total_len += <UInt32<F> as WitnessVarLengthEncodable<F>>::witness_encoding_length(
&witness.timestamp_to_use_for_write,
);
total_len += <EcPairingPrecompileCallParams<F> as WitnessVarLengthEncodable<F>>::witness_encoding_length(&witness. precompile_call_params);
total_len
}
fn encode_witness_to_buffer(witness: &Self::Witness, dst: &mut Vec<F>) {
<Boolean<F> as WitnessVarLengthEncodable<F>>::encode_witness_to_buffer(
&witness.read_precompile_call,
dst,
);
<Boolean<F> as WitnessVarLengthEncodable<F>>::encode_witness_to_buffer(
&witness.read_words_for_round,
dst,
);
<Boolean<F> as WitnessVarLengthEncodable<F>>::encode_witness_to_buffer(
&witness.completed,
dst,
);
// <BN256Fq12NNField<F> as WitnessVarLengthEncodable<F>>::encode_witness_to_buffer(&witness. pairing_inner_state, dst);
<UInt32<F> as WitnessVarLengthEncodable<F>>::encode_witness_to_buffer(
&witness.timestamp_to_use_for_read,
dst,
);
<UInt32<F> as WitnessVarLengthEncodable<F>>::encode_witness_to_buffer(
&witness.timestamp_to_use_for_write,
dst,
);
<EcPairingPrecompileCallParams<F> as WitnessVarLengthEncodable<F>>::encode_witness_to_buffer(&witness. precompile_call_params, dst);
}
}

impl<F: SmallField> CSPlaceholder<F> for EcPairingFunctionFSM<F> {
fn placeholder<CS: ConstraintSystem<F>>(cs: &mut CS) -> Self {
let boolean_false = Boolean::allocated_constant(cs, false);
Expand Down
Binary file not shown.
188 changes: 0 additions & 188 deletions crates/zkevm_test_harness/setup/base_layer/finalization_hint_1.json

This file was deleted.

Loading