Files
icicle/examples/rust/msm
ChickenLover 7265d18d48 ICICLE V2 Release (#492)
This PR introduces major updates for ICICLE Core, Rust and Golang
bindings

---------

Co-authored-by: Yuval Shekel <yshekel@gmail.com>
Co-authored-by: DmytroTym <dmytrotym1@gmail.com>
Co-authored-by: Otsar <122266060+Otsar-Raikou@users.noreply.github.com>
Co-authored-by: VitaliiH <vhnatyk@gmail.com>
Co-authored-by: release-bot <release-bot@ingonyama.com>
Co-authored-by: Stas <spolonsky@icloud.com>
Co-authored-by: Jeremy Felder <jeremy.felder1@gmail.com>
Co-authored-by: ImmanuelSegol <3ditds@gmail.com>
Co-authored-by: JimmyHongjichuan <45908291+JimmyHongjichuan@users.noreply.github.com>
Co-authored-by: pierre <pierreuu@gmail.com>
Co-authored-by: Leon Hibnik <107353745+LeonHibnik@users.noreply.github.com>
Co-authored-by: nonam3e <timur@ingonyama.com>
Co-authored-by: Vlad <88586482+vladfdp@users.noreply.github.com>
Co-authored-by: LeonHibnik <leon@ingonyama.com>
Co-authored-by: nonam3e <71525212+nonam3e@users.noreply.github.com>
Co-authored-by: vladfdp <vlad.heintz@gmail.com>
2024-04-23 05:26:40 +03:00
..
2024-04-23 05:26:40 +03:00
2024-04-23 05:26:40 +03:00
2024-01-08 23:48:24 +02:00

ICICLE example: MultiScalar Multiplication (MSM) in Rust

ICICLE provides Rust bindings to CUDA-accelerated C++ implementation of Multi-Scalar Multiplication.

Best Practices

In order to save time and setting up prerequisites manually, we recommend running this example in our ZKContainer.

Usage

msm(
  /* Scalars input vector */ &scalars, 
  /* Points input vector */ &points, 
  /* MSMConfig reference */ &cfg, 
  /* Projective point result */ &mut msm_results.as_slice()
).unwrap();

In this example we use BN254 curve. The function computes result = \sum_{i=0}^{size-1} scalars[i] \cdot points[i], where input points[] uses affine coordinates, and result uses projective coordinates.

What's in the example

  1. Define the size of MSM.
  2. Generate random inputs on-device
  3. Configure MSM
  4. Execute MSM on-device
  5. Move the result on host

Running the example:

cargo run --release

You can add the --feature arkworks,profile flag to measure times of both ICICLE and arkworks.

Note

The default sizes are 2^19 - 2^23. You can change this by passing the --lower_bound_log_size <size> --upper_bound_log_size <size> options. To change the size range to 2^21 - 2^24, run the example like this:

cargo run --release -- -l 21 -u 24

Benchmarks

These benchmarks were run on a 16 core 24 thread i9-12900k CPU and an RTX 3090 Ti GPU

Single BN254 MSM

Library\Size 2^19 2^20 2^21 2^22 2^23
ICICLE 10 ms 11 ms 21 ms 39 ms 77 ms
Arkworks 284 ms 540 ms 1,152 ms 2,320 ms 4,491 ms

Single BLS12377 MSM

Library\Size 2^19 2^20 2^21 2^22 2^23
ICICLE 9 ms 14 ms 25 ms 48 ms 93 ms
Arkworks 490 ms 918 ms 1,861 ms 3,624 ms 7,191 ms