From feb13f962c64f2cc555ea7a7928fe41f8cd10b8c Mon Sep 17 00:00:00 2001 From: Hanting Zhang Date: Thu, 14 Mar 2024 18:38:08 +0000 Subject: [PATCH 1/5] ingonyama msm --- Cargo.toml | 1 + src/provider/bn256_grumpkin.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ef6bf8523..466e6a0f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +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" } [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2.0", default-features = false, features = ["js"] } diff --git a/src/provider/bn256_grumpkin.rs b/src/provider/bn256_grumpkin.rs index 7418549b3..b6c9c218b 100644 --- a/src/provider/bn256_grumpkin.rs +++ b/src/provider/bn256_grumpkin.rs @@ -8,7 +8,7 @@ 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::{bn256 as bn256_msm, grumpkin as grumpkin_msm}; +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; @@ -35,12 +35,18 @@ pub mod grumpkin { }; } +fn ingonyama_bn256_msm(points: &[bn256::Affine], scalars: &[bn256::Scalar]) -> bn256::Point { + let stream = ingonyama_grumpkin_msm::Config::new(); + let cfg = ingonyama_grumpkin_msm::default_config(&stream.stream); + ingonyama_grumpkin_msm::bn256_msm(&points, &scalars, &cfg) +} + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] impl_traits!( bn256, "30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", "30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47", - bn256_msm + ingonyama_bn256_msm ); #[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))] impl_traits!( From 82732bd0c8810a6450dea84519558a5969181d77 Mon Sep 17 00:00:00 2001 From: Hanting Zhang Date: Thu, 21 Mar 2024 19:52:37 +0000 Subject: [PATCH 2/5] fix target arch --- Cargo.toml | 4 ++-- src/provider/bn256_grumpkin.rs | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 466e6a0f2..deb0f7b34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } +ingonyama-grumpkin-msm = { git = "https://github.com/lurk-lab/ingonyama-grumpkin-msm", optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2.0", default-features = false, features = ["js"] } @@ -117,7 +117,7 @@ abomonate = [] asm = ["halo2curves/asm"] # Compiles in portable mode, w/o ISA extensions => binary can be executed on all systems. portable = ["grumpkin-msm/portable"] -cuda = ["grumpkin-msm/cuda"] +cuda = ["grumpkin-msm/cuda", "ingonyama-grumpkin-msm"] flamegraph = ["pprof/flamegraph", "pprof/criterion"] [profile.dev-ci] diff --git a/src/provider/bn256_grumpkin.rs b/src/provider/bn256_grumpkin.rs index b6c9c218b..77e8d2612 100644 --- a/src/provider/bn256_grumpkin.rs +++ b/src/provider/bn256_grumpkin.rs @@ -8,7 +8,7 @@ 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}; +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; @@ -35,10 +35,17 @@ pub mod grumpkin { }; } -fn ingonyama_bn256_msm(points: &[bn256::Affine], scalars: &[bn256::Scalar]) -> bn256::Point { - let stream = ingonyama_grumpkin_msm::Config::new(); - let cfg = ingonyama_grumpkin_msm::default_config(&stream.stream); - ingonyama_grumpkin_msm::bn256_msm(&points, &scalars, &cfg) +#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] +fn bn256_msm(points: &[bn256::Affine], scalars: &[bn256::Scalar]) -> bn256::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::bn256_msm(&points, &scalars, &cfg) + } else { + grumpkin_msm::bn256(points, scalars) + } + } } #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] @@ -46,7 +53,7 @@ impl_traits!( bn256, "30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", "30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47", - ingonyama_bn256_msm + bn256_msm ); #[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))] impl_traits!( From a46622f0c7c5e2336c36d2a517ee5c4d7b9c4d23 Mon Sep 17 00:00:00 2001 From: Hanting Zhang Date: Fri, 22 Mar 2024 09:18:40 -0700 Subject: [PATCH 3/5] update license --- deny.toml | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/deny.toml b/deny.toml index 670589478..8eb2e8d39 100644 --- a/deny.toml +++ b/deny.toml @@ -109,6 +109,7 @@ allow = [ "Apache-2.0", "Apache-2.0 WITH LLVM-exception", "Unicode-DFS-2016", + "ISC", ] # List of explicitly disallowed licenses # See https://spdx.org/licenses/ for list of possible licenses @@ -147,22 +148,39 @@ exceptions = [ # Some crates don't have (easily) machine readable licensing information, # adding a clarification entry for it allows you to manually specify the # licensing information -#[[licenses.clarify]] +[[licenses.clarify]] # The name of the crate the clarification applies to -#name = "ring" +name = "icicle-cuda-runtime" # The optional version constraint for the crate -#version = "*" +version = "*" # The SPDX expression for the license requirements of the crate -#expression = "MIT AND ISC AND OpenSSL" +expression = "MIT" # One or more files in the crate's source used as the "source of truth" for # the license expression. If the contents match, the clarification will be used # when running the license check, otherwise the clarification will be ignored # and the crate will be checked normally, which may produce warnings or errors # depending on the rest of your configuration -#license-files = [ +license-files = [ # Each entry is a crate relative path, and the (opaque) hash of its contents - #{ path = "LICENSE", hash = 0xbd0eed23 } -#] + { path = "../../../LICENSE", hash = 0xbd0eed23 } +] + +[[licenses.clarify]] +name = "icicle-bn254" +version = "*" +expression = "MIT" +license-files = [ + { path = "../../../../LICENSE", hash = 0xbd0eed23 } +] + + +[[licenses.clarify]] +name = "icicle-core" +version = "*" +expression = "MIT" +license-files = [ + { path = "../../../LICENSE", hash = 0xbd0eed23 } +] [licenses.private] # If true, ignores workspace crates that aren't published, or are only @@ -267,7 +285,7 @@ allow-git = [] [sources.allow-org] # 1 or more github.com organizations to allow git sources for -github = ["lurk-lab"] +github = ["lurk-lab", "ingonyama-zk"] # 1 or more gitlab.com organizations to allow git sources for # gitlab = [""] # 1 or more bitbucket.org organizations to allow git sources for From 3a40a82a57332bf990e5f1e0019b828a49ab2986 Mon Sep 17 00:00:00 2001 From: Hanting Zhang Date: Thu, 2 May 2024 09:17:33 +0000 Subject: [PATCH 4/5] add ingonyama grumpkin --- Cargo.toml | 2 +- src/provider/bn256_grumpkin.rs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index deb0f7b34..94064e66c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] } diff --git a/src/provider/bn256_grumpkin.rs b/src/provider/bn256_grumpkin.rs index 77e8d2612..bf586c775 100644 --- a/src/provider/bn256_grumpkin.rs +++ b/src/provider/bn256_grumpkin.rs @@ -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; @@ -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, From da8a13c9e0a5c62d1f203fbb74098d1ef60ee3e6 Mon Sep 17 00:00:00 2001 From: Hanting Zhang Date: Thu, 2 May 2024 09:35:44 +0000 Subject: [PATCH 5/5] fix license --- Cargo.toml | 2 +- deny.toml | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 94064e66c..deb0f7b34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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", branch = "add-grumpkin-curve", optional = true } +ingonyama-grumpkin-msm = { git = "https://github.com/lurk-lab/ingonyama-grumpkin-msm", optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2.0", default-features = false, features = ["js"] } diff --git a/deny.toml b/deny.toml index 8eb2e8d39..919067ae2 100644 --- a/deny.toml +++ b/deny.toml @@ -173,6 +173,14 @@ license-files = [ { path = "../../../../LICENSE", hash = 0xbd0eed23 } ] +[[licenses.clarify]] +name = "icicle-grumpkin" +version = "*" +expression = "MIT" +license-files = [ + { path = "../../../../LICENSE", hash = 0xbd0eed23 } +] + [[licenses.clarify]] name = "icicle-core"