mirror of
https://github.com/luxfi/accel.git
synced 2026-10-30 17:03:45 +00:00
- 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
30 lines
799 B
Go
30 lines
799 B
Go
//go:build !accel
|
|
|
|
package crypto
|
|
|
|
import (
|
|
"github.com/luxfi/accel"
|
|
)
|
|
|
|
// When accel build tag is not set, GPU functions fall back to CPU
|
|
|
|
func batchVerifyGPU(sess *accel.Session, sigType SigType, sigs, msgs, pubkeys [][]byte) ([]bool, error) {
|
|
return batchVerifyCPU(sigType, sigs, msgs, pubkeys)
|
|
}
|
|
|
|
func hashGPU(sess *accel.Session, hashType HashType, inputs [][]byte) ([][32]byte, error) {
|
|
return hashCPU(hashType, inputs)
|
|
}
|
|
|
|
func msmGPU(sess *accel.Session, curve Curve, scalars, points [][]byte) ([]byte, error) {
|
|
return msmCPU(curve, scalars, points)
|
|
}
|
|
|
|
func aggregateSigsGPU(sess *accel.Session, signatures [][]byte) ([]byte, error) {
|
|
return aggregateSigsCPU(signatures)
|
|
}
|
|
|
|
func aggregatePksGPU(sess *accel.Session, pubkeys [][]byte) ([]byte, error) {
|
|
return aggregatePksCPU(pubkeys)
|
|
}
|