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

fix: Deactivate G2 precompiles #62

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions core/src/runtime/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,6 @@ impl MachineRecord for ExecutionRecord {
"k256_decompress_events".to_string(),
self.secp256k1_decompress_events.len(),
);
stats.insert(
"bls12381_g1_add_events".to_string(),
self.bls12381_g1_add_events.len(),
);
stats.insert(
"bls12381_fp_add_events".to_string(),
self.bls12381_fp_add_events.len(),
Expand Down
11 changes: 1 addition & 10 deletions core/src/stark/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use crate::air::{MachineAir, SPHINX_PROOF_NUM_PV_ELTS};
use crate::memory::{MemoryChipType, MemoryProgramChip};
use crate::stark::Chip;
use crate::syscall::precompiles::bls12_381::g1_decompress::Bls12381G1DecompressChip;
use crate::syscall::precompiles::bls12_381::g2_add::Bls12381G2AffineAddChip;
use crate::syscall::precompiles::bls12_381::g2_double::Bls12381G2AffineDoubleChip;
use crate::syscall::precompiles::field::add::FieldAddChip;
use crate::syscall::precompiles::field::mul::FieldMulChip;
use crate::syscall::precompiles::field::sub::FieldSubChip;
Expand Down Expand Up @@ -120,10 +118,6 @@ pub enum RiscvAir<F: PrimeField32> {
Bls12381Fp2Mul(QuadFieldMulChip<Bls12381BaseField>),
/// A precompile for decompressing a point on the BLS12-381 curve.
Bls12381G1Decompress(Bls12381G1DecompressChip),
/// A precompile for adding two G2Affine points on the BLS12-381 curve.
Bls12381G2Add(Bls12381G2AffineAddChip),
/// A precompile for doubling a G2Affine point on the BLS12-381 curve.
Bls12381G2AffineDouble(Bls12381G2AffineDoubleChip),
}

impl<F: PrimeField32> RiscvAir<F> {
Expand Down Expand Up @@ -184,12 +178,9 @@ impl<F: PrimeField32> RiscvAir<F> {
chips.push(RiscvAir::Bls12381Fp2Mul(bls12381_fp2_mul));
let bls12381_g1_decompress = Bls12381G1DecompressChip::new();
chips.push(RiscvAir::Bls12381G1Decompress(bls12381_g1_decompress));
let bls12381_g2_add = Bls12381G2AffineAddChip::new();
chips.push(RiscvAir::Bls12381G2Add(bls12381_g2_add));
let bls12381_g2_double = Bls12381G2AffineDoubleChip::new();
chips.push(RiscvAir::Bls12381G2AffineDouble(bls12381_g2_double));
let div_rem = DivRemChip;
chips.push(RiscvAir::DivRem(div_rem));

let add = AddSubChip;
chips.push(RiscvAir::Add(add));
let bitwise = BitwiseChip;
Expand Down
10 changes: 6 additions & 4 deletions core/src/syscall/precompiles/bls12_381/g2_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ where
}
}

#[allow(unused)] // Disabling for recursion performance
#[cfg(test)]
mod tests {
use crate::runtime::{Instruction, Opcode, SyscallCode};
Expand Down Expand Up @@ -700,7 +701,8 @@ mod tests {
assert_eq!(computed_y_c1, expected[3]);
}

#[test]
// Disabled for recursion performance
// #[test]
fn test_bls12381_g2_affine_add_precompile() {
// input data
let a_x_c0 = biguint_str_to_words("3017839990326613039145041105403203768289907560485999954764669466782738776913278597336115197412326608157502898901494", 10);
Expand Down Expand Up @@ -728,7 +730,7 @@ mod tests {
);
}

#[test]
// #[test]
fn test_bls12381_g2_affine_add_precompile_flaky_input() {
// input data
let a_x_c0 = biguint_str_to_words("940678610412633391924225779762290732605526547639243864351304234419401586596082223466014582312599779726285805697475", 10);
Expand Down Expand Up @@ -756,7 +758,7 @@ mod tests {
);
}

#[test]
// #[test]
fn test_bls12381_g2_affine_add_precompile_randomized_input() {
let mut rng = OsRng;
let a = G2Projective::random(&mut rng);
Expand Down Expand Up @@ -802,7 +804,7 @@ mod tests {
);
}

#[test]
// #[test]
fn test_bls12381_g2_addition_precompile_elf() {
setup_logger();
let program = Program::from(BLS12381_G2_ADD_ELF);
Expand Down
7 changes: 4 additions & 3 deletions core/src/syscall/precompiles/bls12_381/g2_double.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ where
}
}

#[allow(unused)] // Disabled for recursion performance
#[cfg(test)]
mod tests {
use crate::runtime::{Instruction, Opcode, SyscallCode};
Expand Down Expand Up @@ -648,7 +649,7 @@ mod tests {
assert_eq!(computed_y_c1, expected[3]);
}

#[test]
// #[test]
fn test_bls12381_g2_double_precompile() {
let p_ptr = 100u32;
let p = [
Expand All @@ -666,7 +667,7 @@ mod tests {
execute_test(p_ptr, &p, &expected);
}

#[test]
// #[test]
fn test_bls12381_g2_double_precompile_randomized_input() {
let mut rng = OsRng;
let p = G2Projective::random(&mut rng);
Expand All @@ -691,7 +692,7 @@ mod tests {
execute_test(p_ptr, &p, &expected);
}

#[test]
// #[test]
fn test_bls12381_g2_double_precompile_elf() {
setup_logger();
let program = Program::from(BLS12381_G2_DOUBLE_ELF);
Expand Down
1 change: 1 addition & 0 deletions prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ mod tests {
}

#[test]
#[ignore] // ignore for recursion performance reasons
fn test_deferred_proving_with_bls12381_g2_precompiles() {
fn test_inner(
program_elf: &[u8],
Expand Down
Loading