Skip to content

Commit

Permalink
add ingonyama grumpkin
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanting Zhang committed May 2, 2024
1 parent a46622f commit 3a40a82
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ rayon-scan = "0.1.0"
# grumpkin-msm has been patched to support MSMs for the pasta curve cycle
# see: https://github.com/lurk-lab/grumpkin-msm/pull/3
grumpkin-msm = { git = "https://github.com/lurk-lab/grumpkin-msm", branch = "dev" }
ingonyama-grumpkin-msm = { git = "https://github.com/lurk-lab/ingonyama-grumpkin-msm", optional = true }
ingonyama-grumpkin-msm = { git = "https://github.com/lurk-lab/ingonyama-grumpkin-msm", branch = "add-grumpkin-curve", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2.0", default-features = false, features = ["js"] }
Expand Down
15 changes: 13 additions & 2 deletions src/provider/bn256_grumpkin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use crate::{
use digest::{ExtendableOutput, Update};
use ff::{FromUniformBytes, PrimeField};
use group::{cofactor::CofactorCurveAffine, Curve, Group as AnotherGroup};
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use grumpkin_msm::grumpkin as grumpkin_msm;
// Remove this when https://github.com/zcash/pasta_curves/issues/41 resolves
use halo2curves::{bn256::G2Affine, CurveAffine, CurveExt};
use num_bigint::BigInt;
Expand Down Expand Up @@ -48,6 +46,19 @@ fn bn256_msm(points: &[bn256::Affine], scalars: &[bn256::Scalar]) -> bn256::Poin
}
}

#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
fn grumpkin_msm(points: &[grumpkin::Affine], scalars: &[grumpkin::Scalar]) -> grumpkin::Point {
cfg_if::cfg_if! {
if #[cfg(feature = "cuda")] {
let stream = ingonyama_grumpkin_msm::Config::new();
let cfg = ingonyama_grumpkin_msm::default_config(&stream.stream);
ingonyama_grumpkin_msm::grumpkin_msm(&points, &scalars, &cfg)
} else {
grumpkin_msm::grumpkin(points, scalars)
}
}
}

#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
impl_traits!(
bn256,
Expand Down

0 comments on commit 3a40a82

Please sign in to comment.