Skip to content

Commit

Permalink
feat(icicle): Add icicle MSM support
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-a16z committed Dec 2, 2024
1 parent 6198d4b commit 4a714c8
Show file tree
Hide file tree
Showing 35 changed files with 1,807 additions and 216 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ jobs:
with:
command: clippy
args: --all
- name: cargo clippy icicle
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all --features icicle

machete:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,6 +82,23 @@ jobs:
- name: Run jolt-core tests
run: cargo nextest run --release -p jolt-core

test-icicle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Cache Jolt RISC-V Rust toolchain
uses: actions/cache@v4
with:
key: jolt-rust-toolchain-${{hashFiles('guest-toolchain-tag')}}
path: ~/.jolt
- name: Install Jolt RISC-V Rust toolchain
run: cargo run install-toolchain
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Run jolt-core tests
run: cargo nextest run --release -p jolt-core --features icicle

on-chain:
name: Onchain Verifier Tests
runs-on: ubuntu-latest
Expand Down
66 changes: 66 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ members = [

[features]
host = ["jolt-sdk/host"]
icicle = ["jolt-core/icicle"]

[lib]
path = "./src/lib.rs"
Expand Down
3 changes: 3 additions & 0 deletions examples/alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "alloc-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/collatz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "collatz-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/fibonacci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "fibonacci-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
2 changes: 2 additions & 0 deletions examples/muldiv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ edition = "2021"
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "muldiv-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/multi-function/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "multi-function-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
5 changes: 4 additions & 1 deletion examples/overflow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ edition = "2021"

[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "overflow-guest", path = "./guest" }
guest = { package = "overflow-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/sha2-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "sha2-chain-guest", path = "./guest" }

hex = "0.4.3"

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/sha2-ex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "sha2-guest", path = "./guest" }

hex = "0.4.3"

[features]
icicle = ["jolt-sdk/icicle"]
4 changes: 3 additions & 1 deletion examples/sha3-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "sha3-chain-guest", path = "./guest" }
hex = "0.4.3"

hex = "0.4.3"
[features]
icicle = ["jolt-sdk/icicle"]
4 changes: 3 additions & 1 deletion examples/sha3-ex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "sha3-guest", path = "./guest" }

hex = "0.4.3"

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "stdlib-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
36 changes: 25 additions & 11 deletions jolt-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ repository = "https://github.com/a16z/jolt"
license-file = "LICENSE"
keywords = ["SNARK", "cryptography", "proofs"]

[features]
default = [
"ark-ec/parallel",
"ark-ff/parallel",
"ark-std/parallel",
"ark-ff/asm",
"host",
"rayon",
]
host = ["dep:reqwest", "dep:tokio"]
icicle = ["default", "dep:icicle-runtime", "dep:icicle-core", "dep:icicle-bn254"]

[dependencies]
ark-bn254 = "0.4.0"
ark-ec = { version = "0.4.2", default-features = false }
Expand Down Expand Up @@ -65,6 +77,7 @@ bytemuck = "1.19.0"
tokio = { version = "1.38.0", optional = true }
alloy-primitives = "0.7.6"
alloy-sol-types = "0.7.6"
once_cell = "1.19.0"

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
Expand Down Expand Up @@ -93,23 +106,24 @@ harness = false
name = "compute_cubic"
harness = false

[[bench]]
name = "msm"
harness = false

[[bench]]
name = "msm_batch"
harness = false

[lib]
name = "jolt_core"
path = "src/lib.rs"

[features]
default = [
"ark-ec/parallel",
"ark-ff/parallel",
"ark-std/parallel",
"ark-ff/asm",
"host",
"rayon",
]
host = ["dep:reqwest", "dep:tokio"]

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
icicle-runtime = { git = "https://github.com/ingonyama-zk/icicle.git", tag = "v3.1.0", optional = true }
icicle-core = { git = "https://github.com/ingonyama-zk/icicle.git", tag = "v3.1.0", optional = true }
icicle-bn254 = { git = "https://github.com/ingonyama-zk/icicle.git", tag = "v3.1.0", optional = true }
memory-stats = "1.0.0"
sys-info = "0.9.1"
tokio = { version = "1.38.0", optional = true, features = ["rt-multi-thread"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion jolt-core/benches/iai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn eval_poly_setup<F: JoltField>(size: usize) -> (DensePolynomial<F>, Vec<F>) {
#[library_benchmark]
#[bench::long(msm_setup::<G1Projective>(4096))]
fn bench_msm<G: CurveGroup>(input: (Vec<G>, Vec<G::ScalarField>)) -> G {
black_box(VariableBaseMSM::msm(&G::normalize_batch(&input.0), &input.1).unwrap())
black_box(VariableBaseMSM::msm(&G::normalize_batch(&input.0), None, &input.1).unwrap())
}

#[library_benchmark]
Expand Down
Loading

0 comments on commit 4a714c8

Please sign in to comment.