Skip to content

Commit

Permalink
chore: Refactors CPU MSM operations using halo2curves library
Browse files Browse the repository at this point in the history
- Expanded the `msm` module within the `provider/util` directory and introduced a new function, `cpu_best_msm`.
- Changed the curves library dependency in `bn256_grumpkin.rs` from `pasta_curves` to `halo2curves`,
- Removed the `msm.rs` file along with two associated functions `cpu_msm_serial` and `cpu_best_msm` used for non-GPU accelerated operations, and all related tests.
- Reorganized the import of `CurveAffine, CurveExt` from the `halo2curves` library in `provider/mod.rs`.

Fixes argumentcomputer#193
  • Loading branch information
huitseeker committed Jan 3, 2024
1 parent d8008c3 commit 547539c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 158 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pasta-msm = { git = "https://github.com/lurk-lab/pasta-msm", branch = "dev", ver
grumpkin-msm = { git = "https://github.com/lurk-lab/grumpkin-msm", branch = "dev", features = ["dont-implement-sort"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
halo2curves = { version = "0.5.0", features = ["bits", "derive_serde"] }
halo2curves = { version = "0.5.0", features = ["bits", "derive_serde", "multicore"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
# see https://github.com/rust-random/rand/pull/948
Expand Down
4 changes: 2 additions & 2 deletions src/provider/bn256_grumpkin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use ff::{FromUniformBytes, PrimeField};
use group::{cofactor::CofactorCurveAffine, Curve, Group as AnotherGroup};
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use grumpkin_msm::{bn256 as bn256_msm, grumpkin as grumpkin_msm};
// Remove this when https://github.com/zcash/pasta_curves/issues/41 resolves
use halo2curves::{CurveAffine, CurveExt};
use num_bigint::BigInt;
use num_traits::Num;
// Remove this when https://github.com/zcash/pasta_curves/issues/41 resolves
use pasta_curves::arithmetic::{CurveAffine, CurveExt};
use rayon::prelude::*;
use sha3::Shake256;
use std::io::Read;
Expand Down
11 changes: 10 additions & 1 deletion src/provider/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/// Utilities for provider module
pub(in crate::provider) mod fb_msm;
pub(in crate::provider) mod msm;
pub mod msm {
use halo2curves::msm::best_multiexp;
use halo2curves::CurveAffine;

// this argument swap is useful until Rust gets named arguments
// and saves significant complexity in macro code
pub fn cpu_best_msm<C: CurveAffine>(bases: &[C], scalars: &[C::Scalar]) -> C::Curve {
best_multiexp(scalars, bases)
}
}
154 changes: 0 additions & 154 deletions src/provider/util/msm.rs

This file was deleted.

0 comments on commit 547539c

Please sign in to comment.