Skip to content

Commit

Permalink
refactor: Remove BLS12381 G2 Add and Double functionalities
Browse files Browse the repository at this point in the history
- Removed the `bls12381-g2-add` and `bls12381-g2-double` functions related to BLS12381 G2Affine points from various files.
- Deleted associated tests, files, modules, and references from test suite, codebase, libraries, and syscall map.
  • Loading branch information
huitseeker committed Oct 4, 2024
1 parent b392e25 commit 540fb6b
Show file tree
Hide file tree
Showing 19 changed files with 3 additions and 2,390 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ prover/build
prover/*.tar.gz

# IDE Conf
.idea
.idea
prover/data
40 changes: 0 additions & 40 deletions core/src/runtime/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ use crate::{
syscall::precompiles::{
bls12_381::{
g1_decompress::{Bls12381G1DecompressChip, Bls12381G1DecompressEvent},
g2_add::{Bls12381G2AffineAddChip, Bls12381G2AffineAddEvent},
g2_double::{Bls12381G2AffineDoubleChip, Bls12381G2AffineDoubleEvent},
},
field::{FieldChip, FieldEvent},
quad_field::{QuadFieldChip, QuadFieldEvent},
Expand Down Expand Up @@ -131,8 +129,6 @@ pub struct ExecutionRecord {
pub bls12381_fp_events: Vec<FieldEvent<Bls12381BaseField>>,
pub bls12381_fp2_events: Vec<QuadFieldEvent<Bls12381BaseField>>,
pub bls12381_g1_decompress_events: Vec<Bls12381G1DecompressEvent>,
pub bls12381_g2_add_events: Vec<Bls12381G2AffineAddEvent>,
pub bls12381_g2_double_events: Vec<Bls12381G2AffineDoubleEvent>,

// Blake2s
pub blake2s_round_events: Vec<Blake2sRoundEvent>,
Expand Down Expand Up @@ -262,18 +258,6 @@ impl EventLens<Secp256k1DecompressChip> for ExecutionRecord {
}
}

impl EventLens<Bls12381G2AffineAddChip> for ExecutionRecord {
fn events(&self) -> <Bls12381G2AffineAddChip as crate::air::WithEvents<'_>>::Events {
&self.bls12381_g2_add_events
}
}

impl EventLens<Bls12381G2AffineDoubleChip> for ExecutionRecord {
fn events(&self) -> <Bls12381G2AffineDoubleChip as crate::air::WithEvents<'_>>::Events {
&self.bls12381_g2_double_events
}
}

impl EventLens<FieldChip<Bls12381BaseField>> for ExecutionRecord {
fn events(&self) -> <FieldChip<Bls12381BaseField> as crate::air::WithEvents<'_>>::Events {
&self.bls12381_fp_events
Expand Down Expand Up @@ -495,14 +479,6 @@ impl MachineRecord for ExecutionRecord {
"bls12381_fp2_events".to_string(),
self.bls12381_fp2_events.len(),
);
stats.insert(
"bls12381_g2_add_events".to_string(),
self.bls12381_g2_add_events.len(),
);
stats.insert(
"bls12381_g2_double_events".to_string(),
self.bls12381_g2_double_events.len(),
);

stats.insert(
"blake2s_round_events".to_string(),
Expand Down Expand Up @@ -554,10 +530,6 @@ impl MachineRecord for ExecutionRecord {
.append(&mut other.bls12381_fp2_events);
self.bls12381_g1_decompress_events
.append(&mut other.bls12381_g1_decompress_events);
self.bls12381_g2_add_events
.append(&mut other.bls12381_g2_add_events);
self.bls12381_g2_double_events
.append(&mut other.bls12381_g2_double_events);
self.blake2s_round_events
.append(&mut other.blake2s_round_events);

Expand Down Expand Up @@ -887,18 +859,6 @@ impl MachineRecord for ExecutionRecord {
self.nonce_lookup.insert(event.lookup_id, i as u32);
}

// Bls12-381 G2Affine addition events.
first.bls12381_g2_add_events = take(&mut self.bls12381_g2_add_events);
for (i, event) in first.bls12381_g2_add_events.iter().enumerate() {
self.nonce_lookup.insert(event.lookup_id, i as u32);
}

// Bls12-381 G2Affine doubling events.
first.bls12381_g2_double_events = take(&mut self.bls12381_g2_double_events);
for (i, event) in first.bls12381_g2_double_events.iter().enumerate() {
self.nonce_lookup.insert(event.lookup_id, i as u32);
}

// blake2s_round events
first.blake2s_round_events = take(&mut self.blake2s_round_events);
for (i, event) in first.blake2s_round_events.iter().enumerate() {
Expand Down
10 changes: 0 additions & 10 deletions core/src/runtime/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use crate::runtime::{Register, Runtime};
use crate::stark::Ed25519Parameters;
use crate::syscall::precompiles::blake2s::Blake2sRoundChip;
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::edwards::EdAddAssignChip;
use crate::syscall::precompiles::edwards::EdDecompressChip;
use crate::syscall::precompiles::field::{FieldAddSyscall, FieldMulSyscall, FieldSubSyscall};
Expand Down Expand Up @@ -394,14 +392,6 @@ pub fn default_syscall_map() -> HashMap<SyscallCode, Arc<dyn Syscall>> {
SyscallCode::BLS12381_G1_DECOMPRESS,
Arc::new(Bls12381G1DecompressChip::new()),
);
syscall_map.insert(
SyscallCode::BLS12381_G2_ADD,
Arc::new(Bls12381G2AffineAddChip::new()),
);
syscall_map.insert(
SyscallCode::BLS12381_G2_DOUBLE,
Arc::new(Bls12381G2AffineDoubleChip::new()),
);
syscall_map.insert(
SyscallCode::SHA512_EXTEND,
Arc::new(Sha512ExtendChip::new()),
Expand Down
Loading

0 comments on commit 540fb6b

Please sign in to comment.