Skip to main content

Crate g1_msm_ref

Crate g1_msm_ref 

Source
Expand description

alt_bn128_g1_msm reference implementation

This crate is the proposed reference implementation of the alt_bn128_g1_msm SIMD: Σᵢ scalarsᵢ · pointsᵢ over BN254 G1, computed by a Pippenger window-NAF multi-scalar multiplication. It is no_std- compatible so the same code path can run on host (for off-chain verifiers) and inside agave’s syscall bridge.

Two entrypoints:

  • alt_bn128_g1_msm_be — proposed syscall surface. Takes the wire byte layout [n: u32 LE | scalar₀ | point₀ | scalar₁ | point₁ | …] and returns 64-byte BE G1Affine.
  • naive_msm_be — same surface, but implemented as n sequential scalar multiplications + additions. Serves as the baseline for benchmarks: it is what an on-chain verifier ends up doing today when it can only call alt_bn128_g1_multiplication_be per point.

Both functions reject identity points + zero scalars consistently (skipping their contribution rather than erroring), to match the existing alt_bn128_* syscalls’ semantics on the empty/identity input edge cases.

Enums§

MsmError
Wire-format error code matching the existing alt_bn128_* syscalls.

Functions§

alt_bn128_g1_msm_be
Wire format expected by the proposed alt_bn128_g1_msm_be syscall.
naive_msm_be
Baseline: sequential Σᵢ scalarᵢ · pointᵢ via per-point scalar mul + add.