Files
accel/ops/crypto/crypto_msm_purego.go
zeekay ef39c02b90 ops/crypto: typed Curve enum and BLS12-381 G1 MSM via luxcpp/crypto cgo
- Replace MSM(curve string, ...) with MSM(curve Curve, ...). Curve enum
  values (0..3) match GPUKIT_CURVE_* in luxcpp/crypto so the cgo bridge
  forwards them unchanged.
- Drop the always-error msmCPU stub; route through gpukit_multi_pippenger_cpu
  via cgo when -tags=lux_crypto_native is set (CPU body is the same
  signed-digit Bos-Coster Pippenger that backs secp256k1 / bn254 / banderwagon).
- !cgo or !lux_crypto_native build returns ErrUnsupported so callers fall
  back to their own MSM (e.g. gnark-crypto MultiExp inside the EIP-2537
  bls12381 precompile).

Closes the audit hole at luxfi/precompile a5c7257e718ca0d94: MSM on
BLS12-381 G1 now has a real CPU implementation through accel.

Wire format (per Curve doc):
  CurveSecp256k1, CurveBN254, CurveBanderwagon : 64-byte BE x||y per point
  CurveBLS12_381                               : 96-byte BE x||y per point
  scalars                                      : 32-byte LE canonical
2026-04-29 01:05:23 -07:00

16 lines
576 B
Go

// Copyright (C) 2024-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
//go:build !cgo || !lux_crypto_native
// +build !cgo !lux_crypto_native
package crypto
// msmCPU is the pure-Go path. It returns ErrUnsupported so callers can fall
// back to their own MSM implementation (e.g. gnark-crypto MultiExp inside
// the EIP-2537 precompile). Build with `-tags=lux_crypto_native` and a CGO
// toolchain to route through luxcpp/crypto.
func msmCPU(curve Curve, scalars, points [][]byte) ([]byte, error) {
return nil, ErrUnsupported
}