mirror of
https://github.com/pseXperiments/icicle.git
synced 2026-01-14 15:37:56 -05:00
ICICLE example: MultiScalar Multiplication (MSM) in Rust
ICICLE provides Rust bindings to CUDA-accelerated C++ implementation of Multi-Scalar Multiplication.
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
- Define the size of MSM.
- Generate random inputs on-device
- Configure MSM
- Execute MSM on-device
- Move the result on host
Running the example:
# for CPU
./run.sh -d CPU
# for CUDA
./run.sh -d CUDA -b /path/to/cuda/backend/install/dir