Files
gpu/ecrecover_nocgo.go
zeekay c4e0b229a2 ecrecover: short-circuit empty batch in no-CGO path + add tests
Empty/nil input now returns (nil, nil) on no-CGO builds so callers can
skip empty blocks without distinguishing build modes. Non-empty input
returns the new exported ErrEcrecoverNoCGO sentinel for fallback paths.

Pin the Signature and EcrecoverResult layouts (R/S/MsgHash 32 bytes,
Address 20 bytes, V/Valid scalar) and the empty-batch contract for
both build paths.
2026-04-28 02:23:14 -07:00

22 lines
689 B
Go

//go:build !cgo
package gpu
import "errors"
// BatchEcrecover recovers Ethereum addresses for a batch of signatures.
//
// Without CGO the GPU/native backend is unavailable. Empty and nil inputs
// short-circuit (callers use this to skip empty blocks without paying the
// cost of an FFI hop). A non-empty input returns ErrEcrecoverNoCGO so the
// caller can fall back to a pure-Go ecrecover path.
func BatchEcrecover(sigs []Signature) ([]EcrecoverResult, error) {
if len(sigs) == 0 {
return nil, nil
}
return nil, ErrEcrecoverNoCGO
}
// ErrEcrecoverNoCGO is returned by BatchEcrecover on builds without CGO.
var ErrEcrecoverNoCGO = errors.New("gpu: BatchEcrecover requires CGO")